Ver Fonte

顽症报告导出

zhuang há 1 ano atrás
pai
commit
7e0992c2a3

+ 4 - 2
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxPersistentManageDao.java

@@ -3,6 +3,7 @@ package com.rongwei.bscommon.sys.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.rongwei.bsentity.domain.ZhcxPersistentManageDo;
 import com.rongwei.bsentity.vo.ZhcxPersistentWordVO;
+import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
@@ -11,12 +12,13 @@ import java.util.Map;
 /**
  * @author zhuang
  */
+@Mapper
 public interface ZhcxPersistentManageDao extends BaseMapper<ZhcxPersistentManageDo> {
     @Select("<script>select * from ZHCX_PERSISTENT_MANAGE " +
             "where 1=1 and DELETED = '0' and PERIOD = #{period} and YEAR(CREATEDATE) = #{year} " +
             "and FILL IS NOT NULL" +
             "<if test='params!=null and params!=null'>" +
-            "#{params}" +
+            "${params}" +
             "</if>" +
             "</script>")
     List<ZhcxPersistentManageDo> listData(Map<String, Object> map);
@@ -25,7 +27,7 @@ public interface ZhcxPersistentManageDao extends BaseMapper<ZhcxPersistentManage
             "where 1=1 and DELETED = '0' and PERIOD = #{period} and YEAR(CREATEDATE) = #{year} " +
             "and FILL LIKE '%${type}%' and FIRSTORGNAME is not null " +
             "<if test='params!=null and params!=null'>" +
-            "#{params}" +
+            "${params}" +
             "</if>" +
             "GROUP BY FIRSTORGNAME ,TYPE"+
             "</script>")

+ 41 - 20
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxPersistentManageServiceImpl.java

@@ -60,6 +60,20 @@ public class ZhcxPersistentManageServiceImpl extends ServiceImpl<ZhcxPersistentM
         map.put("period","第"+period+"期");
         List<ZhcxPersistentManageDo> list = zhcxPersistentManageDao.listData(map);
         if(list.size() > 0){
+            list.forEach(ev ->{
+                String sitepic = ev.getSitepic();
+                if(StringUtils.isNotBlank(sitepic)){
+                    String[] splits = sitepic.split("\\^_\\^");
+                    Optional<String> firstId = Arrays.stream(splits)
+                            .filter(s -> s.contains(".jpg")
+                                    || s.contains(".jpeg")
+                                    || s.contains(".png"))
+                            .findFirst();
+                    if(firstId.isPresent()){
+                        ev.setSitepic(firstId.get());
+                    }
+                }
+            });
             Map<String, List<ZhcxPersistentManageDo>> groupList = list.stream()
                     .collect(Collectors.groupingBy(ZhcxPersistentManageDo::getFill));
             Date[] weekDates = getWeekDates(Integer.parseInt(year), Integer.parseInt(period));
@@ -357,28 +371,35 @@ public class ZhcxPersistentManageServiceImpl extends ServiceImpl<ZhcxPersistentM
             String rectifystatus = staf.getRectifystatus();
             if(StringUtils.isNotBlank(sitepic)){
                 String[] splits = StringUtils.toString(sitepic, "").split("\\^_\\^");
-                String[] imgIds = splits[0].split("-;-");
-                SysFileItemDo fileItemDo = sysFileItemService.getById(imgIds[1]);
-                if(fileItemDo != null){
-                    BufferedInputStream inputStream = FileUtil.getInputStream(fileItemDo.getFullpath());
-                    // 使用DocumentBuilder插入图片
-                    DocumentBuilder builder = new DocumentBuilder(doc);
-
-                    // 找到包含"pic"的占位符的单元格
-                    Cell cellWithPicPlaceholder = null;
-                    for (Cell cell : newRow.getCells()) {
-                        if (cell.getRange().getText().contains("pic")) {
-                            cellWithPicPlaceholder = cell;
-                            break;
+                Optional<String> firstId = Arrays.stream(splits)
+                        .filter(s -> s.contains(".jpg")
+                                || s.contains(".jpeg")
+                                || s.contains(".png"))
+                        .findFirst();
+                if(firstId.isPresent()){
+                    String[] imgIds = firstId.get().split("-;-");
+                    SysFileItemDo fileItemDo = sysFileItemService.getById(imgIds[1]);
+                    if(fileItemDo != null){
+                        BufferedInputStream inputStream = FileUtil.getInputStream(fileItemDo.getFullpath());
+                        // 使用DocumentBuilder插入图片
+                        DocumentBuilder builder = new DocumentBuilder(doc);
+
+                        // 找到包含"pic"的占位符的单元格
+                        Cell cellWithPicPlaceholder = null;
+                        for (Cell cell : newRow.getCells()) {
+                            if (cell.getRange().getText().contains("pic")) {
+                                cellWithPicPlaceholder = cell;
+                                break;
+                            }
                         }
-                    }
 
-                    if (cellWithPicPlaceholder != null) {
-                        // 清除占位符
-                        cellWithPicPlaceholder.getRange().replace("pic", "");
-                        // 移动到单元格并插入图片
-                        builder.moveTo(cellWithPicPlaceholder.getFirstParagraph());
-                        builder.insertImage(inputStream, 100, 80); // 设置图片宽度和高度
+                        if (cellWithPicPlaceholder != null) {
+                            // 清除占位符
+                            cellWithPicPlaceholder.getRange().replace("pic", "");
+                            // 移动到单元格并插入图片
+                            builder.moveTo(cellWithPicPlaceholder.getFirstParagraph());
+                            builder.insertImage(inputStream, 100, 80); // 设置图片宽度和高度
+                        }
                     }
                 }
             }