Browse Source

导出

master
zhizhi wu 5 years ago
parent
commit
4380fe375f
  1. 3
      health/src/main/java/com/ccsens/health/api/DebugController.java
  2. 18
      ht/src/main/java/com/ccsens/ht/api/DoctorController.java
  3. 3
      ht/src/main/java/com/ccsens/ht/api/PatientController.java
  4. 11
      ht/src/main/java/com/ccsens/ht/bean/po/HtDoctor.java
  5. 70
      ht/src/main/java/com/ccsens/ht/bean/po/HtDoctorExample.java
  6. 13
      ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java
  7. 40
      ht/src/main/java/com/ccsens/ht/service/DoctorService.java
  8. 7
      ht/src/main/java/com/ccsens/ht/service/IDoctorService.java
  9. 16
      ht/src/main/java/com/ccsens/ht/service/PatientReportService.java
  10. 4
      ht/src/main/resources/application-dev.yml
  11. 1
      ht/src/main/resources/application-prod.yml
  12. 1
      ht/src/main/resources/application-test.yml
  13. 25
      ht/src/main/resources/mapper_raw/HtDoctorMapper.xml
  14. 2
      util/src/main/java/com/ccsens/util/CodeEnum.java
  15. 27
      util/src/main/java/com/ccsens/util/PdfUtil.java
  16. 13
      util/src/main/java/com/ccsens/util/RestTemplateUtil.java
  17. 2
      util/src/test/java/com/ccsens/util/PdfUtilTest.java

3
health/src/main/java/com/ccsens/health/api/DebugController.java

@ -23,8 +23,7 @@ public class DebugController {
})
@RequestMapping(value="",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"})
public JsonResponse debug(HttpServletRequest request) throws Exception {
return JsonResponse.newInstance().ok("测试");
return JsonResponse.newInstance().ok("测试0\\\\\\\0");
}
@ApiOperation(value = "/测试二维码",notes = "")

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

@ -4,6 +4,7 @@ package com.ccsens.ht.api;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.ht.annotation.DoctorAudit;
import com.ccsens.ht.bean.dto.DoctorDto;
import com.ccsens.ht.bean.vo.PatientReportVo;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.ht.bean.vo.DoctorVo;
import com.ccsens.ht.service.IDoctorService;
@ -94,5 +95,22 @@ public class DoctorController {
return JsonResponse.newInstance().ok(dtos);
}
@MustLogin
@DoctorAudit
@ApiOperation(value = "分享编辑病友信息",notes = "分享编辑病友信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "json", value = "分享编辑病友信息", required = true)
})
@RequestMapping(value="/patientFillShare", method = RequestMethod.POST)
public JsonResponse<PatientReportVo.Export> patientFillShare(@RequestBody @ApiParam @Valid QueryDto params) throws Exception {
log.info("查询其他信息请求参数:{}", params);
Long userId = params.getUserId();
String path = doctorService.getShareUrl(userId);
PatientReportVo.Export export = new PatientReportVo.Export();
export.setPath(path);
log.info("{}分享路径:{}", userId, export);
return JsonResponse.newInstance().ok(export);
}
}

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

@ -112,7 +112,7 @@ public class PatientController {
patient.setIdcard(null);
}
//设置记录值
patient.setRecorder(patient.getId() == null ? Constant.Ht.NUMBER_DEFAULT : params.getUserId());
// patient.setRecorder(patient.getId() == null ? Constant.Ht.NUMBER_DEFAULT : params.getUserId());
long id = patientService.editPatient(patient.copy(), params.getUserId());
log.info("病友编辑结果:{}", id);
if (id <= 0) {
@ -160,4 +160,5 @@ public class PatientController {
json.put("id", id);
return JsonResponse.newInstance().ok(CodeEnum.SUCCESS, json);
}
}

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

@ -24,6 +24,8 @@ public class HtDoctor implements Serializable {
private String remark;
private String sharePatientEdit;
private Date createTime;
private Date updateTime;
@ -112,6 +114,14 @@ public class HtDoctor implements Serializable {
this.remark = remark == null ? null : remark.trim();
}
public String getSharePatientEdit() {
return sharePatientEdit;
}
public void setSharePatientEdit(String sharePatientEdit) {
this.sharePatientEdit = sharePatientEdit == null ? null : sharePatientEdit.trim();
}
public Date getCreateTime() {
return createTime;
}
@ -152,6 +162,7 @@ public class HtDoctor implements Serializable {
sb.append(", auditorId=").append(auditorId);
sb.append(", auditState=").append(auditState);
sb.append(", remark=").append(remark);
sb.append(", sharePatientEdit=").append(sharePatientEdit);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", isDel=").append(isDel);

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

@ -725,6 +725,76 @@ public class HtDoctorExample {
return (Criteria) this;
}
public Criteria andSharePatientEditIsNull() {
addCriterion("share_patient_edit is null");
return (Criteria) this;
}
public Criteria andSharePatientEditIsNotNull() {
addCriterion("share_patient_edit is not null");
return (Criteria) this;
}
public Criteria andSharePatientEditEqualTo(String value) {
addCriterion("share_patient_edit =", value, "sharePatientEdit");
return (Criteria) this;
}
public Criteria andSharePatientEditNotEqualTo(String value) {
addCriterion("share_patient_edit <>", value, "sharePatientEdit");
return (Criteria) this;
}
public Criteria andSharePatientEditGreaterThan(String value) {
addCriterion("share_patient_edit >", value, "sharePatientEdit");
return (Criteria) this;
}
public Criteria andSharePatientEditGreaterThanOrEqualTo(String value) {
addCriterion("share_patient_edit >=", value, "sharePatientEdit");
return (Criteria) this;
}
public Criteria andSharePatientEditLessThan(String value) {
addCriterion("share_patient_edit <", value, "sharePatientEdit");
return (Criteria) this;
}
public Criteria andSharePatientEditLessThanOrEqualTo(String value) {
addCriterion("share_patient_edit <=", value, "sharePatientEdit");
return (Criteria) this;
}
public Criteria andSharePatientEditLike(String value) {
addCriterion("share_patient_edit like", value, "sharePatientEdit");
return (Criteria) this;
}
public Criteria andSharePatientEditNotLike(String value) {
addCriterion("share_patient_edit not like", value, "sharePatientEdit");
return (Criteria) this;
}
public Criteria andSharePatientEditIn(List<String> values) {
addCriterion("share_patient_edit in", values, "sharePatientEdit");
return (Criteria) this;
}
public Criteria andSharePatientEditNotIn(List<String> values) {
addCriterion("share_patient_edit not in", values, "sharePatientEdit");
return (Criteria) this;
}
public Criteria andSharePatientEditBetween(String value1, String value2) {
addCriterion("share_patient_edit between", value1, value2, "sharePatientEdit");
return (Criteria) this;
}
public Criteria andSharePatientEditNotBetween(String value1, String value2) {
addCriterion("share_patient_edit not between", value1, value2, "sharePatientEdit");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;

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

@ -108,6 +108,7 @@ public class PatientReportVo {
List<PdfUtil.Row> rows = new ArrayList<>();
//第一栏
rows.add(
fillRow(
@ -118,7 +119,7 @@ public class PatientReportVo {
//第二栏
rows.add(
fillRow(
"文化程度(年或月):" + this.educationalStatusUnit,
"文化程度:" + this.educationalStatusUnit + "年",
"编号:" + this.serialNumber,
"职业:" + careerMap.get(this.career))
);
@ -152,6 +153,7 @@ public class PatientReportVo {
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setContent(param);
cell.setBorder(0);
cell.setCenter(false);
row.addCell(cell);
}
@ -253,14 +255,12 @@ public class PatientReportVo {
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++) {
@ -288,21 +288,22 @@ public class PatientReportVo {
scoreScoreCell.setContent(score);
scoreScoreCell.setRowSpan(2);
row4.addCell(scoreScoreCell);
// fillBlankCell(row5);
}
// fillBlankCell(row3);
// fillBlankCell(row3, row4, row5);
rows.add(row3);
rows.add(row4);
rows.add(row5);
}
}
if (StrUtil.isBlank(this.description)) {
return rows;
}
PdfUtil.Row descRow = new PdfUtil.Row();
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setColSpan(colNum);
cell.setContent(this.description);
cell.setCenter(false);
descRow.addCell(cell);
rows.add(descRow);

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

@ -1,6 +1,8 @@
package com.ccsens.ht.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.cloudutil.bean.tall.dto.MemberRoleDto;
import com.ccsens.cloudutil.feign.TallFeignClient;
@ -13,17 +15,20 @@ import com.ccsens.ht.persist.dao.HtTitleDao;
import com.ccsens.ht.persist.mapper.HtDoctorMapper;
import com.ccsens.ht.uitl.Constant;
import com.ccsens.util.*;
import com.ccsens.util.exception.BaseException;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -41,16 +46,18 @@ public class DoctorService implements IDoctorService {
@Autowired
private Snowflake snowflake;
@Autowired
@Resource
private HtDoctorMapper htDoctorMapper;
@Autowired
@Resource
private HtPositionDao htPositionDao;
@Autowired
@Resource
private HtTitleDao htTitleDao;
@Autowired
@Resource
private HtDoctorAuditDao htDoctorAuditDao;
@Autowired
private TallFeignClient tallFeignClient;
@Value("${ht.project.patientUrl}")
private String patientUrl;
@ -274,6 +281,31 @@ public class DoctorService implements IDoctorService {
return htDoctorMapper.selectByExample(doctorExample);
}
@Override
public String getShareUrl(Long userId) throws Exception {
HtDoctorExample example = new HtDoctorExample();
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())) {
return doctor.getSharePatientEdit();
}
log.info("生成分享评测对象信息录入页面");
String shareUrl = patientUrl + "?userId=" + userId;
String codePath = QrCodeUtil.urlToQRCode(shareUrl, PropUtil.path);
String codeUrl = PropUtil.imgDomain + "/" + codePath;
log.info("生成的二维码路径:{}", codeUrl);
doctor.setSharePatientEdit(codeUrl);
log.info("修改医生分享评测对象信息录入页面路径");
return codeUrl;
}
@Override
public DoctorVo.Query queryDoctorStatus(Long userId) {
DoctorVo.Query query = htDoctorAuditDao.queryDoctorStatus(userId);

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

@ -58,4 +58,11 @@ public interface IDoctorService {
/**查询医生审核状态*/
DoctorVo.Query queryDoctorStatus(Long userId);
/**
* 医生分享病人编辑路径
* @param userId
* @return
*/
String getShareUrl(Long userId) throws Exception;
}

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

@ -78,9 +78,7 @@ public class PatientReportService implements IPatientReportService {
return JsonResponse.newInstance().ok(CodeEnum.PARAM_ERROR);
}
HtPatientReportExample example = new HtPatientReportExample();
example.createCriteria().andPatientIdEqualTo(htPatient.getId());
long times = htPatientReportDao.countByExample(example);
HtPatientReport htPatientReport = new HtPatientReport();
htPatientReport.setId(snowflake.nextId());
htPatientReport.setDoctorId(doctors.get(0).getId());
@ -89,7 +87,6 @@ public class PatientReportService implements IPatientReportService {
htPatientReport.setPatientAge(StrUtil.isEmpty(htPatient.getIdcard()) ? null : (byte)IdcardUtil.getAgeByIdCard(htPatient.getIdcard()));
htPatientReport.setEvaluationCode(Constant.Ht.Report.PARENT_CODE);
htPatientReport.setName(Constant.Ht.Report.PARENT_NAME + DateUtil.today());
htPatientReport.setSerialNumber(htPatient.getId() + "_" + (times + 1));
htPatientReport.setReportTime(System.currentTimeMillis());
// 查询医院信息
String hospital = htPositionDao.queryHospital(doctors.get(0).getPositionId());
@ -383,28 +380,31 @@ public class PatientReportService implements IPatientReportService {
content.addAll(reportScore.toRow());
});
PdfUtil.Row row = new PdfUtil.Row();
addCell(row,"初步印象",2,2);
addCell(row, detail.getPatient().getInitialImpression(), 6, 2);
PdfUtil.Cell initWordCell = addCell(row, "初步印象", 2, 2);
initWordCell.setHeight(50);
PdfUtil.Cell initImplCell = addCell(row, detail.getPatient().getInitialImpression(), 6, 2);
initImplCell.setHeight(50);
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().getHospital()+Constant.Ht.Report.PARENT_NAME, detail.getPatient().toPdfRow(), content);
String path = PropUtil.imgDomain + "/" + PdfUtil.credatePdf(PropUtil.path, detail.getPatient().getHospital(), Constant.Ht.Report.PARENT_NAME, 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) {
private PdfUtil.Cell 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);
return cell1;
}
@Override

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

@ -34,4 +34,6 @@ file:
imgDomain: http://localhost:7040/uploads
ht:
project:
name: 认知功能评测云平台系统
patientUrl: https://www.baidu.com/
name: 认知功能评测云平台系统

1
ht/src/main/resources/application-prod.yml

@ -34,6 +34,7 @@ file:
imgDomain: https://www.tall.wiki/gateway/ht/uploads
ht:
project:
patientUrl: https://www.tall.wiki/ht-dev/htPatientRegister
name: 认知功能评测云平台系统
eureka:
instance:

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

@ -35,6 +35,7 @@ file:
imgDomain: https://test.tall.wiki/gateway/ht/uploads
ht:
project:
patientUrl: https://test.tall.wiki/ht-dev/htPatientRegister
name: 认知功能评测云平台系统
eureka:
instance:

25
ht/src/main/resources/mapper_raw/HtDoctorMapper.xml

@ -12,6 +12,7 @@
<result column="auditor_id" jdbcType="BIGINT" property="auditorId" />
<result column="audit_state" jdbcType="TINYINT" property="auditState" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="share_patient_edit" jdbcType="VARCHAR" property="sharePatientEdit" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="is_del" jdbcType="TINYINT" property="isDel" />
@ -76,7 +77,7 @@
</sql>
<sql id="Base_Column_List">
id, user_id, position_id, title_id, name, sex, age, auditor_id, audit_state, remark,
create_time, update_time, is_del
share_patient_edit, create_time, update_time, is_del
</sql>
<select id="selectByExample" parameterType="com.ccsens.ht.bean.po.HtDoctorExample" resultMap="BaseResultMap">
select
@ -112,13 +113,13 @@
insert into t_ht_doctor (id, user_id, position_id,
title_id, name, sex,
age, auditor_id, audit_state,
remark, create_time, update_time,
is_del)
remark, share_patient_edit, create_time,
update_time, is_del)
values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{positionId,jdbcType=BIGINT},
#{titleId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{sex,jdbcType=TINYINT},
#{age,jdbcType=INTEGER}, #{auditorId,jdbcType=BIGINT}, #{auditState,jdbcType=TINYINT},
#{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{isDel,jdbcType=TINYINT})
#{remark,jdbcType=VARCHAR}, #{sharePatientEdit,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{isDel,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" parameterType="com.ccsens.ht.bean.po.HtDoctor">
insert into t_ht_doctor
@ -153,6 +154,9 @@
<if test="remark != null">
remark,
</if>
<if test="sharePatientEdit != null">
share_patient_edit,
</if>
<if test="createTime != null">
create_time,
</if>
@ -194,6 +198,9 @@
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="sharePatientEdit != null">
#{sharePatientEdit,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
@ -244,6 +251,9 @@
<if test="record.remark != null">
remark = #{record.remark,jdbcType=VARCHAR},
</if>
<if test="record.sharePatientEdit != null">
share_patient_edit = #{record.sharePatientEdit,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
@ -270,6 +280,7 @@
auditor_id = #{record.auditorId,jdbcType=BIGINT},
audit_state = #{record.auditState,jdbcType=TINYINT},
remark = #{record.remark,jdbcType=VARCHAR},
share_patient_edit = #{record.sharePatientEdit,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
is_del = #{record.isDel,jdbcType=TINYINT}
@ -307,6 +318,9 @@
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="sharePatientEdit != null">
share_patient_edit = #{sharePatientEdit,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
@ -330,6 +344,7 @@
auditor_id = #{auditorId,jdbcType=BIGINT},
audit_state = #{auditState,jdbcType=TINYINT},
remark = #{remark,jdbcType=VARCHAR},
share_patient_edit = #{sharePatientEdit,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
is_del = #{isDel,jdbcType=TINYINT}

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

@ -112,6 +112,8 @@ public enum CodeEnum {
HEALTH_TYPE_ERROR(94,"您的健康状态异常,打卡失败。",true),
NOT_HEALTH_RECORD(95,"您今天还未上报健康信息,请上报后再试。",true),
SELECT_TIME_ERROR(96,"请输入正确的查询时间",true),
DINGDING_EXCEPTION(97,"钉钉接口调用异常。",true),
URL_ERROR(98, "请求路径转换异常", true),
;
public CodeEnum addMsg(String msg){

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

@ -2,6 +2,7 @@ package com.ccsens.util;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
@ -29,11 +30,12 @@ public class PdfUtil {
* 生成pdf
* @param parentPath
* @param title
* @param subhead 副标题
* @param intros
* @param content
* @return
*/
public static String credatePdf(String parentPath, String title, List<Row> intros, List<Row> content) {
public static String credatePdf(String parentPath, String title, String subhead, List<Row> intros, List<Row> content) {
String fileName = "pdf/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".pdf";
log.info("pdf文件名:{}", fileName );
File file = new File(parentPath, fileName);
@ -50,11 +52,19 @@ public class PdfUtil {
// 中文字体
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
// 标题字体
Font titleChinese = new Font(bfChinese, 18, Font.BOLD);
Font titleChinese = new Font(bfChinese, 24, Font.BOLD);
//设置标题
Paragraph par = new Paragraph(title, titleChinese);
par.setAlignment(Element.ALIGN_CENTER);
document.add(par);
if (StrUtil.isNotBlank(subhead)) {
// 标题字体
Font subheadChinese = new Font(bfChinese, 22, Font.NORMAL);
//设置标题
Paragraph subheadPar = new Paragraph(subhead, subheadChinese);
subheadPar.setAlignment(Element.ALIGN_CENTER);
document.add(subheadPar);
}
// 每行加空白
fillBlankRow(document, titleChinese);
@ -126,6 +136,15 @@ public class PdfUtil {
pdfpCell.setBorderWidthBottom(cell.border);
pdfpCell.setColspan(cell.colSpan);
pdfpCell.setRowspan(cell.rowSpan);
if (cell.isCenter) {
//水平居中
pdfpCell.setHorizontalAlignment(Element.ALIGN_CENTER);
}
//垂直居中
pdfpCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
// pdfpCell.setFixedHeight(cell.height);
pdfpCell.setMinimumHeight(cell.height);
table.addCell(pdfpCell);
}
}
@ -164,6 +183,10 @@ public class PdfUtil {
private int colSpan = 1;
//纵向合并数
private int rowSpan = 1;
//单元格高度
private int height = 25;
// 单元格是否居中
private boolean isCenter = true;
}
}

13
util/src/main/java/com/ccsens/util/RestTemplateUtil.java

@ -3,6 +3,7 @@ package com.ccsens.util;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.util.exception.BaseException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
@ -15,6 +16,8 @@ import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
@Slf4j
@ -61,7 +64,15 @@ public class RestTemplateUtil {
JSONObject json = JSON.parseObject(JSON.toJSONString(params));
HttpEntity<Map<String, Object>> objectHttpEntity = new HttpEntity<>(json,httpHeaders);
ResponseEntity<String> response = util.restTemplate.postForEntity(url, objectHttpEntity, String.class);
URI uri = null;
try {
uri = new URI(url);
}catch (URISyntaxException e) {
log.error("转换路径异常:{}", e);
throw new BaseException(CodeEnum.URL_ERROR);
}
ResponseEntity<String> response = util.restTemplate.postForEntity(uri, objectHttpEntity, String.class);
log.info("返回:{}", response);
return response.getBody();
}

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

@ -49,7 +49,7 @@ public class PdfUtilTest {
contents.add(row);
contents.add(row2);
}
PdfUtil.credatePdf("/home/", "评测", rows, contents);
PdfUtil.credatePdf("/home/", "山大一院","评测", rows, contents);
}

Loading…
Cancel
Save