Browse Source

Merge branch 'master' of gitee.com:ccsens_s/ccsenscloud

master
zhangye 6 years ago
parent
commit
c9ba865262
  1. 5
      cloudutil/pom.xml
  2. 14
      cloudutil/src/main/java/com/ccsens/cloudutil/annotation/Login.java
  3. 2
      cloudutil/src/main/java/com/ccsens/cloudutil/annotation/MustLogin.java
  4. 31
      cloudutil/src/main/java/com/ccsens/cloudutil/aspect/MustLoginAspect.java
  5. 1
      game/src/main/java/com/ccsens/game/api/ScreenController.java
  6. 18
      game/src/main/java/com/ccsens/game/bean/dto/ClientDto.java
  7. 18
      game/src/main/java/com/ccsens/game/bean/vo/ClientVo.java
  8. 9
      game/src/main/java/com/ccsens/game/service/ClientService.java
  9. 11
      game/src/main/java/com/ccsens/game/service/IClientService.java
  10. 6
      ht/pom.xml
  11. 5
      ht/src/main/java/com/ccsens/ht/api/DoctorController.java
  12. 6
      ht/src/main/java/com/ccsens/ht/api/FileController.java
  13. 4
      ht/src/main/java/com/ccsens/ht/api/PatientController.java
  14. 54
      ht/src/main/java/com/ccsens/ht/api/PatientReportController.java
  15. 4
      ht/src/main/java/com/ccsens/ht/api/PositionController.java
  16. 4
      ht/src/main/java/com/ccsens/ht/api/QuestionController.java
  17. 3
      ht/src/main/java/com/ccsens/ht/aspect/DoctorAuditAspect.java
  18. 11
      ht/src/main/java/com/ccsens/ht/bean/po/HtPatientReport.java
  19. 70
      ht/src/main/java/com/ccsens/ht/bean/po/HtPatientReportExample.java
  20. 127
      ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java
  21. 18
      ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java
  22. 6
      ht/src/main/java/com/ccsens/ht/intercept/MybatisInterceptor.java
  23. 18
      ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java
  24. 76
      ht/src/main/java/com/ccsens/ht/service/PatientReportService.java
  25. 2
      ht/src/main/java/com/ccsens/ht/service/QuestionService.java
  26. 4
      ht/src/main/resources/mapper_dao/HtQuestionOptionDao.xml
  27. 27
      ht/src/main/resources/mapper_raw/HtPatientReportMapper.xml
  28. 12
      util/pom.xml
  29. 47
      util/src/main/java/com/ccsens/util/PdfUtil.java
  30. 44
      util/src/main/java/com/ccsens/util/QrCodeUtil.java
  31. 2
      util/src/main/java/com/ccsens/util/bean/dto/QueryDto.java
  32. 6
      util/src/test/java/com/ccsens/util/KeyTest.java
  33. 123
      util/src/test/java/com/ccsens/util/PdfUtilTest.java

5
cloudutil/pom.xml

@ -44,6 +44,11 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>
</dependencies>
</project>

14
cloudutil/src/main/java/com/ccsens/cloudutil/annotation/Login.java

@ -0,0 +1,14 @@
package com.ccsens.cloudutil.annotation;
import java.lang.annotation.*;
/**
* 有token,则根据token获取userId, 无则不获取
* @author: wuHuiJuan
* @create: 2019/12/26 16:39
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Login {
}

2
ht/src/main/java/com/ccsens/ht/annotation/MustLogin.java → cloudutil/src/main/java/com/ccsens/cloudutil/annotation/MustLogin.java

@ -1,4 +1,4 @@
package com.ccsens.ht.annotation;
package com.ccsens.cloudutil.annotation;
import java.lang.annotation.*;

31
ht/src/main/java/com/ccsens/ht/aspect/MustLoginAspect.java → cloudutil/src/main/java/com/ccsens/cloudutil/aspect/MustLoginAspect.java

@ -1,18 +1,20 @@
package com.ccsens.ht.aspect;
package com.ccsens.cloudutil.aspect;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.cloudutil.feign.TallFeignClient;
import com.ccsens.ht.bean.dto.QueryDto;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.WebConstant;
import com.ccsens.util.exception.BaseException;
import com.ccsens.util.bean.dto.QueryDto;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@ -20,6 +22,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
/**
* @description:
@ -34,7 +37,7 @@ public class MustLoginAspect {
@Autowired
private TallFeignClient tallFeignClient;
@Pointcut("@annotation(com.ccsens.ht.annotation.MustLogin)")
@Pointcut("@annotation(com.ccsens.cloudutil.annotation.MustLogin) || @annotation(com.ccsens.cloudutil.annotation.Login) ")
public void loginAdvice(){}
@Around("loginAdvice()")
@ -47,8 +50,28 @@ public class MustLoginAspect {
Object[] args = pjp.getArgs();
QueryDto dto = args == null || args.length < 1 ? null : (QueryDto) args[0];
//获取userId
JsonResponse response = tallFeignClient.getUserIdByToken(authHeader);
log.info("{}获取userId:{}", authHeader, response);
Signature signature = pjp.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Method targetMethod = methodSignature.getMethod();
MustLogin mustLoginAnnotation = targetMethod.getAnnotation(MustLogin.class);
if (mustLoginAnnotation == null) {
log.info("不是必须登录,有token,则添加userId,没有则不添加");
if (response.getCode().intValue() == CodeEnum.SUCCESS.getCode().intValue() && response.getData() != null) {
JSONObject json = JSONObject.parseObject(JSON.toJSONString(response.getData()));
Long userId = json.getLong("id");
if (dto != null) {
dto.setUserId(userId);
}
}
Object result = pjp.proceed();
return result;
}
//必须登录,未登录直接返回未登录相关信息
if (response.getCode().intValue() != CodeEnum.SUCCESS.getCode().intValue()) {
return response;
}

1
game/src/main/java/com/ccsens/game/api/ScreenController.java

@ -36,6 +36,7 @@ public class ScreenController {
@ApiOperation(value = "获取游戏基本信息", notes = "")
@ApiImplicitParams({
})
@RequestMapping(value = "information", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<ScreenVo.GameInfoVo> getGameInfo(HttpServletRequest request,

18
game/src/main/java/com/ccsens/game/bean/dto/ClientDto.java

@ -0,0 +1,18 @@
package com.ccsens.game.bean.dto;
import io.swagger.annotations.ApiModel;
import lombok.Data;
/**
* @description:
* @author: wuHuiJuan
* @create: 2019/12/26 15:03
*/
public class ClientDto {
@Data
@ApiModel("ClientDtoJoin")
public static class Join{
}
}

18
game/src/main/java/com/ccsens/game/bean/vo/ClientVo.java

@ -0,0 +1,18 @@
package com.ccsens.game.bean.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @description:
* @author: wuHuiJuan
* @create: 2019/12/26 15:01
*/
public class ClientVo {
@Data
@ApiModel("ClientVoJoin")
public static class Join{
}
}

9
game/src/main/java/com/ccsens/game/service/ClientService.java

@ -0,0 +1,9 @@
package com.ccsens.game.service;
/**
* @description:
* @author: wuHuiJuan
* @create: 2019/12/26 15:01
*/
public class ClientService implements IClientService {
}

11
game/src/main/java/com/ccsens/game/service/IClientService.java

@ -0,0 +1,11 @@
package com.ccsens.game.service;
/**
* @description:
* @author: wuHuiJuan
* @create: 2019/12/26 15:00
*/
public interface IClientService {
}

6
ht/pom.xml

@ -24,11 +24,7 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>
</dependencies>
<build>

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

@ -1,10 +1,10 @@
package com.ccsens.ht.api;
import com.ccsens.ht.annotation.MustLogin;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.ht.annotation.DoctorAudit;
import com.ccsens.ht.bean.dto.DoctorDto;
import com.ccsens.ht.bean.dto.QueryDto;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.ht.bean.vo.DoctorVo;
import com.ccsens.ht.service.IDoctorService;
import com.ccsens.util.CodeEnum;
@ -13,7 +13,6 @@ import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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;

6
ht/src/main/java/com/ccsens/ht/api/FileController.java

@ -1,12 +1,10 @@
package com.ccsens.ht.api;
import cn.hutool.core.date.DateUtil;
import com.ccsens.ht.annotation.MustLogin;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.ht.bean.dto.FileDto;
import com.ccsens.ht.bean.dto.QueryDto;
import com.ccsens.ht.bean.dto.QuestionDto;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.ht.bean.vo.FileVo;
import com.ccsens.ht.bean.vo.QuestionVo;
import com.ccsens.util.Base64FileUtil;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.PropUtil;

4
ht/src/main/java/com/ccsens/ht/api/PatientController.java

@ -2,9 +2,9 @@ package com.ccsens.ht.api;
import cn.hutool.core.util.IdcardUtil;
import com.ccsens.ht.annotation.DoctorAudit;
import com.ccsens.ht.annotation.MustLogin;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.ht.bean.dto.PatientDto;
import com.ccsens.ht.bean.dto.QueryDto;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.ht.bean.po.HtPatient;
import com.ccsens.ht.bean.vo.PatientVo;
import com.ccsens.ht.service.IPatientService;

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

@ -2,15 +2,13 @@ package com.ccsens.ht.api;
import com.ccsens.ht.annotation.DoctorAudit;
import com.ccsens.ht.annotation.MustLogin;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.ht.bean.dto.PatientReportDto;
import com.ccsens.ht.bean.dto.QueryDto;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.ht.bean.vo.PatientReportVo;
import com.ccsens.ht.service.IPatientReportService;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.PdfUtil;
import com.ccsens.util.PropUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
@ -21,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.io.IOException;
/**
* @program: ptpro
@ -112,20 +111,35 @@ public class PatientReportController {
return JsonResponse.newInstance().ok(authority);
}
// @ApiOperation(value = "导出报告单",notes = "导出报告单")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "json", value = "导出报告单", required = true)
// })
// @RequestMapping(value="/exportReport", method = RequestMethod.POST)
// public JsonResponse<PatientReportVo.Export> exportReport(@RequestBody @ApiParam @Valid QueryDto<PatientReportDto.QueryDetail> param){
// //查询报告单信息
// log.info("查询报告单详情:{}", param);
// PatientReportVo.ReprotDetail detail = patientReportService.queryReportDetail(param.getParam(), param.getUserId());
// if (detail == null) {
// return JsonResponse.newInstance().ok(CodeEnum.);
// }
// PdfUtil.credatePdf(PropUtil.path, detail.getPatient().getName(), detail.getPatient().toPdfRow(), )
// log.info("查询报告单详情结果:{}", detail);
// return JsonResponse.newInstance().ok(detail);
// }
@ApiOperation(value = "导出报告单",notes = "导出报告单")
@ApiImplicitParams({
@ApiImplicitParam(name = "json", value = "导出报告单", required = true)
})
@RequestMapping(value="/exportReport", method = RequestMethod.POST)
public JsonResponse<PatientReportVo.Export> exportReport(@RequestBody @ApiParam @Valid QueryDto<PatientReportDto.QueryDetail> param){
//查询报告单信息
log.info("查询报告单详情:{}", param);
String path = patientReportService.exportReport(param.getParam(), param.getUserId());
log.info("文件路径:{}", path);
PatientReportVo.Export export = new PatientReportVo.Export();
export.setPath(path);
return JsonResponse.newInstance().ok(export);
}
@ApiOperation(value = "分享报告单",notes = "分享报告单")
@ApiImplicitParams({
@ApiImplicitParam(name = "json", value = "分享报告单", required = true)
})
@RequestMapping(value="/shareReport", method = RequestMethod.POST)
public JsonResponse<PatientReportVo.Export> shareReport(@RequestBody @ApiParam @Valid QueryDto<PatientReportDto.QueryDetail> param) throws IOException {
//查询报告单信息
log.info("查询报告单详情:{}", param);
String path = patientReportService.generateQRCode(param.getParam(), param.getUserId());
log.info("文件路径:{}", path);
PatientReportVo.Export export = new PatientReportVo.Export();
export.setPath(path);
return JsonResponse.newInstance().ok(export);
}
}

4
ht/src/main/java/com/ccsens/ht/api/PositionController.java

@ -1,8 +1,8 @@
package com.ccsens.ht.api;
import com.ccsens.ht.annotation.MustLogin;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.ht.bean.dto.PositionDto;
import com.ccsens.ht.bean.dto.QueryDto;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.ht.bean.vo.PositionVo;
import com.ccsens.ht.service.IPositionService;
import com.ccsens.util.JsonResponse;

4
ht/src/main/java/com/ccsens/ht/api/QuestionController.java

@ -2,8 +2,8 @@ package com.ccsens.ht.api;
import com.ccsens.ht.annotation.DoctorAudit;
import com.ccsens.ht.annotation.MustLogin;
import com.ccsens.ht.bean.dto.QueryDto;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.ht.bean.dto.QuestionDto;
import com.ccsens.ht.bean.vo.QuestionVo;
import com.ccsens.ht.service.IQuestionService;

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

@ -1,13 +1,12 @@
package com.ccsens.ht.aspect;
import com.ccsens.ht.bean.dto.QueryDto;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.ht.bean.po.HtDoctor;
import com.ccsens.ht.bean.po.HtDoctorExample;
import com.ccsens.ht.persist.mapper.HtDoctorMapper;
import com.ccsens.ht.uitl.Constant;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.exception.BaseException;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;

11
ht/src/main/java/com/ccsens/ht/bean/po/HtPatientReport.java

@ -36,6 +36,8 @@ public class HtPatientReport implements Serializable {
private String url;
private String qrCodeUrl;
private String remark;
private Date createTime;
@ -174,6 +176,14 @@ public class HtPatientReport implements Serializable {
this.url = url == null ? null : url.trim();
}
public String getQrCodeUrl() {
return qrCodeUrl;
}
public void setQrCodeUrl(String qrCodeUrl) {
this.qrCodeUrl = qrCodeUrl == null ? null : qrCodeUrl.trim();
}
public String getRemark() {
return remark;
}
@ -228,6 +238,7 @@ public class HtPatientReport implements Serializable {
sb.append(", checkTime=").append(checkTime);
sb.append(", evaluationCode=").append(evaluationCode);
sb.append(", url=").append(url);
sb.append(", qrCodeUrl=").append(qrCodeUrl);
sb.append(", remark=").append(remark);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);

70
ht/src/main/java/com/ccsens/ht/bean/po/HtPatientReportExample.java

@ -1155,6 +1155,76 @@ public class HtPatientReportExample {
return (Criteria) this;
}
public Criteria andQrCodeUrlIsNull() {
addCriterion("qr_code_url is null");
return (Criteria) this;
}
public Criteria andQrCodeUrlIsNotNull() {
addCriterion("qr_code_url is not null");
return (Criteria) this;
}
public Criteria andQrCodeUrlEqualTo(String value) {
addCriterion("qr_code_url =", value, "qrCodeUrl");
return (Criteria) this;
}
public Criteria andQrCodeUrlNotEqualTo(String value) {
addCriterion("qr_code_url <>", value, "qrCodeUrl");
return (Criteria) this;
}
public Criteria andQrCodeUrlGreaterThan(String value) {
addCriterion("qr_code_url >", value, "qrCodeUrl");
return (Criteria) this;
}
public Criteria andQrCodeUrlGreaterThanOrEqualTo(String value) {
addCriterion("qr_code_url >=", value, "qrCodeUrl");
return (Criteria) this;
}
public Criteria andQrCodeUrlLessThan(String value) {
addCriterion("qr_code_url <", value, "qrCodeUrl");
return (Criteria) this;
}
public Criteria andQrCodeUrlLessThanOrEqualTo(String value) {
addCriterion("qr_code_url <=", value, "qrCodeUrl");
return (Criteria) this;
}
public Criteria andQrCodeUrlLike(String value) {
addCriterion("qr_code_url like", value, "qrCodeUrl");
return (Criteria) this;
}
public Criteria andQrCodeUrlNotLike(String value) {
addCriterion("qr_code_url not like", value, "qrCodeUrl");
return (Criteria) this;
}
public Criteria andQrCodeUrlIn(List<String> values) {
addCriterion("qr_code_url in", values, "qrCodeUrl");
return (Criteria) this;
}
public Criteria andQrCodeUrlNotIn(List<String> values) {
addCriterion("qr_code_url not in", values, "qrCodeUrl");
return (Criteria) this;
}
public Criteria andQrCodeUrlBetween(String value1, String value2) {
addCriterion("qr_code_url between", value1, value2, "qrCodeUrl");
return (Criteria) this;
}
public Criteria andQrCodeUrlNotBetween(String value1, String value2) {
addCriterion("qr_code_url not between", value1, value2, "qrCodeUrl");
return (Criteria) this;
}
public Criteria andRemarkIsNull() {
addCriterion("remark is null");
return (Criteria) this;

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

@ -7,7 +7,6 @@ import com.ccsens.util.PdfUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
@ -129,12 +128,17 @@ public class PatientReportVo {
"病案号:" + this.hospitalNumber)
);
//第四栏
Date date = new Date();
date.setTime(this.reportTime);
Date date = null;
if (this.reportTime > 0) {
date = new Date();
date.setTime(this.reportTime);
}
rows.add(
fillRow(
"临床诊断:" + this.clinicalDiagnosis,
"检查日期:" + DateUtil.format(date, "yyyy-MM-dd"))
"",
"检查日期:" + (date == null ? "" : DateUtil.format(date, "yyyy-MM-dd")))
);
return rows;
@ -181,31 +185,39 @@ public class PatientReportVo {
}
public List<PdfUtil.Row> toRow() {
int colNum = 8;
int headNum = 2;
List<PdfUtil.Row> rows = new ArrayList<>();
if (CollectionUtil.isEmpty(subReport)) {
PdfUtil.Row row = new PdfUtil.Row();
PdfUtil.Cell cell1 = new PdfUtil.Cell();
cell1.setContent(this.name + (StrUtil.isBlank(this.remark) ? "" : "("+this.remark+")"));
cell1.setContent(this.code + (StrUtil.isBlank(this.remark) ? "" : "("+this.remark+")"));
cell1.setColSpan(headNum);
PdfUtil.Cell cell2 = new PdfUtil.Cell();
cell2.setContent(this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : ""));
cell2.setColSpan(colNum - headNum);
row.addCell(cell1);
row.addCell(cell2);
rows.add(row);
return rows;
} else {
String mmse = "MMSE";
String npi = "NPI";
if (mmse.equalsIgnoreCase(this.code) || npi.equalsIgnoreCase(this.code)) {
PdfUtil.Row row1 = new PdfUtil.Row();
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setContent(this.name + (StrUtil.isBlank(this.remark) ? "" : "("+this.remark+")"));
cell.setContent(this.code + (StrUtil.isBlank(this.remark) ? "" : "("+this.remark+")"));
cell.setRowSpan(2);
cell.setColSpan(npi.equalsIgnoreCase(this.code) ? headNum : 1);
row1.addCell(cell);
//被合并cell
PdfUtil.Row row2 = new PdfUtil.Row();
// fillBlankCell(row2);
//子测评项
this.subReport.forEach(reportScore -> {
fillRow(row1,row2, reportScore.getName(), reportScore.score == null ? "" : reportScore.score + (reportScore.totalScore > 0 ? "/" + reportScore.totalScore : ""));
fillRow(row1,row2, reportScore.getName(), reportScore.score == null ? "" : reportScore.score + (reportScore.totalScore > 0 ? "/" + reportScore.totalScore : ""), npi.equalsIgnoreCase(this.code) ? new int[]{3,3} : null);
});
// 总分
if (mmse.equalsIgnoreCase(this.code)) {
fillRow(row1,row2, "总分", this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : ""));
}
@ -213,75 +225,110 @@ public class PatientReportVo {
rows.add(row2);
} else {
//moca
int firstIndex = 6;
int firstIndex = 5;
PdfUtil.Row row1 = new PdfUtil.Row();
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setContent(this.name + (StrUtil.isBlank(this.remark) ? "" : "("+this.remark+")"));
cell.setRowSpan(5);
row1.addCell(cell);
PdfUtil.Row row2 = new PdfUtil.Row();
// fillBlankCell(row2);
for (int i = 0; i < firstIndex; i++) {
ReportScore reportScore = this.subReport.get(i);
String jy = "JY";
if (jy.equalsIgnoreCase(reportScore.getCode())) {
fillRow(row1, row2, reportScore.getName(), "");
fillRow(row1, row2, reportScore.getName(), "", i == 0 ? new int[]{2,2}: null);
} else {
fillRow(row1, row2, reportScore.getName(), reportScore.score == null ? "" : reportScore.score + (reportScore.totalScore > 0 ? "/" + reportScore.totalScore : ""));
fillRow(row1, row2, reportScore.getName(), reportScore.score == null ? "" : reportScore.score + (reportScore.totalScore > 0 ? "/" + reportScore.totalScore : ""), i == 0 ? new int[]{2,2}: null);
}
}
PdfUtil.Cell scoreNameCell = new PdfUtil.Cell();
scoreNameCell.setContent("总分");
row1.addCell(scoreNameCell);
PdfUtil.Cell scoreCell = new PdfUtil.Cell();
scoreNameCell.setContent("总分");
row1.addCell(scoreNameCell);
for (ReportScore score: this.subReport) {
if (firstIndex == 6) {
//设置总分
PdfUtil.Cell scoreTitleCell = new PdfUtil.Cell();
scoreTitleCell.setContent("总分");
row1.addCell(scoreTitleCell);
PdfUtil.Cell scoreScoreCell = new PdfUtil.Cell();
scoreScoreCell.setContent(this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : ""));
scoreScoreCell.setRowSpan(4);
row2.addCell(scoreScoreCell);
rows.add(row1);
rows.add(row2);
//换行
row1 = new PdfUtil.Row();
row2 = new PdfUtil.Row();
}
firstIndex++;
}
scoreCell.setContent(this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : ""));
scoreCell.setRowSpan(4);
row2.addCell(scoreCell);
// fillBlankCell(row1, row2);
rows.add(row1);
rows.add(row2);
//下一行
PdfUtil.Row row3 = new PdfUtil.Row();
PdfUtil.Row row4 = new PdfUtil.Row();
PdfUtil.Row row5 = new PdfUtil.Row();
// fillBlankCell(row3, row4, row5);
//延迟回忆特殊处理
String ychy = "YCHY";
for (int i = firstIndex; i < this.subReport.size(); i++) {
ReportScore reportScore = this.subReport.get(i);
//设置名字
PdfUtil.Cell scoreTitleCell = new PdfUtil.Cell();
scoreTitleCell.setContent(reportScore.getName());
scoreTitleCell.setColSpan(ychy.equalsIgnoreCase(reportScore.getCode()) ? 2 : 1);
row3.addCell(scoreTitleCell);
//设置子类
if (ychy.equalsIgnoreCase(reportScore.getCode())) {
for (int j = 0; j < reportScore.subReport.size(); j++) {
ReportScore subScore = reportScore.getSubReport().get(j);
PdfUtil.Cell subCell = new PdfUtil.Cell();
subCell.setContent(subScore.name + (subScore.getScore() == null ? " " : subScore.getScore()) + subScore.getRemark());
if (j == 0 ) {
row4.addCell(subCell);
} else {
row5.addCell(subCell);
}
}
}
PdfUtil.Cell scoreScoreCell = new PdfUtil.Cell();
scoreScoreCell.setContent(reportScore.score == null ? "" : reportScore.score + (reportScore.totalScore > 0 ? "/" + reportScore.totalScore : ""));
scoreScoreCell.setRowSpan(2);
row4.addCell(scoreScoreCell);
// fillBlankCell(row5);
}
// fillBlankCell(row3);
// fillBlankCell(row3, row4, row5);
rows.add(row3);
rows.add(row4);
rows.add(row5);
}
}
PdfUtil.Row row = new PdfUtil.Row();
PdfUtil.Row descRow = new PdfUtil.Row();
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setColSpan(colNum);
cell.setContent(this.description);
descRow.addCell(cell);
rows.add(descRow);
return rows;
}
private void fillRow(PdfUtil.Row row1, PdfUtil.Row row2, String name, String score){
/**
* 添加一个空格
* @param rows
*/
private void fillBlankCell(PdfUtil.Row... rows) {
for (PdfUtil.Row row: rows) {
PdfUtil.Cell cell = new PdfUtil.Cell();
row.addCell(cell);
}
}
private void fillRow(PdfUtil.Row row1, PdfUtil.Row row2, String name, String score, int... colspan){
//名称
PdfUtil.Cell cell1 = new PdfUtil.Cell();
cell1.setContent(name);
cell1.setColSpan(colspan == null || colspan.length == 0 ? 1 : colspan[0]);
row1.addCell(cell1);
//分数
PdfUtil.Cell cell2 = new PdfUtil.Cell();
cell2.setContent(score);
cell2.setColSpan(colspan == null || colspan.length <= 1 ? 1 : colspan[1]);
row2.addCell(cell2);
}
}

18
ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java

@ -85,12 +85,26 @@ public class QuestionVo {
@ApiModelProperty("试题")
private Question question;
@ApiModelProperty("选项")
private List<Option> options;
private List<OptionJson> options = new ArrayList<>();
public static QuestionOption toQuestionOption(HtQuestion question, List<Option> options) {
QuestionOption vo = new QuestionOption();
vo.setQuestion(Question.toQuestionVo(question));
vo.setOptions(options);
if (CollectionUtil.isNotEmpty(options)) {
//方便后续把相同属性的选项放到一个对象的List中
Map<String, OptionJson> map = new HashMap<>();
options.forEach(option -> {
if (map.get(option.getName()) == null) {
OptionJson json = new OptionJson();
json.setName(option.getName());
map.put(json.getName(), json);
//相同属性的选项放在同一个optionJson里
vo.options.add(json);
}
OptionJson json = map.get(option.getName());
json.addOption(option);
});
}
return vo;
}
}

6
ht/src/main/java/com/ccsens/ht/intercept/MybatisInterceptor.java

@ -36,11 +36,15 @@ public class MybatisInterceptor implements Interceptor {
String selectByExample = "selectByExample";
String countByExample = "countByExample";
String countByExample2 = "selectByExample_COUNT";
String selectByPrimaryKey = "selectByPrimaryKey";
Object[] args = invocation.getArgs();
MappedStatement statement = (MappedStatement) args[0];
if (statement.getId().endsWith(selectByExample)) {
if (statement.getId().endsWith(selectByExample)
|| statement.getId().endsWith(countByExample)
|| statement.getId().endsWith(countByExample2)) {
//XXXExample
Object example = args[1];

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

@ -6,6 +6,8 @@ import com.ccsens.util.CodeEnum;
import com.ccsens.util.JsonResponse;
import com.github.pagehelper.PageInfo;
import java.io.IOException;
public interface IPatientReportService {
@ -56,4 +58,20 @@ public interface IPatientReportService {
*@date: 2019/11/19 15:50
*/
PatientReportVo.Authority queryReportAuthority(PatientReportDto.Authority authority, Long userId);
/**
* 导出报告单
* @param queryDetail
* @param userId
* @return
*/
String exportReport(PatientReportDto.QueryDetail queryDetail, Long userId);
/**
* 生成二维码
* @param queryDetail
* @param userId
* @return
*/
String generateQRCode(PatientReportDto.QueryDetail queryDetail, Long userId) throws IOException;
}

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

@ -14,8 +14,7 @@ import com.ccsens.ht.persist.mapper.HtPatientFollowUpMapper;
import com.ccsens.ht.persist.mapper.HtPatientMapper;
import com.ccsens.ht.persist.mapper.HtPatientReportRecordMapper;
import com.ccsens.ht.uitl.Constant;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.*;
import com.ccsens.util.exception.BaseException;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@ -27,6 +26,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
@ -346,4 +346,76 @@ public class PatientReportService implements IPatientReportService {
return sum.get();
}
@Override
public String exportReport(PatientReportDto.QueryDetail queryDetail, Long userId) {
log.info("导出报告单:{}, 操作用户:{}", queryDetail, userId);
//查看是否已生成对应文件路径
HtPatientReport report = htPatientReportDao.selectByPrimaryKey(queryDetail.getId());
if (report == null) {
throw new BaseException(CodeEnum.REPORT_NOT_FOUND);
}
if (StrUtil.isNotBlank(report.getUrl())) {
return report.getUrl();
}
PatientReportVo.ReprotDetail detail = queryReportDetail(queryDetail, userId);
if (detail == null) {
throw new BaseException(CodeEnum.REPORT_NOT_FOUND);
}
List<PdfUtil.Row> content = new ArrayList<>();
detail.getScores().forEach(reportScore -> {
content.addAll(reportScore.toRow());
});
PdfUtil.Row row = new PdfUtil.Row();
addCell(row,"初步印象",2,2);
addCell(row, detail.getPatient().getInitialImpression(), 6, 2);
content.add(row);
PdfUtil.Row row2 = new PdfUtil.Row();
addCell(row2,"测评员:",4,1, 0);
addCell(row2,"报告日期:",4,1, 0);
content.add(row2);
String path = PropUtil.imgDomain + "/" + PdfUtil.credatePdf(PropUtil.path, detail.getPatient().getName(), detail.getPatient().toPdfRow(), content);
report.setUrl(path);
htPatientReportDao.updateByPrimaryKeySelective(report);
log.info("生成文件路径:{}", path);
return path;
}
private void addCell(PdfUtil.Row row, String content, int colSpan, int rowSpan, int... border) {
PdfUtil.Cell cell1 = new PdfUtil.Cell();
cell1.setContent(content);
cell1.setColSpan(colSpan);
cell1.setRowSpan(rowSpan);
cell1.setBorder(border == null || border.length == 0 ? 1 : border[0]);
row.addCell(cell1);
}
@Override
public String generateQRCode(PatientReportDto.QueryDetail queryDetail, Long userId) throws IOException {
log.info("报告单分享:{},用户ID:{}", queryDetail, userId);
HtPatientReport report = htPatientReportDao.selectByPrimaryKey(queryDetail.getId());
if (report == null) {
throw new BaseException(CodeEnum.REPORT_NOT_FOUND);
}
//有二维码直接返回
if (StrUtil.isNotBlank(report.getQrCodeUrl())) {
log.info("直接返回二维码路径:{}", report.getQrCodeUrl());
return report.getQrCodeUrl();
}
String pdfUrl = report.getUrl();
if (StrUtil.isBlank(pdfUrl)) {
log.info("尚未生成pdf文件,生成文件");
pdfUrl = exportReport(queryDetail, userId);
}
String qrCodePath = QrCodeUtil.urlToQRCode(pdfUrl, PropUtil.path);
String qrCodeUrl = PropUtil.imgDomain + "/" + qrCodePath;
log.info("生成的二维码路径:{}", qrCodeUrl);
HtPatientReport newReport = htPatientReportDao.selectByPrimaryKey(queryDetail.getId());
newReport.setQrCodeUrl(qrCodeUrl);
htPatientReportDao.updateByPrimaryKeySelective(newReport);
log.info("修改报告单二维码路径");
return qrCodeUrl;
}
}

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

@ -109,7 +109,7 @@ public class QuestionService implements IQuestionService {
if (CollectionUtil.isNotEmpty(relationQuestions)) {
relationQuestions.forEach(relation -> {
//试题选项
List<QuestionVo.Option> options = htQuestionOptionDao.queryOption(question.getId(), query.getPatientReportId());
List<QuestionVo.Option> options = htQuestionOptionDao.queryOption(relation.getId(), query.getPatientReportId());
QuestionVo.QuestionOption questionOption = QuestionVo.QuestionOption.toQuestionOption(relation, options);
vos.add(questionOption);
});

4
ht/src/main/resources/mapper_dao/HtQuestionOptionDao.xml

@ -41,8 +41,8 @@
<select id="queryOption" resultMap="OptionMap">
select t1.id, t1.type, t1.question_id, t1.name, t1.score, t1.display, if (t2.id is null, 0, 1) as choose , if(t2.type = 3, null, t2.answer) as answer
from t_ht_question_option t1 left join t_ht_patient_score t2 on t1.id = t2.option_id and (t2.id is null or t2.patient_report_id = #{patientReportId,jdbcType=BIGINT})
select t1.id, t1.type, t1.question_id, t1.name, t1.score, t1.display, case when t1.type = 'hidden' then 0 when t2.id is null then 0 else 1 end as choose , if(t2.type = 3, null, t2.answer) as answer
from t_ht_question_option t1 left join t_ht_patient_score t2 on t1.id = t2.option_id and (t2.id is null or (t2.patient_report_id = #{patientReportId,jdbcType=BIGINT} and t2.is_del = 0))
where t1.question_id = #{questionId,jdbcType=BIGINT}
and t1.is_del = 0
group by t1.id

27
ht/src/main/resources/mapper_raw/HtPatientReportMapper.xml

@ -18,6 +18,7 @@
<result column="check_time" jdbcType="BIGINT" property="checkTime" />
<result column="evaluation_code" jdbcType="VARCHAR" property="evaluationCode" />
<result column="url" jdbcType="VARCHAR" property="url" />
<result column="qr_code_url" jdbcType="VARCHAR" property="qrCodeUrl" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
@ -84,7 +85,7 @@
<sql id="Base_Column_List">
id, name, patient_id, patient_idcard, patient_age, doctor_id, serial_number, initial_impression,
clinical_diagnosis, pasi, department, bed_number, report_time, check_time, evaluation_code,
url, remark, create_time, update_time, is_del
url, qr_code_url, remark, create_time, update_time, is_del
</sql>
<select id="selectByExample" parameterType="com.ccsens.ht.bean.po.HtPatientReportExample" resultMap="BaseResultMap">
select
@ -122,15 +123,17 @@
serial_number, initial_impression, clinical_diagnosis,
pasi, department, bed_number,
report_time, check_time, evaluation_code,
url, remark, create_time,
update_time, is_del)
url, qr_code_url, remark,
create_time, update_time, is_del
)
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{patientId,jdbcType=BIGINT},
#{patientIdcard,jdbcType=VARCHAR}, #{patientAge,jdbcType=TINYINT}, #{doctorId,jdbcType=BIGINT},
#{serialNumber,jdbcType=VARCHAR}, #{initialImpression,jdbcType=VARCHAR}, #{clinicalDiagnosis,jdbcType=VARCHAR},
#{pasi,jdbcType=TINYINT}, #{department,jdbcType=VARCHAR}, #{bedNumber,jdbcType=VARCHAR},
#{reportTime,jdbcType=BIGINT}, #{checkTime,jdbcType=BIGINT}, #{evaluationCode,jdbcType=VARCHAR},
#{url,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{isDel,jdbcType=TINYINT})
#{url,jdbcType=VARCHAR}, #{qrCodeUrl,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{isDel,jdbcType=TINYINT}
)
</insert>
<insert id="insertSelective" parameterType="com.ccsens.ht.bean.po.HtPatientReport">
insert into t_ht_patient_report
@ -183,6 +186,9 @@
<if test="url != null">
url,
</if>
<if test="qrCodeUrl != null">
qr_code_url,
</if>
<if test="remark != null">
remark,
</if>
@ -245,6 +251,9 @@
<if test="url != null">
#{url,jdbcType=VARCHAR},
</if>
<if test="qrCodeUrl != null">
#{qrCodeUrl,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
@ -316,6 +325,9 @@
<if test="record.url != null">
url = #{record.url,jdbcType=VARCHAR},
</if>
<if test="record.qrCodeUrl != null">
qr_code_url = #{record.qrCodeUrl,jdbcType=VARCHAR},
</if>
<if test="record.remark != null">
remark = #{record.remark,jdbcType=VARCHAR},
</if>
@ -351,6 +363,7 @@
check_time = #{record.checkTime,jdbcType=BIGINT},
evaluation_code = #{record.evaluationCode,jdbcType=VARCHAR},
url = #{record.url,jdbcType=VARCHAR},
qr_code_url = #{record.qrCodeUrl,jdbcType=VARCHAR},
remark = #{record.remark,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
@ -407,6 +420,9 @@
<if test="url != null">
url = #{url,jdbcType=VARCHAR},
</if>
<if test="qrCodeUrl != null">
qr_code_url = #{qrCodeUrl,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
@ -439,6 +455,7 @@
check_time = #{checkTime,jdbcType=BIGINT},
evaluation_code = #{evaluationCode,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR},
qr_code_url = #{qrCodeUrl,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},

12
util/pom.xml

@ -15,24 +15,30 @@
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.xhtmlrenderer/flying-saucer-pdf -->
<!--PDF生成-->
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.1.19</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.itextpdf/itext-asian -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>5.2.0</version>
</dependency>
<!--生成二维码-->
<dependency>
<groupId>net.glxn.qrgen</groupId>
<artifactId>javase</artifactId>
<version>2.0</version>
</dependency>
</dependencies>

47
util/src/main/java/com/ccsens/util/PdfUtil.java

@ -34,7 +34,7 @@ public class PdfUtil {
* @return
*/
public static String credatePdf(String parentPath, String title, List<Row> intros, List<Row> content) {
String fileName = "pdf/" + DateUtil.today() + "/" + title + System.currentTimeMillis() + ".pdf";
String fileName = "pdf/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".pdf";
log.info("pdf文件名:{}", fileName );
File file = new File(parentPath, fileName);
if (!file.getParentFile().exists()) {
@ -61,9 +61,8 @@ public class PdfUtil {
//设置介绍内容
if (CollectionUtil.isNotEmpty(intros)) {
fillRow(intros, document);
fillBlankRow(document, titleChinese);
}
if (CollectionUtil.isEmpty(content)) {
if (CollectionUtil.isNotEmpty(content)) {
fillRow(content, document);
}
@ -106,30 +105,36 @@ public class PdfUtil {
*/
private static void fillRow(List<Row> rows, Document document) throws IOException, DocumentException {
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
rows.forEach(row -> {
PdfPTable table = new PdfPTable(row.getCells().size());
table.setWidthPercentage(100);
table.setSpacingBefore(10);
int size = 0;
for (Cell cell :rows.get(0).getCells()) {
size += cell.getColSpan();
}
PdfPTable table = new PdfPTable(size);
table.setSpacingBefore(0);
table.setWidthPercentage(100);
for (int j = 0; j < rows.size(); j++) {
Row row = rows.get(j);
table.setHorizontalAlignment(row.align);
Font font = new Font(bfChinese, row.fontSize, row.fontStyle);
row.cells.forEach(cell -> {
PdfPCell pdfpCell = new PdfPCell(new Paragraph(cell.content,font));
pdfpCell.setBorder(cell.border);
for (int i = 0; i < row.cells.size(); i++) {
Cell cell = row.cells.get(i);
PdfPCell pdfpCell = new PdfPCell(new Phrase(cell.content,font));
pdfpCell.setBorderWidthTop(j == 0 ? cell.border : 0);
pdfpCell.setBorderWidthLeft(cell.border);
pdfpCell.setBorderWidthRight(i == row.cells.size() - 1 ? cell.border : 0);
pdfpCell.setBorderWidthBottom(cell.border);
pdfpCell.setColspan(cell.colSpan);
pdfpCell.setRowspan(cell.rowSpan);
table.addCell(pdfpCell);
});
try {
table.setWidthPercentage(90);
table.setHorizontalAlignment(row.align);
document.add(table);
} catch (DocumentException e) {
e.printStackTrace();
}
});
}
try {
document.add(table);
} catch (DocumentException e) {
e.printStackTrace();
}
}
/**

44
util/src/main/java/com/ccsens/util/QrCodeUtil.java

@ -0,0 +1,44 @@
package com.ccsens.util;
import cn.hutool.core.date.DateUtil;
import net.glxn.qrgen.core.image.ImageType;
import net.glxn.qrgen.javase.QRCode;
import java.io.*;
/**
* 二维码工具类
* @author: wuHuiJuan
* @create: 2019/12/25 10:36
*/
public class QrCodeUtil {
/**
* 根据文件路径生成二维码
* @param url
* @param parentPath
* @return
* @throws IOException
*/
public static String urlToQRCode(String url, String parentPath) throws IOException {
String fileName = "qrCode/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".png";
ByteArrayOutputStream stream = QRCode.from(url).to(ImageType.BMP).stream();
byte[] codeByte = stream.toByteArray();
File file = new File(parentPath, fileName);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
OutputStream out = null;
try {
out = new FileOutputStream(file);
out.write(codeByte);
out.flush();
} finally {
if ( out!= null) {
out.close();
}
}
return fileName;
}
}

2
ht/src/main/java/com/ccsens/ht/bean/dto/QueryDto.java → util/src/main/java/com/ccsens/util/bean/dto/QueryDto.java

@ -1,4 +1,4 @@
package com.ccsens.ht.bean.dto;
package com.ccsens.util.bean.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

6
util/src/test/java/com/ccsens/util/KeyTest.java

@ -15,13 +15,13 @@ import org.junit.Test;
*/
public class KeyTest {
/**生成密钥*/
@Test
// @Test
public void test33(){
byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();
Console.log(Base64.encode(key));
}
/**加密*/
@Test
// @Test
public void test3(){
String key = "a6RlI/GctLgENUvF6DOY7w==";
String string = "po3OynBO[M3579p6L7)o";
@ -31,7 +31,7 @@ public class KeyTest {
}
/**解密*/
@Test
// @Test
public void test4(){
// String key = "";
String key = System.getenv("CCSENS_GAME");

123
util/src/test/java/com/ccsens/util/PdfUtilTest.java

@ -1,9 +1,17 @@
package com.ccsens.util;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import org.junit.Test;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* @description:
@ -14,22 +22,26 @@ public class PdfUtilTest {
@Test
public void test(){
List<PdfUtil.Row> rows = new ArrayList<>();
for (int i = 0; i < 3; i++) {
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setContent("cell" + i);
PdfUtil.Row row = new PdfUtil.Row();
row.addCell(cell);
PdfUtil.Cell cell2 = new PdfUtil.Cell();
cell2.setContent("cell--" + i);
row.addCell(cell2);
rows.add(row);
}
// for (int i = 0; i < 3; i++) {
// PdfUtil.Cell cell = new PdfUtil.Cell();
// cell.setContent("cell" + i);
// PdfUtil.Row row = new PdfUtil.Row();
// row.addCell(cell);
// PdfUtil.Cell cell2 = new PdfUtil.Cell();
// cell2.setContent("cell--" + i);
// row.addCell(cell2);
// rows.add(row);
// }
List<PdfUtil.Row> contents = new ArrayList<>();
for (int i = 0; i < 3; i++) {
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setRowSpan(2);
cell.setContent("*******" + i);
PdfUtil.Cell cell1 = new PdfUtil.Cell();
cell1.setContent("*******==========" + i);
PdfUtil.Row row = new PdfUtil.Row();
row.addCell(cell);
row.addCell(cell1);
PdfUtil.Cell cell2 = new PdfUtil.Cell();
cell2.setContent("+++++++" + i);
PdfUtil.Row row2 = new PdfUtil.Row();
@ -39,4 +51,95 @@ public class PdfUtilTest {
}
PdfUtil.credatePdf("/home/", "评测", rows, contents);
}
public static void main(String[] args) throws IOException, DocumentException {
String fileDesc = "";
FileOutputStream outr = null;// 创建输出流
// 生成随机数
Random random = new Random();
int x = random.nextInt();
fileDesc = "d:\\home\\" + "_" + x + ".pdf";// 路径下一定要有此文件
BaseFont baseFontChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
Font fontChinese = new Font(baseFontChinese, 12, Font.NORMAL);
// step 1
Document document = new Document();
// step 2
try {
outr = new FileOutputStream(fileDesc);
PdfWriter.getInstance(document, outr);
// step 3
document.open();
// step 4
PdfPTable table = new PdfPTable(3);
// the cell object
PdfPCell cell;
// we add a cell with colspan3
cell = new PdfPCell(new Phrase("Cell with colspan 3"));
cell.setColspan(3);
table.addCell(cell);
// now we add a cell with rowspan2
cell = new PdfPCell(new Phrase("Cell with rowspan 2 跨行", fontChinese));
cell.setRowspan(2);
// cell.setHorizontalAlignment(Element.ALIGN_MIDDLE);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(cell);
// we add the four remaining cells with addCell()
table.addCell("row 1-1; cell 1");
table.addCell("row 1-2; cell 2");
cell = new PdfPCell(new Phrase("Cell with rowspan 2 跨行", fontChinese));
table.addCell("row 2-1; cell 1");
table.addCell("row 2-2; cell 2");
table.addCell("row 3-1; cell 1");
table.addCell("row 3-2; cell 2");
table.addCell("row 3-3; cell 3");
table.addCell("row 4-1; cell 1");
table.addCell("row 4-2; cell 2");
table.addCell("row 4-3; cell 3");
table.addCell("row 5-1; cell 1");
table.addCell("row 5-2; cell 2");
table.addCell("row 5-3; cell 3");
table.addCell("row 6-1; cell 1");
table.addCell("row 6-2; cell 2");
table.addCell("row 6-3; cell 3");
table.addCell("row 7-1; cell 1");
table.addCell("row 7-2; cell 2");
table.addCell("row 7-3; cell 3");
table.addCell("row 8-1; cell 1");
table.addCell("row 8-2; cell 2");
table.addCell("row 8-3; cell 3");
table.addCell("row 9-1; cell 1");
table.addCell("row 9-2; cell 2");
table.addCell("row 9-3; cell 3");
//加入隔行换色事件
// PdfPTableEvent event = new AlternatingBackground();
// table.setTableEvent(event);
//end
document.add(table);
document.close();
} catch (DocumentException e1) {
e1.printStackTrace();
} finally {
if (outr != null) {
outr.close();
}
}
}
}

Loading…
Cancel
Save