Browse Source

Merge branch 'master' into innerDevelop

zhoutg 4 years ago
parent
commit
2a3a355bd6

+ 3 - 5
src/main/java/com/diagbot/aggregate/IndicationTestAggregate.java

@@ -86,11 +86,6 @@ public class IndicationTestAggregate {
         MultipartFile file = testFacade.getMulFileByPath(mapPath.get("【高危药品】"));
         Map<String, Object> highDrugMap = testFacade.testHighRiskDrugExcel(file, new TestLineVO());
         map.put("【高危药品】",highDrugMap);
-
-        file = testFacade.getMulFileByPath(mapPath.get("【高危手术整合】"));
-        Map<String, Object> highOperationMap = testFacade.testHighRiskOperationExcel(file, new TestLineVO());
-        map.put("【高危手术】",highOperationMap);
-
         return map;
     }
 
@@ -99,6 +94,9 @@ public class IndicationTestAggregate {
         Map<String, Object> map = new LinkedHashMap<>();
         MultipartFile file = testFacade.getMulFileByPath(mapPath.get("【高危手术整合】"));
 
+        Map<String, Object> highOperationMap = testFacade.testHighRiskOperationExcel(file, new TestLineVO());
+        map.put("【高危手术】",highOperationMap);
+
         TestLineVO testLineVO = new TestLineVO();
         testLineVO.setGetOne(true);
         Map<String, Object> highOperationComplexMap = testFacade.testHighRiskProcess(file, testLineVO);

+ 5 - 0
src/main/java/com/diagbot/facade/TestwordInfoFacade.java

@@ -13,6 +13,8 @@ import com.diagbot.entity.SymptomFeatureList;
 import com.diagbot.entity.TestwordInfo;
 import com.diagbot.entity.TestwordRes;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.service.SymptomFeatureService;
 import com.diagbot.service.TestwordInfoService;
 import com.diagbot.service.TestwordResService;
@@ -448,6 +450,9 @@ public class TestwordInfoFacade extends TestwordInfoServiceImpl {
      * @param symptomFeatureVO
      */
     public void getSymptom(SymptomFeatureVO symptomFeatureVO) {
+        if (StringUtil.isBlank(symptomFeatureVO.getPath())) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "文件目录不能为空");
+        }
         Map<String, SymptomFeatureList> listMap = new LinkedHashMap<>();
         try {
             // 1、获取文件目录

+ 181 - 0
src/main/java/com/diagbot/util/ExcelStyleUtil.java

@@ -0,0 +1,181 @@
+package com.diagbot.util;
+
+import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
+import cn.afterturn.easypoi.excel.entity.params.ExcelForEachParams;
+import cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler;
+import org.apache.poi.ss.usermodel.*;
+
+/**
+ * @description: 自定义excel格式
+ * @author: zhoutg
+ * @date: 2020/11/10 13:10
+ */
+public class ExcelStyleUtil implements IExcelExportStyler {
+    private static final short STRING_FORMAT = (short) BuiltinFormats.getBuiltinFormat("TEXT");
+    private static final short FONT_SIZE_TEXT = 10;
+    private static final short FONT_SIZE_TITLE = 10;
+    private static final short FONT_SIZE_HEADER = 10;
+    /**
+     * 大标题样式
+     */
+    private CellStyle headerStyle;
+    /**
+     * 每列标题样式
+     */
+    private CellStyle titleStyle;
+    /**
+     * 数据行样式
+     */
+    private CellStyle styles;
+
+    public ExcelStyleUtil(Workbook workbook) {
+        this.init(workbook);
+    }
+
+    /**
+     * 初始化样式
+     *
+     * @param workbook
+     */
+    private void init(Workbook workbook) {
+        this.headerStyle = initHeaderStyle(workbook);
+        this.titleStyle = initTitleStyle(workbook);
+        this.styles = initStyles(workbook);
+    }
+
+    /**
+     * 大标题样式
+     *
+     * @param color
+     * @return
+     */
+    @Override
+    public CellStyle getHeaderStyle(short color) {
+        return headerStyle;
+    }
+
+    /**
+     * 每列标题样式
+     *
+     * @param color
+     * @return
+     */
+    @Override
+    public CellStyle getTitleStyle(short color) {
+        return titleStyle;
+    }
+
+    /**
+     * 数据行样式
+     *
+     * @param parity 可以用来表示奇偶行
+     * @param entity 数据内容
+     * @return 样式
+     */
+    @Override
+    public CellStyle getStyles(boolean parity, ExcelExportEntity entity) {
+        return styles;
+    }
+
+    /**
+     * 获取样式方法
+     *
+     * @param dataRow 数据行
+     * @param obj     对象
+     * @param data    数据
+     */
+    @Override
+    public CellStyle getStyles(Cell cell, int dataRow, ExcelExportEntity entity, Object obj, Object data) {
+        return getStyles(true, entity);
+    }
+
+    /**
+     * 模板使用的样式设置
+     */
+    @Override
+    public CellStyle getTemplateStyles(boolean isSingle, ExcelForEachParams excelForEachParams) {
+        return null;
+    }
+
+    /**
+     * 初始化--大标题样式
+     *
+     * @param workbook
+     * @return
+     */
+    private CellStyle initHeaderStyle(Workbook workbook) {
+        CellStyle style = getBaseCellStyle(workbook);
+        style.setFont(getFont(workbook, FONT_SIZE_HEADER, true));
+        return style;
+    }
+
+    /**
+     * 初始化--每列标题样式
+     *
+     * @param workbook
+     * @return
+     */
+    private CellStyle initTitleStyle(Workbook workbook) {
+        CellStyle style = getBaseCellStyle(workbook);
+        style.setFont(getFont(workbook, FONT_SIZE_TITLE, true));
+        //背景色
+        style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        return style;
+    }
+
+    /**
+     * 初始化--数据行样式
+     *
+     * @param workbook
+     * @return
+     */
+    private CellStyle initStyles(Workbook workbook) {
+        CellStyle style = getBaseCellStyle(workbook);
+        style.setFont(getFont(workbook, FONT_SIZE_TEXT, false));
+        style.setDataFormat(STRING_FORMAT);
+        return style;
+    }
+
+    /**
+     * 基础样式
+     *
+     * @return
+     */
+    private CellStyle getBaseCellStyle(Workbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+        //下边框
+        style.setBorderBottom(BorderStyle.THIN);
+        //左边框
+        style.setBorderLeft(BorderStyle.THIN);
+        //上边框
+        style.setBorderTop(BorderStyle.THIN);
+        //右边框
+        style.setBorderRight(BorderStyle.THIN);
+        //水平居中
+        style.setAlignment(HorizontalAlignment.CENTER);
+        //上下居中
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        //设置自动换行
+        style.setWrapText(true);
+        return style;
+    }
+
+    /**
+     * 字体样式
+     *
+     * @param size   字体大小
+     * @param isBold 是否加粗
+     * @return
+     */
+    private Font getFont(Workbook workbook, short size, boolean isBold) {
+        Font font = workbook.createFont();
+        //字体样式
+        font.setFontName("宋体");
+        //是否加粗
+        font.setBold(isBold);
+        //字体大小
+        font.setFontHeightInPoints(size);
+        return font;
+    }
+}

+ 2 - 0
src/main/java/com/diagbot/web/TestwordInfoController.java

@@ -8,6 +8,7 @@ import com.diagbot.vo.TestwordInfoVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -34,6 +35,7 @@ public class TestwordInfoController {
     @ApiOperation(value = "提词API[zhoutg]",
             notes = "提词API")
     @PostMapping("/getword")
+    @Transactional
     public RespDTO<Map<String, String>> getword(@RequestBody TestwordInfoVO testwordInfoVO) {
         return RespDTO.onSuc(testwordInfoFacade.getWord(testwordInfoVO));
     }