zhizhi wu 5 years ago
parent
commit
df27e33d30
  1. 2
      cloudutil/src/main/resources/application-util-test.yml
  2. 4
      ct/src/main/resources/application-test.yml
  3. 4
      ct/src/main/resources/druid-test.yml
  4. 4
      game/src/main/resources/application-test.yml
  5. 4
      game/src/main/resources/druid-test.yml
  6. 4
      health/src/main/resources/application-test.yml
  7. 4
      health/src/main/resources/druid-test.yml
  8. 18
      ht/src/main/java/com/ccsens/ht/api/DoctorController.java
  9. 51
      ht/src/main/java/com/ccsens/ht/api/ImportController.java
  10. 80
      ht/src/main/java/com/ccsens/ht/api/PatientReportController.java
  11. 6
      ht/src/main/java/com/ccsens/ht/aspect/DoctorAuditAspect.java
  12. 65
      ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java
  13. 12
      ht/src/main/java/com/ccsens/ht/bean/vo/DoctorVo.java
  14. 50
      ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java
  15. 21
      ht/src/main/java/com/ccsens/ht/persist/dao/HtDoctorDao.java
  16. 37
      ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java
  17. 51
      ht/src/main/java/com/ccsens/ht/service/DoctorService.java
  18. 9
      ht/src/main/java/com/ccsens/ht/service/IDoctorService.java
  19. 43
      ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java
  20. 181
      ht/src/main/java/com/ccsens/ht/service/PatientReportService.java
  21. 2
      ht/src/main/java/com/ccsens/ht/service/PatientService.java
  22. 5
      ht/src/main/java/com/ccsens/ht/uitl/Constant.java
  23. 4
      ht/src/main/resources/application-test.yml
  24. 4
      ht/src/main/resources/application.yml
  25. 4
      ht/src/main/resources/druid-test.yml
  26. 20
      ht/src/main/resources/mapper_dao/HtDoctorDao.xml
  27. 63
      ht/src/main/resources/mapper_dao/HtPatientReportDao.xml
  28. 2
      ht/src/main/resources/mapper_dao/HtPositionDao.xml
  29. 4
      mt/src/main/resources/application-test.yml
  30. 4
      mt/src/main/resources/druid-test.yml
  31. 4
      tall/src/main/resources/application-test.yml
  32. 4
      tall/src/main/resources/druid-test.yml
  33. 3
      util/src/main/java/com/ccsens/util/CodeEnum.java
  34. 4
      util/src/main/java/com/ccsens/util/bean/dto/QueryDto.java
  35. 58
      util/src/main/java/com/ccsens/util/config/RabbitMQConfig.java
  36. 66
      util/src/main/java/com/ccsens/util/mq/DelayConsumer.java
  37. 30
      util/src/main/java/com/ccsens/util/mq/DelayProducer.java

2
cloudutil/src/main/resources/application-util-test.yml

@ -20,7 +20,7 @@ eureka:
service-url: service-url:
# 指定eureka server通信地址,注意/eureka/小尾巴不能少 # 指定eureka server通信地址,注意/eureka/小尾巴不能少
#defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/ #defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/
defaultZone: http://admin:admin@49.233.89.188:7010/eureka/ defaultZone: http://admin:admin@192.168.0.99:7010/eureka/
instance: instance:
# 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server # 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server
prefer-ip-address: true prefer-ip-address: true

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

@ -8,7 +8,7 @@ spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
rabbitmq: rabbitmq:
host: api.ccsens.com host: 127.0.0.1
password: 111111 password: 111111
port: 5672 port: 5672
username: admin username: admin
@ -28,4 +28,4 @@ swagger:
enable: true enable: true
eureka: eureka:
instance: instance:
ip-address: 49.233.89.188 ip-address: 192.168.0.99

4
ct/src/main/resources/druid-test.yml

@ -15,7 +15,7 @@ spring:
maxWait: 60000 maxWait: 60000
minEvictableIdleTimeMillis: 300000 minEvictableIdleTimeMillis: 300000
minIdle: 5 minIdle: 5
password: password: 37080c1f223685592316b02dad8816c019290a476e54ebb638f9aa3ba8b6bdb9
poolPreparedStatements: true poolPreparedStatements: true
servletLogSlowSql: true servletLogSlowSql: true
servletLoginPassword: 111111 servletLoginPassword: 111111
@ -27,7 +27,7 @@ spring:
testOnReturn: false testOnReturn: false
testWhileIdle: true testWhileIdle: true
timeBetweenEvictionRunsMillis: 60000 timeBetweenEvictionRunsMillis: 60000
url: jdbc:mysql://127.0.0.1/ct?useUnicode=true&characterEncoding=UTF-8 url: jdbc:mysql://49.233.89.188/ct?useUnicode=true&characterEncoding=UTF-8
username: root username: root
validationQuery: SELECT 1 FROM DUAL validationQuery: SELECT 1 FROM DUAL
env: CCSENS_GAME env: CCSENS_GAME

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

@ -8,7 +8,7 @@ spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
rabbitmq: rabbitmq:
host: api.ccsens.com host: 192.168.0.99
password: 111111 password: 111111
port: 5672 port: 5672
username: admin username: admin
@ -28,4 +28,4 @@ swagger:
enable: true enable: true
eureka: eureka:
instance: instance:
ip-address: 49.233.89.188 ip-address: 192.168.0.99

4
game/src/main/resources/druid-test.yml

@ -15,7 +15,7 @@ spring:
maxWait: 60000 maxWait: 60000
minEvictableIdleTimeMillis: 300000 minEvictableIdleTimeMillis: 300000
minIdle: 5 minIdle: 5
password: password: 37080c1f223685592316b02dad8816c019290a476e54ebb638f9aa3ba8b6bdb9
poolPreparedStatements: true poolPreparedStatements: true
servletLogSlowSql: true servletLogSlowSql: true
servletLoginPassword: 111111 servletLoginPassword: 111111
@ -27,7 +27,7 @@ spring:
testOnReturn: false testOnReturn: false
testWhileIdle: true testWhileIdle: true
timeBetweenEvictionRunsMillis: 60000 timeBetweenEvictionRunsMillis: 60000
url: jdbc:mysql://127.0.0.1/game?useUnicode=true&characterEncoding=UTF-8 url: jdbc:mysql://49.233.89.188/game?useUnicode=true&characterEncoding=UTF-8
rname: root rname: root
validationQuery: SELECT 1 FROM DUAL validationQuery: SELECT 1 FROM DUAL
env: CCSENS_GAME env: CCSENS_GAME

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

@ -11,7 +11,7 @@ spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
rabbitmq: rabbitmq:
host: api.ccsens.com host: 192.168.0.99
password: 111111 password: 111111
port: 5672 port: 5672
username: admin username: admin
@ -31,7 +31,7 @@ swagger:
enable: true enable: true
eureka: eureka:
instance: instance:
ip-address: 49.233.89.188 ip-address: 192.168.0.99
file: file:
path: /home/cloud/health/uploads/ path: /home/cloud/health/uploads/
domain: https://test.tall.wiki/gateway/health/ domain: https://test.tall.wiki/gateway/health/

4
health/src/main/resources/druid-test.yml

@ -15,7 +15,7 @@ spring:
maxWait: 60000 maxWait: 60000
minEvictableIdleTimeMillis: 300000 minEvictableIdleTimeMillis: 300000
minIdle: 5 minIdle: 5
password: password: 37080c1f223685592316b02dad8816c019290a476e54ebb638f9aa3ba8b6bdb9
poolPreparedStatements: true poolPreparedStatements: true
servletLogSlowSql: true servletLogSlowSql: true
servletLoginPassword: 111111 servletLoginPassword: 111111
@ -27,7 +27,7 @@ spring:
testOnReturn: false testOnReturn: false
testWhileIdle: true testWhileIdle: true
timeBetweenEvictionRunsMillis: 60000 timeBetweenEvictionRunsMillis: 60000
url: jdbc:mysql://127.0.0.1/health?useUnicode=true&characterEncoding=UTF-8 url: jdbc:mysql://49.233.89.188/health?useUnicode=true&characterEncoding=UTF-8
username: root username: root
validationQuery: SELECT 1 FROM DUAL validationQuery: SELECT 1 FROM DUAL
env: CCSENS_GAME env: CCSENS_GAME

18
ht/src/main/java/com/ccsens/ht/api/DoctorController.java

@ -4,7 +4,9 @@ package com.ccsens.ht.api;
import com.ccsens.cloudutil.annotation.MustLogin; import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.ht.annotation.DoctorAudit; import com.ccsens.ht.annotation.DoctorAudit;
import com.ccsens.ht.bean.dto.DoctorDto; import com.ccsens.ht.bean.dto.DoctorDto;
import com.ccsens.ht.bean.po.HtDoctor;
import com.ccsens.ht.bean.vo.PatientReportVo; import com.ccsens.ht.bean.vo.PatientReportVo;
import com.ccsens.ht.uitl.Constant;
import com.ccsens.util.bean.dto.QueryDto; import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.ht.bean.vo.DoctorVo; import com.ccsens.ht.bean.vo.DoctorVo;
import com.ccsens.ht.service.IDoctorService; import com.ccsens.ht.service.IDoctorService;
@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List;
/** /**
* @program: ptpro * @program: ptpro
@ -113,4 +116,19 @@ public class DoctorController {
} }
@MustLogin
@DoctorAudit
@ApiOperation(value = "查询下属医生信息",notes = "查询下属医生信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "json", value = "查询下属医生信息", required = true)
})
@RequestMapping(value="/querySubordinate", method = RequestMethod.POST)
public JsonResponse<List<DoctorVo.Subordinate>> queryAllSubordinate(@RequestBody @ApiParam @Valid QueryDto params) {
log.info("查询下属信息请求参数:{}", params);
Long userId = params.getUserId();
List<DoctorVo.Subordinate> subordinates = doctorService.queryAllSubordinate(userId);
log.info("{}查询下属返回结果:{}", userId, subordinates);
return JsonResponse.newInstance().ok(subordinates);
}
} }

51
ht/src/main/java/com/ccsens/ht/api/ImportController.java

@ -71,6 +71,57 @@ public class ImportController {
} }
/**
*@Description:
*@Param:
*@return: com.ccsens.ptpro.util.JsonResponse
*@Author: wuhuijuan
*@date: 2020/5/14 11:21
*/
@ApiOperation(value = "导入importMoca",notes = "文件大小不能超过20M,支持后缀:.xls|.xlsx")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "医疗项目表", required = true, paramType = "form",dataType = "__file")
})
@RequestMapping(value = "/importMoca", method = RequestMethod.POST)
public JsonResponse importMoca(@RequestParam(required = true) Part file) throws Exception{
long time1 = System.currentTimeMillis();
//1.上传文件
String allowedExts = "xls,xlsx";
String dir = WebConstant.UPLOAD_PROJECT_WBS + File.separator;
String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir);
File execlFile = new File(dir+path);
long time2 = System.currentTimeMillis();
importService.importQuestion(execlFile, Constant.Ht.Report.MOCA);
log.info("导入moca");
return JsonResponse.newInstance().ok();
}
/**
*@Description:
*@Param:
*@return: com.ccsens.ptpro.util.JsonResponse
*@Author: wuhuijuan
*@date: 2020/5/14 11:21
*/
@ApiOperation(value = "导入importMoca",notes = "文件大小不能超过20M,支持后缀:.xls|.xlsx")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "医疗项目表", required = true, paramType = "form",dataType = "__file")
})
@RequestMapping(value = "/importMMSE", method = RequestMethod.POST)
public JsonResponse importMMSE(@RequestParam(required = true) Part file) throws Exception{
long time1 = System.currentTimeMillis();
//1.上传文件
String allowedExts = "xls,xlsx";
String dir = WebConstant.UPLOAD_PROJECT_WBS + File.separator;
String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir);
File execlFile = new File(dir+path);
long time2 = System.currentTimeMillis();
importService.importQuestion(execlFile, Constant.Ht.Report.MMSE);
log.info("导入mmse");
return JsonResponse.newInstance().ok();
}
} }

80
ht/src/main/java/com/ccsens/ht/api/PatientReportController.java

@ -4,6 +4,8 @@ package com.ccsens.ht.api;
import com.ccsens.ht.annotation.DoctorAudit; import com.ccsens.ht.annotation.DoctorAudit;
import com.ccsens.cloudutil.annotation.MustLogin; import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.ht.bean.dto.PatientReportDto; import com.ccsens.ht.bean.dto.PatientReportDto;
import com.ccsens.ht.bean.po.HtDoctor;
import com.ccsens.ht.uitl.Constant;
import com.ccsens.util.bean.dto.QueryDto; import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.ht.bean.vo.PatientReportVo; import com.ccsens.ht.bean.vo.PatientReportVo;
import com.ccsens.ht.service.IPatientReportService; import com.ccsens.ht.service.IPatientReportService;
@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.List;
/** /**
* @program: ptpro * @program: ptpro
@ -169,4 +172,81 @@ public class PatientReportController {
return JsonResponse.newInstance().ok(export); return JsonResponse.newInstance().ok(export);
} }
@MustLogin
@DoctorAudit
@ApiOperation(value = "查询下属医生的报告单列表",notes = "根据医生ID查询报告单列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "json", value = "查询下属医生的报告单列表", required = true)
})
@RequestMapping(value="/querySubordinateReports", method = RequestMethod.POST)
public JsonResponse<PageInfo<PatientReportVo.ReportName>> querySubordinateReports(@RequestBody @ApiParam @Valid QueryDto<PatientReportDto.Doctor> param){
//编辑报告单信息
log.info("查询某个医生的报告单列表:{}", param);
HtDoctor doctor = (HtDoctor) param.getOtherMsg().get(Constant.Ht.DOCTOR_PARAM);
PageInfo<PatientReportVo.ReportName> reportNamePageInfo = patientReportService.queryDoctorReports(param.getParam(), doctor, param.getUserId());
log.info("查询某个医生的报告单结果:{}", reportNamePageInfo);
return JsonResponse.newInstance().ok(reportNamePageInfo);
}
@MustLogin
@ApiOperation(value = "管理员查询报告单列表",notes = "管理员查询报告单列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "json", value = "管理员查询报告单列表", required = true)
})
@RequestMapping(value="/queryAllReports", method = RequestMethod.POST)
public JsonResponse<PageInfo<PatientReportVo.ReportName>> queryAllReports(@RequestBody @ApiParam @Valid QueryDto<PatientReportDto.AdminQueryReport> param){
//编辑报告单信息
log.info("管理员查询报告单列表请求参数:{}", param);
HtDoctor doctor = (HtDoctor) param.getOtherMsg().get(Constant.Ht.DOCTOR_PARAM);
PageInfo<PatientReportVo.ReportName> reportNamePageInfo = patientReportService.queryAllReports(param.getParam(), param.getUserId());
log.info("管理员查询报告单列表结果:{}", reportNamePageInfo);
return JsonResponse.newInstance().ok(reportNamePageInfo);
}
@MustLogin
@ApiOperation(value = "根据临床诊断统计",notes = "根据临床诊断统计")
@ApiImplicitParams({
@ApiImplicitParam(name = "json", value = "根据临床诊断统计", required = true)
})
@RequestMapping(value="/countByClinicalDiagnosis", method = RequestMethod.POST)
public JsonResponse<PatientReportVo.ClinicalDiagnosis> countByClinicalDiagnosis(@RequestBody @ApiParam @Valid QueryDto<PatientReportDto.ClinicalDiagnosis> param){
//编辑报告单信息
log.info("根据临床诊断统计请求参数:{}", param);
List<PatientReportVo.ClinicalDiagnosis> list = patientReportService.countByClinicalDiagnosis(param.getParam(), param.getUserId());
log.info("根据临床诊断统计结果:{}", list);
return JsonResponse.newInstance().ok(list);
}
@MustLogin
@ApiOperation(value = "根据年龄+性别统计",notes = "根据年龄+性别统计")
@ApiImplicitParams({
@ApiImplicitParam(name = "json", value = "根据年龄+性别统计", required = true)
})
@RequestMapping(value="/countBySexAndAge", method = RequestMethod.POST)
public JsonResponse<PatientReportVo.AgeAndSexGroup> countBySexAndAge(@RequestBody @ApiParam @Valid QueryDto<PatientReportDto.AgeAndSex> param){
log.info("根据临床诊断统计请求参数:{}", param);
List<PatientReportVo.AgeAndSexGroup> reportNamePageInfo = patientReportService.countBySexAndAge(param.getParam(), param.getUserId());
log.info("根据临床诊断统计结果:{}", reportNamePageInfo);
return JsonResponse.newInstance().ok(reportNamePageInfo);
}
@MustLogin
@ApiOperation(value = "根据日期统计",notes = "根据日期统计")
@ApiImplicitParams({
@ApiImplicitParam(name = "json", value = "根据日期统计", required = true)
})
@RequestMapping(value="/countByDay", method = RequestMethod.POST)
public JsonResponse<PatientReportVo.Day> countByDay(@RequestBody @ApiParam @Valid QueryDto<PatientReportDto.Day> param){
log.info("根据临床诊断统计请求参数:{}", param);
List<PatientReportVo.Day> reportNamePageInfo = patientReportService.countByDay(param.getParam(), param.getUserId());
log.info("根据临床诊断统计结果:{}", reportNamePageInfo);
return JsonResponse.newInstance().ok(reportNamePageInfo);
}
} }

6
ht/src/main/java/com/ccsens/ht/aspect/DoctorAuditAspect.java

@ -17,7 +17,9 @@ import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 判断医生是否审核通过 * 判断医生是否审核通过
@ -30,7 +32,7 @@ import java.util.List;
@Component @Component
public class DoctorAuditAspect { public class DoctorAuditAspect {
@Autowired @Resource
private HtDoctorMapper htDoctorMapper; private HtDoctorMapper htDoctorMapper;
@Pointcut("@annotation(com.ccsens.ht.annotation.DoctorAudit)") @Pointcut("@annotation(com.ccsens.ht.annotation.DoctorAudit)")
@ -49,6 +51,8 @@ public class DoctorAuditAspect {
return JsonResponse.newInstance().ok(CodeEnum.AUDIT_NOT_PASS); return JsonResponse.newInstance().ok(CodeEnum.AUDIT_NOT_PASS);
} }
Map<String, Object> map = dto.getOtherMsg();
map.put(Constant.Ht.DOCTOR_PARAM, doctors.get(0));
Object result =pjp.proceed(); Object result =pjp.proceed();
return result; return result;

65
ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java

@ -94,4 +94,69 @@ public class PatientReportDto {
@NotNull(message = "病人报告单ID不能为空") @NotNull(message = "病人报告单ID不能为空")
private Long id; private Long id;
} }
@ApiModel("医生ID")
@Data
public static class Doctor{
@ApiModelProperty("医生ID")
@NotNull(message = "医生ID不能为空")
private Long id;
@ApiModelProperty("第几页")
@Min(value = 1)
private int pageNum = 1;
@ApiModelProperty("每页多少条")
@Min(value = 1)
@Max(value=100)
private int pageSize = 10;
}
@ApiModel("查询报告单")
@Data
public static class AdminQueryReport {
@ApiModelProperty("病人年龄-开始")
private Byte startAge;
@ApiModelProperty("病人年龄-结束")
private Byte endAge;
@ApiModelProperty("性别")
private Byte patientSex;
@ApiModelProperty("临床诊断")
private String clinicalDiagnosis;
@ApiModelProperty("严重程度")
private Byte pasi;
@ApiModelProperty("开始时间")
private Long startTime;
@ApiModelProperty("结束时间")
private Long endTime;
@ApiModelProperty("第几页")
@Min(value = 1)
private int pageNum = 1;
@ApiModelProperty("每页多少条")
@Min(value = 1)
@Max(value=100)
private int pageSize = 10;
}
@ApiModel("临床诊断统计请求")
@Data
public static class ClinicalDiagnosis{
}
@ApiModel("年龄性别统计请求")
@Data
public static class AgeAndSex{
}
@ApiModel("日期统计请求")
@Data
public static class Day {
@ApiModelProperty("开始时间")
private Long startTime;
@ApiModelProperty("结束时间")
private Long endTime;
}
} }

12
ht/src/main/java/com/ccsens/ht/bean/vo/DoctorVo.java

@ -45,6 +45,18 @@ public class DoctorVo {
private String department; private String department;
} }
@Data
@ApiModel("下属信息")
public static class Subordinate{
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("职务名称")
private String positionName;
@ApiModelProperty("科室名称")
private String department;
}
} }

50
ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java

@ -61,6 +61,8 @@ public class PatientReportVo {
private Byte authority; private Byte authority;
@ApiModelProperty("报告单文件路径") @ApiModelProperty("报告单文件路径")
private String url; private String url;
@ApiModelProperty("医生ID")
private Long doctorId;
} }
@ApiModel("PatientReportVoReprotDetail") @ApiModel("PatientReportVoReprotDetail")
@ -423,4 +425,52 @@ public class PatientReportVo {
@ApiModelProperty("路径") @ApiModelProperty("路径")
private String path; private String path;
} }
@ApiModel("临床诊断统计")
@Data
public static class ClinicalDiagnosis{
@ApiModelProperty("临床诊断类型")
private String diagnosis;
@ApiModelProperty("对应人数")
private Integer count;
}
@ApiModel("年龄性别统计")
@Data
public static class AgeAndSex{
@ApiModelProperty("年龄段")
private Byte ageLevel;
@ApiModelProperty("性别")
private Byte sex;
@ApiModelProperty("对应人数")
private Integer count;
public AgeAndSex(){}
public AgeAndSex(Byte ageLevel, Byte sex, Integer count) {
this.ageLevel = ageLevel;
this.sex = sex;
this.count = count;
}
}
@ApiModel("年龄+性别统计")
@Data
public static class AgeAndSexGroup {
@ApiModelProperty("年龄段")
private String ageLevel;
@ApiModelProperty("男")
private AgeAndSex man;
@ApiModelProperty("女")
private AgeAndSex woman;
}
@ApiModel("日期统计")
@Data
public static class Day {
@ApiModelProperty("日期")
private String dateDay;
@ApiModelProperty("统计")
private Integer count;
}
} }

21
ht/src/main/java/com/ccsens/ht/persist/dao/HtDoctorDao.java

@ -0,0 +1,21 @@
package com.ccsens.ht.persist.dao;
import com.ccsens.ht.bean.vo.DoctorVo;
import com.ccsens.ht.persist.mapper.HtDoctorMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 医生信息
* @author whj
*/
public interface HtDoctorDao extends HtDoctorMapper {
/**
* 查询所有的下属信息
* @param positionId
* @return
*/
List<DoctorVo.Subordinate> queryAllSubordinate(@Param("positionId") Long positionId);
}

37
ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java

@ -1,5 +1,6 @@
package com.ccsens.ht.persist.dao; package com.ccsens.ht.persist.dao;
import com.ccsens.ht.bean.dto.PatientReportDto;
import com.ccsens.ht.bean.vo.PatientReportVo; import com.ccsens.ht.bean.vo.PatientReportVo;
import com.ccsens.ht.persist.mapper.HtPatientReportMapper; import com.ccsens.ht.persist.mapper.HtPatientReportMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -50,4 +51,40 @@ public interface HtPatientReportDao extends HtPatientReportMapper {
* @param userId * @param userId
*/ */
void ignoreComplete(@Param("id") Long id, @Param("userId") Long userId); void ignoreComplete(@Param("id") Long id, @Param("userId") Long userId);
/**
* 查询报告单名字ID名字导出路径
* @param doctorId 医生ID
* @param patientId 病人ID
* @return
*/
List<PatientReportVo.ReportName> queryReportName(@Param("doctorId")Long doctorId, @Param("patientId") Long patientId);
/**
* 管理员查询报告单
* @param adminQueryReport
* @return
*/
List<PatientReportVo.ReportName> queryAllReports(PatientReportDto.AdminQueryReport adminQueryReport);
/**
* 根据临床诊断统计
* @param param
* @return
*/
List<PatientReportVo.ClinicalDiagnosis> countByClinicalDiagnosis(PatientReportDto.ClinicalDiagnosis param);
/**
* 根据年龄性别统计
* @param param
* @return
*/
List<PatientReportVo.AgeAndSex> countBySexAndAge(PatientReportDto.AgeAndSex param);
/**
* 根据日期统计
* @param param
* @return
*/
List<PatientReportVo.Day> countByDay(PatientReportDto.Day param);
} }

51
ht/src/main/java/com/ccsens/ht/service/DoctorService.java

@ -10,23 +10,21 @@ import com.ccsens.ht.bean.dto.DoctorDto;
import com.ccsens.ht.bean.po.*; import com.ccsens.ht.bean.po.*;
import com.ccsens.ht.bean.vo.DoctorVo; import com.ccsens.ht.bean.vo.DoctorVo;
import com.ccsens.ht.persist.dao.HtDoctorAuditDao; import com.ccsens.ht.persist.dao.HtDoctorAuditDao;
import com.ccsens.ht.persist.dao.HtDoctorDao;
import com.ccsens.ht.persist.dao.HtPositionDao; import com.ccsens.ht.persist.dao.HtPositionDao;
import com.ccsens.ht.persist.dao.HtTitleDao; import com.ccsens.ht.persist.dao.HtTitleDao;
import com.ccsens.ht.persist.mapper.HtDoctorMapper;
import com.ccsens.ht.uitl.Constant; import com.ccsens.ht.uitl.Constant;
import com.ccsens.util.*; import com.ccsens.util.*;
import com.ccsens.util.exception.BaseException; import com.ccsens.util.exception.BaseException;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
@ -47,7 +45,7 @@ public class DoctorService implements IDoctorService {
@Autowired @Autowired
private Snowflake snowflake; private Snowflake snowflake;
@Resource @Resource
private HtDoctorMapper htDoctorMapper; private HtDoctorDao htDoctorDao;
@Resource @Resource
private HtPositionDao htPositionDao; private HtPositionDao htPositionDao;
@Resource @Resource
@ -66,7 +64,7 @@ public class DoctorService implements IDoctorService {
log.info("提交资格认证:{}", submit); log.info("提交资格认证:{}", submit);
HtDoctorExample example = new HtDoctorExample(); HtDoctorExample example = new HtDoctorExample();
example.createCriteria().andUserIdEqualTo(userId); example.createCriteria().andUserIdEqualTo(userId);
List<HtDoctor> htDoctors = htDoctorMapper.selectByExample(example); List<HtDoctor> htDoctors = htDoctorDao.selectByExample(example);
HtDoctor oldDoctor = null; HtDoctor oldDoctor = null;
for (HtDoctor doctor: htDoctors) { for (HtDoctor doctor: htDoctors) {
// 已经审核通过,无需重复审核 // 已经审核通过,无需重复审核
@ -98,14 +96,14 @@ public class DoctorService implements IDoctorService {
htDoctor.setId(oldDoctor.getId()); htDoctor.setId(oldDoctor.getId());
htDoctor.setAuditorId((long)Constant.Ht.NUMBER_DEFAULT); htDoctor.setAuditorId((long)Constant.Ht.NUMBER_DEFAULT);
htDoctor.setAuditState(Constant.Ht.Doctor.CHECK_WAIT); htDoctor.setAuditState(Constant.Ht.Doctor.CHECK_WAIT);
htDoctorMapper.updateByPrimaryKeySelective(htDoctor); htDoctorDao.updateByPrimaryKeySelective(htDoctor);
} else { } else {
htDoctor.setId(snowflake.nextId()); htDoctor.setId(snowflake.nextId());
htDoctor.setCreateTime(new Date()); htDoctor.setCreateTime(new Date());
htDoctor.setUserId(userId); htDoctor.setUserId(userId);
htDoctor.setAuditorId((long)Constant.Ht.NUMBER_DEFAULT); htDoctor.setAuditorId((long)Constant.Ht.NUMBER_DEFAULT);
htDoctor.setAuditState(Constant.Ht.Doctor.CHECK_WAIT); htDoctor.setAuditState(Constant.Ht.Doctor.CHECK_WAIT);
htDoctorMapper.insertSelective(htDoctor); htDoctorDao.insertSelective(htDoctor);
} }
@ -129,7 +127,7 @@ public class DoctorService implements IDoctorService {
HtDoctorExample example = new HtDoctorExample(); HtDoctorExample example = new HtDoctorExample();
example.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS); example.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS);
List<HtDoctor> htDoctors = htDoctorMapper.selectByExample(example); List<HtDoctor> htDoctors = htDoctorDao.selectByExample(example);
if (CollectionUtils.isEmpty(htDoctors)) { if (CollectionUtils.isEmpty(htDoctors)) {
log.info("用户:{}尚未审核通过", userId); log.info("用户:{}尚未审核通过", userId);
return new PageInfo<>(); return new PageInfo<>();
@ -162,14 +160,14 @@ public class DoctorService implements IDoctorService {
//审核用户 //审核用户
HtDoctorExample example = new HtDoctorExample(); HtDoctorExample example = new HtDoctorExample();
example.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS); example.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS);
List<HtDoctor> htDoctors = htDoctorMapper.selectByExample(example); List<HtDoctor> htDoctors = htDoctorDao.selectByExample(example);
if (CollectionUtils.isEmpty(htDoctors)) { if (CollectionUtils.isEmpty(htDoctors)) {
log.info("用户:{}尚未审核通过", userId); log.info("用户:{}尚未审核通过", userId);
return CodeEnum.AUDIT_NOT_PASS; return CodeEnum.AUDIT_NOT_PASS;
} }
Long auditDoctorId = htDoctors.get(0).getId(); Long auditDoctorId = htDoctors.get(0).getId();
//待审核用户 //待审核用户
HtDoctor waitDoctor = htDoctorMapper.selectByPrimaryKey(audit.getDoctorId()); HtDoctor waitDoctor = htDoctorDao.selectByPrimaryKey(audit.getDoctorId());
log.info("待审核医生信息:{}", waitDoctor); log.info("待审核医生信息:{}", waitDoctor);
if (waitDoctor == null) { if (waitDoctor == null) {
return CodeEnum.PARAM_ERROR; return CodeEnum.PARAM_ERROR;
@ -223,7 +221,7 @@ public class DoctorService implements IDoctorService {
eidtDoctor.setAuditState(audit.getAuditState()); eidtDoctor.setAuditState(audit.getAuditState());
eidtDoctor.setAuditorId(auditDoctorId); eidtDoctor.setAuditorId(auditDoctorId);
eidtDoctor.setId(audit.getDoctorId()); eidtDoctor.setId(audit.getDoctorId());
htDoctorMapper.updateByPrimaryKeySelective(eidtDoctor); htDoctorDao.updateByPrimaryKeySelective(eidtDoctor);
return CodeEnum.SUCCESS; return CodeEnum.SUCCESS;
} }
@ -256,7 +254,7 @@ public class DoctorService implements IDoctorService {
HtDoctorExample example1 = new HtDoctorExample(); HtDoctorExample example1 = new HtDoctorExample();
example1.createCriteria().andPositionIdEqualTo(map.getLong("id")).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS); example1.createCriteria().andPositionIdEqualTo(map.getLong("id")).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS);
//查找上级职务对应的医生 //查找上级职务对应的医生
List<HtDoctor> superiors = htDoctorMapper.selectByExample(example1); List<HtDoctor> superiors = htDoctorDao.selectByExample(example1);
if(CollectionUtils.isEmpty(superiors)) { if(CollectionUtils.isEmpty(superiors)) {
return; return;
} }
@ -278,20 +276,13 @@ public class DoctorService implements IDoctorService {
@Override @Override
public List<HtDoctor> selectByExample(HtDoctorExample doctorExample) { public List<HtDoctor> selectByExample(HtDoctorExample doctorExample) {
return htDoctorMapper.selectByExample(doctorExample); return htDoctorDao.selectByExample(doctorExample);
} }
@Override @Override
public String getShareUrl(Long userId) throws Exception { public String getShareUrl(Long userId) throws Exception {
HtDoctorExample example = new HtDoctorExample(); HtDoctor doctor = getHtDoctor(userId);
example.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS);
List<HtDoctor> htDoctors = htDoctorMapper.selectByExample(example);
if (CollectionUtil.isEmpty(htDoctors)) {
log.info("没有找到{}对应的医生信息", userId);
throw new BaseException(CodeEnum.PARAM_ERROR);
}
HtDoctor doctor = htDoctors.get(0);
if (StrUtil.isNotBlank(doctor.getSharePatientEdit())) { if (StrUtil.isNotBlank(doctor.getSharePatientEdit())) {
return doctor.getSharePatientEdit(); return doctor.getSharePatientEdit();
} }
@ -306,9 +297,27 @@ public class DoctorService implements IDoctorService {
} }
private HtDoctor getHtDoctor(Long userId) {
HtDoctorExample example = new HtDoctorExample();
example.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS);
List<HtDoctor> htDoctors = htDoctorDao.selectByExample(example);
if (CollectionUtil.isEmpty(htDoctors)) {
log.info("没有找到{}对应的医生信息", userId);
throw new BaseException(CodeEnum.PARAM_ERROR);
}
return htDoctors.get(0);
}
@Override @Override
public DoctorVo.Query queryDoctorStatus(Long userId) { public DoctorVo.Query queryDoctorStatus(Long userId) {
DoctorVo.Query query = htDoctorAuditDao.queryDoctorStatus(userId); DoctorVo.Query query = htDoctorAuditDao.queryDoctorStatus(userId);
return query; return query;
} }
@Override
public List<DoctorVo.Subordinate> queryAllSubordinate(Long userId) {
HtDoctor doctor = getHtDoctor(userId);
return htDoctorDao.queryAllSubordinate(doctor.getPositionId());
}
} }

9
ht/src/main/java/com/ccsens/ht/service/IDoctorService.java

@ -7,6 +7,7 @@ import com.ccsens.ht.bean.vo.DoctorVo;
import com.ccsens.util.CodeEnum; import com.ccsens.util.CodeEnum;
import com.ccsens.util.JsonResponse; import com.ccsens.util.JsonResponse;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -65,4 +66,12 @@ public interface IDoctorService {
* @return * @return
*/ */
String getShareUrl(Long userId) throws Exception; String getShareUrl(Long userId) throws Exception;
/**
* 查询所有的下属信息
* @param userId
* @return
*/
List<DoctorVo.Subordinate> queryAllSubordinate(Long userId);
} }

43
ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java

@ -1,12 +1,14 @@
package com.ccsens.ht.service; package com.ccsens.ht.service;
import com.ccsens.ht.bean.dto.PatientReportDto; import com.ccsens.ht.bean.dto.PatientReportDto;
import com.ccsens.ht.bean.po.HtDoctor;
import com.ccsens.ht.bean.vo.PatientReportVo; import com.ccsens.ht.bean.vo.PatientReportVo;
import com.ccsens.util.CodeEnum; import com.ccsens.util.CodeEnum;
import com.ccsens.util.JsonResponse; import com.ccsens.util.JsonResponse;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import java.io.IOException; import java.io.IOException;
import java.util.List;
public interface IPatientReportService { public interface IPatientReportService {
@ -89,4 +91,45 @@ public interface IPatientReportService {
* @return * @return
*/ */
void ignoreComplete(PatientReportDto.Ignore ignore, Long userId); void ignoreComplete(PatientReportDto.Ignore ignore, Long userId);
/**
* 查询某个医生的报告单列表
* @param param
* @param doctor
* @param userId
* @return
*/
PageInfo<PatientReportVo.ReportName> queryDoctorReports(PatientReportDto.Doctor param, HtDoctor doctor, Long userId);
/**
* 管理员查询报告单列表
* @param param
* @param userId
* @return
*/
PageInfo<PatientReportVo.ReportName> queryAllReports(PatientReportDto.AdminQueryReport param, Long userId);
/**
* 根据临床诊断统计
* @param param
* @param userId
* @return
*/
List<PatientReportVo.ClinicalDiagnosis> countByClinicalDiagnosis(PatientReportDto.ClinicalDiagnosis param, Long userId);
/**
* 根据性别年龄统计
* @param param
* @param userId
* @return
*/
List<PatientReportVo.AgeAndSexGroup> countBySexAndAge(PatientReportDto.AgeAndSex param, Long userId);
/**
* 根据日期统计
* @param param
* @param userId
* @return
*/
List<PatientReportVo.Day> countByDay(PatientReportDto.Day param, Long userId);
} }

181
ht/src/main/java/com/ccsens/ht/service/PatientReportService.java

@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
import com.ccsens.ht.bean.dto.PatientReportDto; import com.ccsens.ht.bean.dto.PatientReportDto;
import com.ccsens.ht.bean.po.*; import com.ccsens.ht.bean.po.*;
import com.ccsens.ht.bean.vo.PatientReportVo; import com.ccsens.ht.bean.vo.PatientReportVo;
import com.ccsens.ht.persist.dao.HtDoctorDao;
import com.ccsens.ht.persist.dao.HtPatientReportDao; import com.ccsens.ht.persist.dao.HtPatientReportDao;
import com.ccsens.ht.persist.dao.HtPositionDao; import com.ccsens.ht.persist.dao.HtPositionDao;
import com.ccsens.ht.persist.mapper.HtDoctorMapper; import com.ccsens.ht.persist.mapper.HtDoctorMapper;
@ -48,7 +49,7 @@ public class PatientReportService implements IPatientReportService {
@Autowired @Autowired
private Snowflake snowflake; private Snowflake snowflake;
@Resource @Resource
private HtDoctorMapper htDoctorMapper; private HtDoctorDao htDoctorDao;
@Resource @Resource
private HtPatientReportDao htPatientReportDao; private HtPatientReportDao htPatientReportDao;
@Resource @Resource
@ -66,7 +67,7 @@ public class PatientReportService implements IPatientReportService {
//查询医生信息 //查询医生信息
HtDoctorExample doctorExample = new HtDoctorExample(); HtDoctorExample doctorExample = new HtDoctorExample();
doctorExample.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS).andIsDelEqualTo(Constant.Ht.NUMBER_DEFAULT); doctorExample.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS).andIsDelEqualTo(Constant.Ht.NUMBER_DEFAULT);
List<HtDoctor> doctors = htDoctorMapper.selectByExample(doctorExample); List<HtDoctor> doctors = htDoctorDao.selectByExample(doctorExample);
if (CollectionUtils.isEmpty(doctors)) { if (CollectionUtils.isEmpty(doctors)) {
log.info("根据userId未找到审核通过的医生信息:{}", userId); log.info("根据userId未找到审核通过的医生信息:{}", userId);
return JsonResponse.newInstance().ok(CodeEnum.PARAM_ERROR); return JsonResponse.newInstance().ok(CodeEnum.PARAM_ERROR);
@ -109,7 +110,7 @@ public class PatientReportService implements IPatientReportService {
//查询修改医生信息 //查询修改医生信息
HtDoctorExample example = new HtDoctorExample(); HtDoctorExample example = new HtDoctorExample();
example.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS); example.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS);
List<HtDoctor> doctors = htDoctorMapper.selectByExample(example); List<HtDoctor> doctors = htDoctorDao.selectByExample(example);
if (CollectionUtils.isEmpty(doctors)) { if (CollectionUtils.isEmpty(doctors)) {
log.info("{}医生信息尚未审核通过"); log.info("{}医生信息尚未审核通过");
return CodeEnum.AUDIT_NOT_PASS; return CodeEnum.AUDIT_NOT_PASS;
@ -117,7 +118,7 @@ public class PatientReportService implements IPatientReportService {
HtDoctor doctor = doctors.get(0); HtDoctor doctor = doctors.get(0);
//判断该报告单是否为该医生的 //判断该报告单是否为该医生的
HtDoctor reportDoctor = htDoctorMapper.selectByPrimaryKey(htPatientReport.getDoctorId()); HtDoctor reportDoctor = htDoctorDao.selectByPrimaryKey(htPatientReport.getDoctorId());
// 上级医生和报告单医生允许修改 // 上级医生和报告单医生允许修改
List<Long> lowerPositionIds = htPositionDao.queryAllLowerPosition(doctor.getPositionId()); List<Long> lowerPositionIds = htPositionDao.queryAllLowerPosition(doctor.getPositionId());
if (!doctor.getId().equals(reportDoctor.getId()) && !lowerPositionIds.contains(reportDoctor.getPositionId())) { if (!doctor.getId().equals(reportDoctor.getId()) && !lowerPositionIds.contains(reportDoctor.getPositionId())) {
@ -160,68 +161,53 @@ public class PatientReportService implements IPatientReportService {
@Override @Override
public PageInfo<PatientReportVo.ReportName> queryReports(PatientReportDto.QueryReports query, Long userId) { public PageInfo<PatientReportVo.ReportName> queryReports(PatientReportDto.QueryReports query, Long userId) {
List<PatientReportVo.ReportName> reportVos = new ArrayList<>();
//分页查询报告单列表
PageHelper.startPage(query.getPageNum(), query.getPageSize());
HtPatientReportExample reportExample = new HtPatientReportExample();
//查询医生信息 //查询医生信息
HtDoctorExample doctorExample = new HtDoctorExample(); HtDoctorExample doctorExample = new HtDoctorExample();
doctorExample.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS).andIsDelEqualTo(Constant.Ht.NUMBER_DEFAULT); doctorExample.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS).andIsDelEqualTo(Constant.Ht.NUMBER_DEFAULT);
List<HtDoctor> doctors = htDoctorMapper.selectByExample(doctorExample); List<HtDoctor> doctors = htDoctorDao.selectByExample(doctorExample);
log.info("当前用户是否为医生:{}", CollectionUtil.isNotEmpty(doctors)); log.info("当前用户是否为医生:{}", CollectionUtil.isNotEmpty(doctors));
// 获取医生ID和病人ID
Long patientId = null;
Long doctorId = null;
if (query.getPatientId() != null) { if (query.getPatientId() != null) {
reportExample.createCriteria().andPatientIdEqualTo(query.getPatientId()).andShowStatusEqualTo(Constant.Ht.Report.SHOW_HISTORY); patientId = query.getPatientId();
//.andInitialImpressionIsNotNull().andInitialImpressionNotEqualTo("");
} else if (CollectionUtil.isNotEmpty(doctors)) { } else if (CollectionUtil.isNotEmpty(doctors)) {
reportExample.createCriteria().andDoctorIdEqualTo(doctors.get(0).getId()).andShowStatusEqualTo(Constant.Ht.Report.SHOW_HISTORY); doctorId = doctors.get(0).getId();
//.andInitialImpressionIsNotNull().andInitialImpressionNotEqualTo("");
} else { } else {
log.info("既无病人信息,有无医生信息,不允许查询"); log.info("既无病人信息,有无医生信息,不允许查询");
throw new BaseException(CodeEnum.PARAM_ERROR); throw new BaseException(CodeEnum.PARAM_ERROR);
} }
//分页查询报告单列表
reportExample.setOrderByClause("create_time desc"); PageHelper.startPage(query.getPageNum(), query.getPageSize());
List<HtPatientReport> reports = htPatientReportDao.selectByExample(reportExample); List<PatientReportVo.ReportName> reportVos = htPatientReportDao.queryReportName(doctorId, patientId);
if (CollectionUtils.isEmpty(reportVos)) {
if (CollectionUtils.isEmpty(reports)) {
return new PageInfo<>(reportVos); return new PageInfo<>(reportVos);
} }
if (CollectionUtil.isEmpty(doctors)) { if (CollectionUtil.isEmpty(doctors)) {
reports.forEach(report -> {
PatientReportVo.ReportName name = new PatientReportVo.ReportName();
name.setId(report.getId());
name.setName(report.getName());
name.setUrl(report.getUrl());
name.setAuthority((byte)0);
reportVos.add(name);
});
return new PageInfo<>(reportVos); return new PageInfo<>(reportVos);
} }
HtDoctor doctor = doctors.get(0); HtDoctor doctor = doctors.get(0);
//查询下属职务 //查询下属职务
List<Long> lowerPositionIds = htPositionDao.queryAllLowerPosition(doctor.getPositionId()); List<Long> lowerPositionIds = htPositionDao.queryAllLowerPosition(doctor.getPositionId());
reports.forEach(report -> { reportVos.forEach(reportVo -> {
PatientReportVo.ReportName name = new PatientReportVo.ReportName();
name.setId(report.getId());
name.setName(report.getName());
name.setUrl(report.getUrl());
//自己的可见详情 //自己的可见详情
if (doctor.getId().equals(report.getDoctorId())) { if (doctor.getId().equals(reportVo.getDoctorId())) {
name.setAuthority((byte)1); reportVo.setAuthority((byte)1);
} else if (CollectionUtils.isEmpty(lowerPositionIds)) { } else if (CollectionUtils.isEmpty(lowerPositionIds)) {
name.setAuthority((byte)0); reportVo.setAuthority((byte)0);
} else { } else {
HtDoctor reportDoctor = htDoctorMapper.selectByPrimaryKey(report.getDoctorId()); HtDoctor reportDoctor = htDoctorDao.selectByPrimaryKey(reportVo.getDoctorId());
//自己下属的可见详情 //自己下属的可见详情
if (lowerPositionIds.contains(reportDoctor.getPositionId())) { if (lowerPositionIds.contains(reportDoctor.getPositionId())) {
name.setAuthority((byte)1); reportVo.setAuthority((byte)1);
} else { } else {
name.setAuthority((byte)0); reportVo.setAuthority((byte)0);
} }
} }
reportVos.add(name);
}); });
return new PageInfo<>(reportVos); return new PageInfo<>(reportVos);
} }
@ -298,7 +284,7 @@ public class PatientReportService implements IPatientReportService {
//查询医生信息 //查询医生信息
HtDoctorExample doctorExample = new HtDoctorExample(); HtDoctorExample doctorExample = new HtDoctorExample();
doctorExample.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS).andIsDelEqualTo(Constant.Ht.NUMBER_DEFAULT); doctorExample.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS).andIsDelEqualTo(Constant.Ht.NUMBER_DEFAULT);
List<HtDoctor> doctors = htDoctorMapper.selectByExample(doctorExample); List<HtDoctor> doctors = htDoctorDao.selectByExample(doctorExample);
if (CollectionUtils.isEmpty(doctors)) { if (CollectionUtils.isEmpty(doctors)) {
authorityVo.setAuthority(PatientReportVo.Authority.OLAY_READ); authorityVo.setAuthority(PatientReportVo.Authority.OLAY_READ);
return authorityVo; return authorityVo;
@ -316,7 +302,7 @@ public class PatientReportService implements IPatientReportService {
return authorityVo; return authorityVo;
} }
//查询报告单关联医生职位 //查询报告单关联医生职位
HtDoctor doctor1 = htDoctorMapper.selectByPrimaryKey(htPatientReport.getDoctorId()); HtDoctor doctor1 = htDoctorDao.selectByPrimaryKey(htPatientReport.getDoctorId());
if (lowerPositionIds.contains(doctor1.getPositionId())) { if (lowerPositionIds.contains(doctor1.getPositionId())) {
authorityVo.setAuthority(PatientReportVo.Authority.CHECK); authorityVo.setAuthority(PatientReportVo.Authority.CHECK);
} else { } else {
@ -389,6 +375,7 @@ public class PatientReportService implements IPatientReportService {
PdfUtil.Cell initImplCell = addCell(row, detail.getPatient().getInitialImpression(), 6, 2); PdfUtil.Cell initImplCell = addCell(row, detail.getPatient().getInitialImpression(), 6, 2);
initImplCell.setHeight(PdfUtil.Cell.defaultHeight * 2); initImplCell.setHeight(PdfUtil.Cell.defaultHeight * 2);
initImplCell.setBorderRight(1); initImplCell.setBorderRight(1);
initImplCell.setCenter(false);
content.add(row); content.add(row);
PdfUtil.Row row2 = new PdfUtil.Row(); PdfUtil.Row row2 = new PdfUtil.Row();
PdfUtil.Cell doctorCell = addCell(row2, "测评员:", 4, 1, 0); PdfUtil.Cell doctorCell = addCell(row2, "测评员:", 4, 1, 0);
@ -454,4 +441,118 @@ public class PatientReportService implements IPatientReportService {
log.info("修改报告单二维码路径"); log.info("修改报告单二维码路径");
return qrCodeUrl; return qrCodeUrl;
} }
@Override
public PageInfo<PatientReportVo.ReportName> queryDoctorReports(PatientReportDto.Doctor param, HtDoctor doctor, Long userId) {
//判断被查询医生是否为下属
//查询下属职务
List<Long> lowerPositionIds = htPositionDao.queryAllLowerPosition(doctor.getPositionId());
log.info("下属职务:{}", lowerPositionIds);
if (CollectionUtils.isEmpty(lowerPositionIds)) {
throw new BaseException(CodeEnum.AUTHORITY_ERROR);
}
HtDoctor queryDoctor = htDoctorDao.selectByPrimaryKey(param.getId());
log.info("被查询医生信息:{}", queryDoctor);
if (queryDoctor == null){
throw new BaseException(CodeEnum.PARAM_ERROR);
}
if (!lowerPositionIds.contains(queryDoctor.getPositionId())) {
log.info("被查询医生不是当前医生的下属");
throw new BaseException(CodeEnum.AUTHORITY_ERROR);
}
// 查询该医生报告单
PageHelper.startPage(param.getPageNum(), param.getPageSize());
HtPatientReportExample reportExample = new HtPatientReportExample();
reportExample.createCriteria().andDoctorIdEqualTo(param.getId()).andShowStatusEqualTo(Constant.Ht.Report.SHOW_HISTORY);
reportExample.setOrderByClause("create_time desc");
List<PatientReportVo.ReportName> reports = htPatientReportDao.queryReportName(param.getId(), null);
if (CollectionUtils.isEmpty(reports)) {
log.info("未查询到报告单");
return new PageInfo<>(reports);
}
reports.forEach(report -> {
report.setAuthority((byte)1);
});
return new PageInfo<>(reports);
}
@Override
public PageInfo<PatientReportVo.ReportName> queryAllReports(PatientReportDto.AdminQueryReport adminQueryReport, Long userId) {
PageHelper.startPage(adminQueryReport.getPageNum(), adminQueryReport.getPageSize());
List<PatientReportVo.ReportName> reportNames = htPatientReportDao.queryAllReports(adminQueryReport);
return new PageInfo<>(reportNames);
}
@Override
public List<PatientReportVo.ClinicalDiagnosis> countByClinicalDiagnosis(PatientReportDto.ClinicalDiagnosis param, Long userId) {
return htPatientReportDao.countByClinicalDiagnosis(param);
}
@Override
public List<PatientReportVo.AgeAndSexGroup> countBySexAndAge(PatientReportDto.AgeAndSex param, Long userId) {
List<PatientReportVo.AgeAndSex> list = htPatientReportDao.countBySexAndAge(param);
List<PatientReportVo.AgeAndSexGroup> groups = new ArrayList<>();
List<Byte> ages = new ArrayList<>();
list.forEach(ageAndSex -> {
if (ages.isEmpty()) {
// 添加空白行
byte ageLevel = ageAndSex.getAgeLevel();
if (ageAndSex.getAgeLevel() > 0) {
fillBlankRow(groups, ageLevel, 0);
}
PatientReportVo.AgeAndSexGroup group = new PatientReportVo.AgeAndSexGroup();
group.setAgeLevel(ageLevel + "-" + (ageLevel + 10));
fillBySex(ageAndSex, group);
ages.add(ageAndSex.getAgeLevel());
groups.add(group);
return;
}
byte prevAge = ages.get(ages.size() - 1);
PatientReportVo.AgeAndSexGroup prevGroup = groups.get(groups.size()-1);
byte nowAge = ageAndSex.getAgeLevel().byteValue();
if (prevAge == nowAge) {
fillBySex(ageAndSex, prevGroup);
} else {
// 判断和上一个年龄相比,是否有空白段
if (nowAge - prevAge > 10) {
fillBlankRow(groups, nowAge, prevAge + 10);
}
//添加新的
PatientReportVo.AgeAndSexGroup group = new PatientReportVo.AgeAndSexGroup();
group.setAgeLevel(nowAge + "-" + (nowAge + 10));
fillBySex(ageAndSex, group);
ages.add(ageAndSex.getAgeLevel());
groups.add(group);
}
});
return groups;
}
private void fillBlankRow(List<PatientReportVo.AgeAndSexGroup> groups, byte nowAge, int prevAge) {
int level = 10;
for (int i = prevAge; i < nowAge; i += level) {
PatientReportVo.AgeAndSexGroup group = new PatientReportVo.AgeAndSexGroup();
group.setAgeLevel(i + "-" + (i + 10));
groups.add(group);
}
}
private void fillBySex(PatientReportVo.AgeAndSex ageAndSex, PatientReportVo.AgeAndSexGroup group) {
if (ageAndSex.getAgeLevel() == null) {
log.info("性别不确定");
return;
} else if (ageAndSex.getAgeLevel().byteValue() == Constant.Ht.SEX_MAN) {
group.setMan(ageAndSex);
} else {
group.setWoman(ageAndSex);
}
}
@Override
public List<PatientReportVo.Day> countByDay(PatientReportDto.Day param, Long userId) {
return htPatientReportDao.countByDay(param);
}
} }

2
ht/src/main/java/com/ccsens/ht/service/PatientService.java

@ -179,10 +179,12 @@ public class PatientService implements IPatientService {
throw new BaseException(CodeEnum.RECORDER_NOT); throw new BaseException(CodeEnum.RECORDER_NOT);
} }
patient.setId(oldPatient.getId()); patient.setId(oldPatient.getId());
patient.setIsDel(Constant.Ht.NUMBER_DEFAULT);
htPatientMapper.updateByPrimaryKey(patient); htPatientMapper.updateByPrimaryKey(patient);
} else { } else {
patient.setId(snowflake.nextId()); patient.setId(snowflake.nextId());
patient.setRecorder(userId); patient.setRecorder(userId);
patient.setIsDel(Constant.Ht.NUMBER_DEFAULT);
htPatientMapper.insert(patient); htPatientMapper.insert(patient);
} }
return patient.getId(); return patient.getId();

5
ht/src/main/java/com/ccsens/ht/uitl/Constant.java

@ -39,6 +39,11 @@ public class Constant {
public final static byte NUMBER_DEFAULT = 0; public final static byte NUMBER_DEFAULT = 0;
/**字符串默认值*/ /**字符串默认值*/
public final static String STRING_DEFAULT = ""; public final static String STRING_DEFAULT = "";
public final static String DOCTOR_PARAM = "doctor";
public final static byte SEX_MAN = 0;
public final static byte SEX_WOMAN = 1;
/**删除*/ /**删除*/
public final static byte IS_DEL = 1; public final static byte IS_DEL = 1;
public final static class Rule { public final static class Rule {

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

@ -8,7 +8,7 @@ spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
rabbitmq: rabbitmq:
host: api.ccsens.com host: 127.0.0.1
password: 111111 password: 111111
port: 5672 port: 5672
username: admin username: admin
@ -39,4 +39,4 @@ ht:
name: 认知功能评测云平台系统 name: 认知功能评测云平台系统
eureka: eureka:
instance: instance:
ip-address: 49.233.89.188 ip-address: 192.168.0.99

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

@ -1,4 +1,4 @@
spring: spring:
profiles: profiles:
active: prod active: test
include: common, util-prod include: common, util-test

4
ht/src/main/resources/druid-test.yml

@ -15,7 +15,7 @@ spring:
maxWait: 60000 maxWait: 60000
minEvictableIdleTimeMillis: 300000 minEvictableIdleTimeMillis: 300000
minIdle: 5 minIdle: 5
password: password: b3fd300ad4694070007fdcca961c4018211dc53235dd806ad62abc0cc0abb8e5
poolPreparedStatements: true poolPreparedStatements: true
servletLogSlowSql: true servletLogSlowSql: true
servletLoginPassword: 111111 servletLoginPassword: 111111
@ -27,7 +27,7 @@ spring:
testOnReturn: false testOnReturn: false
testWhileIdle: true testWhileIdle: true
timeBetweenEvictionRunsMillis: 60000 timeBetweenEvictionRunsMillis: 60000
url: jdbc:mysql://127.0.0.1/ht?useUnicode=true&characterEncoding=UTF-8 url: jdbc:mysql://49.233.89.188/ht?useUnicode=true&characterEncoding=UTF-8
username: root username: root
validationQuery: SELECT 1 FROM DUAL validationQuery: SELECT 1 FROM DUAL
env: CCSENS_HT env: CCSENS_HT

20
ht/src/main/resources/mapper_dao/HtDoctorDao.xml

@ -0,0 +1,20 @@
<?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.ht.persist.dao.HtDoctorDao">
<select id="queryAllSubordinate" resultType="com.ccsens.ht.bean.vo.DoctorVo$Subordinate">
select d.id, d.name, dp.name as positionName, p.name as department
from
t_ht_doctor d,
(select id,name,superior_department_id from (
select t1.id , name, t1.type,t1.superior_department_id, if(find_in_set(superior_id, @pids) > 0, @pids:=concat(@pids, ',', id), 0) as ischild
from
(select id, name, type, superior_id, superior_department_id from t_ht_position where is_del = 0 ORDER BY superior_id, id) t1,
(select @pids := #{positionId,jdbcType=BIGINT}) t2
) t3 where t3.type = 3 and ischild != 0) dp,
t_ht_position p
where d.position_id = dp.id and dp.superior_department_id = p.id
order by d.position_id asc
</select>
</mapper>

63
ht/src/main/resources/mapper_dao/HtPatientReportDao.xml

@ -78,6 +78,69 @@
where id = #{id, jdbcType=BIGINT} and complete_status = 0 and is_del = 0 and doctor_id in where id = #{id, jdbcType=BIGINT} and complete_status = 0 and is_del = 0 and doctor_id in
(select doctor_id from t_ht_doctor where user_id = #{userId, jdbcType=BIGINT} and audit_state = 1 and is_del = 0) (select doctor_id from t_ht_doctor where user_id = #{userId, jdbcType=BIGINT} and audit_state = 1 and is_del = 0)
</select> </select>
<select id="queryReportName" resultType="com.ccsens.ht.bean.vo.PatientReportVo$ReportName">
select id, name, url, doctor_id as doctorId, 0 as authority from t_ht_patient_report
<where>
<if test="doctorId != null">
and doctor_id = #{doctorId, jdbcType=BIGINT}
</if>
<if test="patientId != null">
and patient_id = #{patientId, jdbcType=BIGINT}
</if>
and show_status = 1
</where>
order by create_time desc
</select>
<select id="queryAllReports" resultType="com.ccsens.ht.bean.vo.PatientReportVo$ReportName">
select r.id, r.name, r.url, r.doctor_id as doctorId, 1 as authority
from t_ht_patient_report r, t_ht_patient p
where r.patient_id = p.id
<if test="patientSex != null">
and p.sex = #{patientSex}
</if>
<if test="startAge != null">
and r.patient_age &gt; #{startAge}
</if>
<if test="endAge != null">
and r.patient_age &lt; #{endAge}
</if>
<if test="clinicalDiagnosis != null and clinicalDiagnosis != ''">
and r.clinical_diagnosis = #{clinicalDiagnosis}
</if>
<if test="pasi != null">
and r.pasi = #{pasi}
</if>
<if test="startTime != null">
and r.report_time &gt;= #{startTime}
</if>
<if test="endTime != null">
and r.report_time &lt;= #{endTime}
</if>
and r.show_status = 1
and r.is_del = 0
order by r.create_time desc
</select>
<select id="countByClinicalDiagnosis" resultType="com.ccsens.ht.bean.vo.PatientReportVo$ClinicalDiagnosis">
select clinical_diagnosis as diagnosis, count(*) as count from t_ht_patient_report
where is_del = 0 and show_status = 1 group by diagnosis
</select>
<select id="countBySexAndAge" resultType="com.ccsens.ht.bean.vo.PatientReportVo$AgeAndSex">
select r.patient_age div 10 * 10 as ageLevel, p.sex as sex, count(*) as count from t_ht_patient_report r, t_ht_patient p
where r.patient_id = p.id and r.is_del = 0 and r.show_status = 1 group by ageLevel, sex
order by ageLevel, sex
</select>
<select id="countByDay" resultType="com.ccsens.ht.bean.vo.PatientReportVo$Day">
select FROM_UNIXTIME(report_time div 1000, '%Y-%m-%d') as dateDay, count(*) as count
from t_ht_patient_report
where is_del = 0 and show_status = 1
<if test="startTime != null">
and report_time &gt;= #{startTime}
</if>
<if test="endTime != null">
and report_time &lt; #{endTime}
</if>
group by dateDay
</select>
</mapper> </mapper>

2
ht/src/main/resources/mapper_dao/HtPositionDao.xml

@ -53,7 +53,7 @@
</select> </select>
<select id="queryAllLowerPosition" resultType="java.lang.Long"> <select id="queryAllLowerPosition" resultType="java.lang.Long">
select id from ( select id from (
select t1.id , name, t1.type, if(find_in_set(superior_id, @pids) > 0 or id=@pids, @pids:=concat(@pids, ',', id), 0) as ischild select t1.id , name, t1.type, if(find_in_set(superior_id, @pids) > 0, @pids:=concat(@pids, ',', id), 0) as ischild
from from
(select id, name, type, superior_id from t_ht_position where is_del = 0 ORDER BY superior_id, id) t1, (select id, name, type, superior_id from t_ht_position where is_del = 0 ORDER BY superior_id, id) t1,
(select @pids := #{id,jdbcType=BIGINT}) t2 (select @pids := #{id,jdbcType=BIGINT}) t2

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

@ -8,7 +8,7 @@ spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
rabbitmq: rabbitmq:
host: api.ccsens.com host: 127.0.0.1
password: 111111 password: 111111
port: 5672 port: 5672
username: admin username: admin
@ -28,4 +28,4 @@ swagger:
enable: true enable: true
eureka: eureka:
instance: instance:
ip-address: 49.233.89.188 ip-address: 192.168.0.99

4
mt/src/main/resources/druid-test.yml

@ -15,7 +15,7 @@ spring:
maxWait: 60000 maxWait: 60000
minEvictableIdleTimeMillis: 300000 minEvictableIdleTimeMillis: 300000
minIdle: 5 minIdle: 5
password: password: 37080c1f223685592316b02dad8816c019290a476e54ebb638f9aa3ba8b6bdb9
poolPreparedStatements: true poolPreparedStatements: true
servletLogSlowSql: true servletLogSlowSql: true
servletLoginPassword: 111111 servletLoginPassword: 111111
@ -27,7 +27,7 @@ spring:
testOnReturn: false testOnReturn: false
testWhileIdle: true testWhileIdle: true
timeBetweenEvictionRunsMillis: 60000 timeBetweenEvictionRunsMillis: 60000
url: jdbc:mysql://127.0.0.1/mt?useUnicode=true&characterEncoding=UTF-8 url: jdbc:mysql://49.233.89.188/mt?useUnicode=true&characterEncoding=UTF-8
username: root username: root
validationQuery: SELECT 1 FROM DUAL validationQuery: SELECT 1 FROM DUAL
env: CCSENS_GAME env: CCSENS_GAME

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

@ -11,7 +11,7 @@ spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
rabbitmq: rabbitmq:
host: api.ccsens.com host: 192.168.0.99
password: 111111 password: 111111
port: 5672 port: 5672
username: admin username: admin
@ -31,5 +31,5 @@ swagger:
enable: true enable: true
eureka: eureka:
instance: instance:
ip-address: 49.233.89.188 ip-address: 192.168.0.99
gatewayUrl: https://test.tall.wiki/gateway/ gatewayUrl: https://test.tall.wiki/gateway/

4
tall/src/main/resources/druid-test.yml

@ -15,7 +15,7 @@ spring:
maxWait: 60000 maxWait: 60000
minEvictableIdleTimeMillis: 300000 minEvictableIdleTimeMillis: 300000
minIdle: 5 minIdle: 5
password: password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473
poolPreparedStatements: true poolPreparedStatements: true
servletLogSlowSql: true servletLogSlowSql: true
servletLoginPassword: 111111 servletLoginPassword: 111111
@ -27,7 +27,7 @@ spring:
testOnReturn: false testOnReturn: false
testWhileIdle: true testWhileIdle: true
timeBetweenEvictionRunsMillis: 60000 timeBetweenEvictionRunsMillis: 60000
url: jdbc:mysql://127.0.0.1/tall?useUnicode=true&characterEncoding=UTF-8 url: jdbc:mysql://49.233.89.188/tall?useUnicode=true&characterEncoding=UTF-8
username: root username: root
validationQuery: SELECT 1 FROM DUAL validationQuery: SELECT 1 FROM DUAL
env: CCSENS_TALL env: CCSENS_TALL

3
util/src/main/java/com/ccsens/util/CodeEnum.java

@ -113,7 +113,8 @@ public enum CodeEnum {
NOT_HEALTH_RECORD(95,"您今天还未上报健康信息,请上报后再试。",true), NOT_HEALTH_RECORD(95,"您今天还未上报健康信息,请上报后再试。",true),
SELECT_TIME_ERROR(96,"请输入正确的查询时间",true), SELECT_TIME_ERROR(96,"请输入正确的查询时间",true),
DINGDING_EXCEPTION(97,"钉钉接口调用异常。",true), DINGDING_EXCEPTION(97,"钉钉接口调用异常。",true),
URL_ERROR(98, "请求路径转换异常", true), URL_ERROR(98, "请求路径转换异常。", true),
AUTHORITY_ERROR(99, "对不起,您没有操作权限。", true),
; ;
public CodeEnum addMsg(String msg){ public CodeEnum addMsg(String msg){

4
util/src/main/java/com/ccsens/util/bean/dto/QueryDto.java

@ -7,6 +7,8 @@ import org.springframework.validation.annotation.Validated;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.Map;
/** /**
* @program: ptpro * @program: ptpro
@ -22,4 +24,6 @@ public class QueryDto<T> {
private T param; private T param;
@ApiModelProperty("登录用户ID 前端不为userId赋值") @ApiModelProperty("登录用户ID 前端不为userId赋值")
private Long userId; private Long userId;
@ApiModelProperty("其他添加属性")
private Map<String, Object> otherMsg = new HashMap<>();
} }

58
util/src/main/java/com/ccsens/util/config/RabbitMQConfig.java

@ -13,9 +13,9 @@ public class RabbitMQConfig {
public static final String TALL_MESSAGE_1 = "tall_message_1"; public static final String TALL_MESSAGE_1 = "tall_message_1";
public static final String TALL_MESSAGE_2 = "tall_message_2"; public static final String TALL_MESSAGE_2 = "tall_message_2";
public static final String GAME_STATUS = "game_status"; public static final String GAME_STATUS = "game_status";
public static final String GAME_STATUS_DELAY_SEND_QUEUE = "gameStatusDelaySendQueue"; // public static final String GAME_STATUS_DELAY_SEND_QUEUE = "gameStatusDelaySendQueue";
public static final String GAME_STATUS_DELAY_SEND_EXCHANGE = "gameStatusDelaySendExchange"; // public static final String GAME_STATUS_DELAY_SEND_EXCHANGE = "gameStatusDelaySendExchange";
public static final String GAME_STATUS_DELAY_SEND_ROUTING_KEY = "gameStatusDelaySendRoutingKey"; // public static final String GAME_STATUS_DELAY_SEND_ROUTING_KEY = "gameStatusDelaySendRoutingKey";
@Bean @Bean
public Queue queue_game (){ public Queue queue_game (){
@ -34,34 +34,34 @@ public class RabbitMQConfig {
return new Queue(TALL_MESSAGE_2); return new Queue(TALL_MESSAGE_2);
} }
/** // /**
* 延时发送队列 // * 延时发送队列
* @return // * @return
*/ // */
@Bean // @Bean
public Queue delayQueue(){ // public Queue delayQueue(){
// return QueueBuilder.durable(GAME_STATUS_DELAY_SEND_QUEUE).build(); //// return QueueBuilder.durable(GAME_STATUS_DELAY_SEND_QUEUE).build();
return new Queue(GAME_STATUS_DELAY_SEND_QUEUE,true); // return new Queue(GAME_STATUS_DELAY_SEND_QUEUE,true);
} // }
/** // /**
* 延时交换机 // * 延时交换机
* @return // * @return
*/ // */
@Bean // @Bean
public CustomExchange delayExchange(){ // public CustomExchange delayExchange(){
Map<String, Object> args = new HashMap<>(); // Map<String, Object> args = new HashMap<>();
args.put("x-delayed-type", "direct"); // args.put("x-delayed-type", "direct");
return new CustomExchange(GAME_STATUS_DELAY_SEND_EXCHANGE, "x-delayed-message", true, false, args); // return new CustomExchange(GAME_STATUS_DELAY_SEND_EXCHANGE, "x-delayed-message", true, false, args);
} // }
/** // /**
* 绑定 // * 绑定
*/ // */
@Bean // @Bean
Binding queueBinding(Queue delayQueue, CustomExchange customExchange) { // Binding queueBinding(Queue delayQueue, CustomExchange customExchange) {
return BindingBuilder.bind(delayQueue).to(customExchange).with(GAME_STATUS_DELAY_SEND_ROUTING_KEY).noargs(); // return BindingBuilder.bind(delayQueue).to(customExchange).with(GAME_STATUS_DELAY_SEND_ROUTING_KEY).noargs();
} // }
} }

66
util/src/main/java/com/ccsens/util/mq/DelayConsumer.java

@ -1,33 +1,33 @@
package com.ccsens.util.mq; //package com.ccsens.util.mq;
//
import com.ccsens.util.config.RabbitMQConfig; //import com.ccsens.util.config.RabbitMQConfig;
import com.rabbitmq.client.Channel; //import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitHandler; //import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener; //import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders; //import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Headers; //import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload; //import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
//
import java.io.IOException; //import java.io.IOException;
import java.util.Date; //import java.util.Date;
import java.util.Map; //import java.util.Map;
//
/** ///**
* @description: // * @description:
* @author: wuHuiJuan // * @author: wuHuiJuan
* @create: 2019/12/27 15:40 // * @create: 2019/12/27 15:40
*/ // */
@Component //@Component
public class DelayConsumer { //public class DelayConsumer {
@RabbitListener(queues = RabbitMQConfig.GAME_STATUS_DELAY_SEND_QUEUE) // @RabbitListener(queues = RabbitMQConfig.GAME_STATUS_DELAY_SEND_QUEUE)
@RabbitHandler // @RabbitHandler
public void receive(@Payload Object msg, @Headers Map<String, Object> headers, Channel channel ) throws IOException { // public void receive(@Payload Object msg, @Headers Map<String, Object> headers, Channel channel ) throws IOException {
System.out.println("接收到的消息:"+msg +"||" + new Date()); // System.out.println("接收到的消息:"+msg +"||" + new Date());
//
//ACK 手工签收,通知rabbitMQ,消费端消费成功 // //ACK 手工签收,通知rabbitMQ,消费端消费成功
Long deliveryTag = (Long)headers.get(AmqpHeaders.DELIVERY_TAG); // Long deliveryTag = (Long)headers.get(AmqpHeaders.DELIVERY_TAG);
channel.basicAck(deliveryTag,false); // channel.basicAck(deliveryTag,false);
} // }
//
} //}

30
util/src/main/java/com/ccsens/util/mq/DelayProducer.java

@ -36,19 +36,19 @@ public class DelayProducer {
}; };
/** // /**
* 通过延迟消息插件发动延迟消息 // * 通过延迟消息插件发动延迟消息
* @param msg // * @param msg
* @param expiration // * @param expiration
*/ // */
public void sendDelayMessage(Object msg, Long expiration){ // public void sendDelayMessage(Object msg, Long expiration){
//
//绑定异步监听回调函数 // //绑定异步监听回调函数
rabbitTemplate.setConfirmCallback(confirmCallback); // rabbitTemplate.setConfirmCallback(confirmCallback);
//
rabbitTemplate.convertAndSend(RabbitMQConfig.GAME_STATUS_DELAY_SEND_EXCHANGE,RabbitMQConfig.GAME_STATUS_DELAY_SEND_ROUTING_KEY, msg,(message)->{ // rabbitTemplate.convertAndSend(RabbitMQConfig.GAME_STATUS_DELAY_SEND_EXCHANGE,RabbitMQConfig.GAME_STATUS_DELAY_SEND_ROUTING_KEY, msg,(message)->{
message.getMessageProperties().setHeader("x-delay", expiration);//设置延迟时间 // message.getMessageProperties().setHeader("x-delay", expiration);//设置延迟时间
return message; // return message;
}, new CorrelationData("123")); // }, new CorrelationData("123"));
} // }
} }

Loading…
Cancel
Save