Forráskód Böngészése

产品维护字段扩展,日报代码修正

yzc 2 éve
szülő
commit
29e4b74997

+ 6 - 0
hx-item/pom.xml

@@ -24,6 +24,12 @@
             <artifactId>hx-common</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>2.2.11</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 7 - 4
hx-item/src/main/java/com/fjhx/item/controller/product/ProductInfoController.java

@@ -9,10 +9,8 @@ import com.fjhx.item.entity.product.vo.ProductInfoVo;
 import com.fjhx.item.service.product.ProductInfoService;
 import com.ruoyi.common.core.domain.BaseSelectDto;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -71,4 +69,9 @@ public class ProductInfoController {
         productInfoService.delete(dto.getId());
     }
 
+    @PostMapping("/excelImport")
+    public void issueExcelImport(@RequestParam("file") MultipartFile file){
+        productInfoService.excelImport(file);
+    }
+
 }

+ 2 - 0
hx-item/src/main/java/com/fjhx/item/entity/product/po/ProductInfo.java

@@ -68,4 +68,6 @@ public class ProductInfo extends BasePo {
      */
     private String remark;
 
+    private String victoriatouristJson;
+
 }

+ 4 - 0
hx-item/src/main/java/com/fjhx/item/service/product/ProductInfoService.java

@@ -7,6 +7,7 @@ import com.fjhx.item.entity.product.po.ProductInfo;
 import com.fjhx.item.entity.product.vo.ProductInfoVo;
 import com.ruoyi.common.core.service.BaseService;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 
@@ -59,4 +60,7 @@ public interface ProductInfoService extends BaseService<ProductInfo> {
      */
     List<ProductInfoVo> getListByProductType(Integer productType);
 
+    /**excel导入*/
+    void excelImport(MultipartFile file);
+
 }

+ 43 - 0
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductInfoServiceImpl.java

@@ -1,6 +1,8 @@
 package com.fjhx.item.service.product.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -15,12 +17,16 @@ import com.fjhx.item.mapper.product.ProductInfoMapper;
 import com.fjhx.item.service.product.ProductClassifyService;
 import com.fjhx.item.service.product.ProductInfoService;
 import com.fjhx.item.util.CodeEnum;
+import com.fjhx.item.util.excel.util.ExcelUtil;
 import com.ruoyi.common.core.domain.BaseIdPo;
+import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.ruoyi.common.utils.wrapper.SqlField;
+import com.ruoyi.system.service.ISysDeptService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -43,6 +49,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
 
     @Autowired
     private ProductClassifyService productClassifyService;
+    @Autowired
+    private ISysDeptService sysDeptService;
 
     @Override
     public Page<ProductInfoVo> getPage(ProductInfoSelectDto dto) {
@@ -85,7 +93,35 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
             record.setClassifyNameGroup(classifyNameGroup);
 
         }
+        //赋值维多利亚扩展部门名称
+        List<Long> ids = new ArrayList<>();
+        for (ProductInfoVo record : records) {
+            String victoriatouristJson = record.getVictoriatouristJson();
+            if (ObjectUtil.isNotEmpty(victoriatouristJson)) {
+                JSONObject json = JSONObject.parseObject(victoriatouristJson);
+                ids.add(json.getLong("deptId"));
+            }
+        }
+        if (ObjectUtil.isEmpty(ids)) {
+            return page;
+        }
+
+        IWrapper<SysDept> wrapper1 = IWrapper.getWrapper();
+        wrapper1.in(SysDept::getDeptId, ids);
+        List<SysDept> sysDepts = sysDeptService.list(wrapper1);
+        Map<Long, String> sysDeptMap = sysDepts.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
+
+        for (ProductInfoVo record : records) {
+            String victoriatouristJson = record.getVictoriatouristJson();
+
+            if (ObjectUtil.isEmpty(victoriatouristJson)) {
+                continue;
+            }
 
+            JSONObject json = JSONObject.parseObject(victoriatouristJson);
+            json.put("deptName", sysDeptMap.get(json.getLong("deptId")));
+            record.setVictoriatouristJson(json.toJSONString());
+        }
 
         return page;
     }
@@ -128,6 +164,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
 
     /**
      * 根据产品IDS获取产品
+     *
      * @param productIds
      * @return
      */
@@ -138,6 +175,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
 
     /**
      * 根据产品类型获取产品
+     *
      * @param productType
      * @return
      */
@@ -146,4 +184,9 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         return baseMapper.getListByProductType(productType);
     }
 
+    @Override
+    public void excelImport(MultipartFile file) {
+//        List<Object> read = ExcelUtil.read(file, Object.class);
+    }
+
 }

+ 51 - 0
hx-item/src/main/java/com/fjhx/item/util/excel/listener/DataListener.java

@@ -0,0 +1,51 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.item.util.excel.listener;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Excel监听器
+ *
+ * @author Chill
+ */
+@Getter
+@EqualsAndHashCode(callSuper = true)
+public class DataListener<T> extends AnalysisEventListener<T> {
+
+	/**
+	 * 缓存的数据列表
+	 */
+	private final List<T> dataList = new ArrayList<>();
+
+	@Override
+	public void invoke(T data, AnalysisContext analysisContext) {
+		dataList.add(data);
+	}
+
+	@Override
+	public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+
+	}
+
+}

+ 72 - 0
hx-item/src/main/java/com/fjhx/item/util/excel/listener/ImportListener.java

@@ -0,0 +1,72 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.item.util.excel.listener;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.fjhx.item.util.excel.support.ExcelImporter;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.RequiredArgsConstructor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Excel监听器
+ *
+ * @author Chill
+ */
+@Data
+@RequiredArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+public class ImportListener<T> extends AnalysisEventListener<T> {
+
+	/**
+	 * 默认每隔3000条存储数据库
+	 */
+	private int batchCount = 3000;
+	/**
+	 * 缓存的数据列表
+	 */
+	private List<T> list = new ArrayList<>();
+	/**
+	 * 数据导入类
+	 */
+	private final ExcelImporter<T> importer;
+
+	@Override
+	public void invoke(T data, AnalysisContext analysisContext) {
+		list.add(data);
+		// 达到BATCH_COUNT,则调用importer方法入库,防止数据几万条数据在内存,容易OOM
+		if (list.size() >= batchCount) {
+			// 调用importer方法
+			importer.save(list);
+			// 存储完成清理list
+			list.clear();
+		}
+	}
+
+	@Override
+	public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+		// 调用importer方法
+		importer.save(list);
+		// 存储完成清理list
+		list.clear();
+	}
+
+}

+ 30 - 0
hx-item/src/main/java/com/fjhx/item/util/excel/support/ExcelException.java

@@ -0,0 +1,30 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.item.util.excel.support;
+
+/**
+ * Excel异常处理类
+ *
+ * @author Chill
+ */
+public class ExcelException extends RuntimeException {
+	private static final long serialVersionUID = 1L;
+
+	public ExcelException(String message) {
+		super(message);
+	}
+}

+ 35 - 0
hx-item/src/main/java/com/fjhx/item/util/excel/support/ExcelImporter.java

@@ -0,0 +1,35 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.item.util.excel.support;
+
+import java.util.List;
+
+/**
+ * Excel统一导入接口
+ *
+ * @author Chill
+ */
+public interface ExcelImporter<T> {
+
+	/**
+	 * 导入数据逻辑
+	 *
+	 * @param data 数据集合
+	 */
+	void save(List<T> data);
+
+}

+ 178 - 0
hx-item/src/main/java/com/fjhx/item/util/excel/util/ExcelUtil.java

@@ -0,0 +1,178 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.item.util.excel.util;
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.read.builder.ExcelReaderBuilder;
+import com.alibaba.excel.read.listener.ReadListener;
+import com.alibaba.excel.util.DateUtils;
+import com.alibaba.excel.write.handler.WriteHandler;
+import com.fjhx.item.util.excel.listener.DataListener;
+import com.fjhx.item.util.excel.listener.ImportListener;
+import com.fjhx.item.util.excel.support.ExcelException;
+import com.fjhx.item.util.excel.support.ExcelImporter;
+import lombok.SneakyThrows;
+import org.apache.commons.codec.Charsets;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Excel工具类
+ *
+ * @author Chill
+ * @apiNote { https://www.yuque.com/easyexcel/doc/easyexcel }
+ */
+public class ExcelUtil {
+
+	/**
+	 * 读取excel的所有sheet数据
+	 *
+	 * @param excel excel文件
+	 * @return List<Object>
+	 */
+	public static <T> List<T> read(MultipartFile excel, Class<T> clazz) {
+		DataListener<T> dataListener = new DataListener<>();
+		ExcelReaderBuilder builder = getReaderBuilder(excel, dataListener, clazz);
+		builder.doReadAll();
+		return dataListener.getDataList();
+	}
+
+	/**
+	 * 读取excel的指定sheet数据
+	 *
+	 * @param excel   excel文件
+	 * @param sheetNo sheet序号(从0开始)
+	 * @return List<Object>
+	 */
+	public static <T> List<T> read(MultipartFile excel, int sheetNo, Class<T> clazz) {
+		return read(excel, sheetNo, 1, clazz);
+	}
+
+	/**
+	 * 读取excel的指定sheet数据
+	 *
+	 * @param excel         excel文件
+	 * @param sheetNo       sheet序号(从0开始)
+	 * @param headRowNumber 表头行数
+	 * @return List<Object>
+	 */
+	public static <T> List<T> read(MultipartFile excel, int sheetNo, int headRowNumber, Class<T> clazz) {
+		DataListener<T> dataListener = new DataListener<>();
+		ExcelReaderBuilder builder = getReaderBuilder(excel, dataListener, clazz);
+		builder.sheet(sheetNo).headRowNumber(headRowNumber).doRead();
+		return dataListener.getDataList();
+	}
+
+	/**
+	 * 读取并导入数据
+	 *
+	 * @param excel    excel文件
+	 * @param importer 导入逻辑类
+	 * @param <T>      泛型
+	 */
+	public static <T> void save(MultipartFile excel, ExcelImporter<T> importer, Class<T> clazz) {
+		ImportListener<T> importListener = new ImportListener<>(importer);
+		ExcelReaderBuilder builder = getReaderBuilder(excel, importListener, clazz);
+		builder.doReadAll();
+	}
+
+	/**
+	 * 导出excel
+	 *
+	 * @param response 响应类
+	 * @param dataList 数据列表
+	 * @param clazz    class类
+	 * @param <T>      泛型
+	 */
+	@SneakyThrows
+	public static <T> void export(HttpServletResponse response, List<T> dataList, Class<T> clazz) {
+		export(response, DateUtils.format(new Date(), DateUtils.DATE_FORMAT_14), "导出数据", dataList, clazz);
+	}
+
+	/**
+	 * 导出excel
+	 *
+	 * @param response  响应类
+	 * @param fileName  文件名
+	 * @param sheetName sheet名
+	 * @param dataList  数据列表
+	 * @param clazz     class类
+	 * @param <T>       泛型
+	 */
+	@SneakyThrows
+	public static <T> void export(HttpServletResponse response, String fileName, String sheetName, List<T> dataList, Class<T> clazz) {
+		response.setContentType("application/vnd.ms-excel");
+		response.setCharacterEncoding(Charsets.UTF_8.name());
+		fileName = URLEncoder.encode(fileName, Charsets.UTF_8.name());
+		response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+		EasyExcel.write(response.getOutputStream(), clazz).sheet(sheetName).doWrite(dataList);
+	}
+
+	/**
+	 * 导出excel
+	 *
+	 * @param response     响应类
+	 * @param fileName     文件名
+	 * @param sheetName    sheet名
+	 * @param dataList     数据列表
+	 * @param clazz        class类
+	 * @param writeHandler 自定义处理器
+	 * @param <T>          泛型
+	 */
+	@SneakyThrows
+	public static <T> void export(HttpServletResponse response, String fileName, String sheetName, List<T> dataList, WriteHandler writeHandler, Class<T> clazz) {
+		response.setContentType("application/vnd.ms-excel");
+		response.setCharacterEncoding(Charsets.UTF_8.name());
+		fileName = URLEncoder.encode(fileName, Charsets.UTF_8.name());
+		response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+		EasyExcel.write(response.getOutputStream(), clazz).registerWriteHandler(writeHandler).sheet(sheetName).doWrite(dataList);
+	}
+
+	/**
+	 * 获取构建类
+	 *
+	 * @param excel        excel文件
+	 * @param readListener excel监听类
+	 * @return ExcelReaderBuilder
+	 */
+	public static <T> ExcelReaderBuilder getReaderBuilder(MultipartFile excel, ReadListener<T> readListener, Class<T> clazz) {
+		String filename = excel.getOriginalFilename();
+		if (ObjectUtils.isEmpty(filename)) {
+			throw new ExcelException("请上传文件!");
+		}
+		if ((!StringUtils.endsWithIgnoreCase(filename, ".xls") && !StringUtils.endsWithIgnoreCase(filename, ".xlsx"))) {
+			throw new ExcelException("请上传正确的excel文件!");
+		}
+		InputStream inputStream;
+		try {
+			inputStream = new BufferedInputStream(excel.getInputStream());
+			return EasyExcel.read(inputStream, clazz, readListener);
+		} catch (IOException e) {
+			throw new ExcelException("读取文件失败!");
+		}
+	}
+
+}

+ 2 - 2
hx-oa/src/main/java/com/fjhx/oa/controller/daily/DailyReportController.java

@@ -77,8 +77,8 @@ public class DailyReportController {
      * 分享日报
      */
     @PostMapping("/share")
-    public void share(Long id,Long toUserId) {
-        dailyReportService.share(id,toUserId);
+    public void share(DailyReportDto dto) {
+        dailyReportService.share(dto.getId(), dto.getToUserId());
     }
 
 }

+ 3 - 0
hx-oa/src/main/java/com/fjhx/oa/entity/daily/dto/DailyReportCommentsSelectDto.java

@@ -14,4 +14,7 @@ import lombok.Setter;
 @Setter
 public class DailyReportCommentsSelectDto extends BaseSelectDto {
 
+    /**日报id*/
+    private Long dailyReportId;
+
 }

+ 2 - 0
hx-oa/src/main/java/com/fjhx/oa/entity/daily/dto/DailyReportDto.java

@@ -28,4 +28,6 @@ public class DailyReportDto extends DailyReport {
     /**接收人列表*/
     private List<DailyReportDetails> dailyReportDetailsList;
 
+    private List<Long> toUserId;
+
 }

+ 4 - 1
hx-oa/src/main/java/com/fjhx/oa/service/daily/DailyReportService.java

@@ -7,6 +7,9 @@ import com.fjhx.oa.entity.daily.vo.DailyReportVo;
 import com.fjhx.oa.entity.daily.dto.DailyReportSelectDto;
 import com.fjhx.oa.entity.daily.dto.DailyReportDto;
 
+import java.awt.*;
+import java.util.List;
+
 
 /**
  * <p>
@@ -45,5 +48,5 @@ public interface DailyReportService extends BaseService<DailyReport> {
 
     DailyReportVo myCount( );
 
-    void share(Long id, Long toUserId);
+    void share(Long id, List<Long> toUserIdList);
 }

+ 18 - 14
hx-oa/src/main/java/com/fjhx/oa/service/daily/impl/DailyReportCommentsServiceImpl.java

@@ -1,21 +1,22 @@
 package com.fjhx.oa.service.daily.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.common.constant.SourceConstant;
+import com.fjhx.oa.entity.daily.dto.DailyReportCommentsDto;
+import com.fjhx.oa.entity.daily.dto.DailyReportCommentsSelectDto;
 import com.fjhx.oa.entity.daily.po.DailyReportComments;
+import com.fjhx.oa.entity.daily.vo.DailyReportCommentsVo;
 import com.fjhx.oa.mapper.daily.DailyReportCommentsMapper;
 import com.fjhx.oa.service.daily.DailyReportCommentsService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.ruoyi.system.utils.UserUtil;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.fjhx.oa.entity.daily.vo.DailyReportCommentsVo;
-import com.fjhx.oa.entity.daily.dto.DailyReportCommentsSelectDto;
-import com.ruoyi.common.utils.wrapper.IWrapper;
-import com.fjhx.oa.entity.daily.dto.DailyReportCommentsDto;
-import cn.hutool.core.bean.BeanUtil;
 
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 
@@ -24,7 +25,7 @@ import java.util.stream.Collectors;
  * 报表评论 服务实现类
  * </p>
  *
- * @author 
+ * @author
  * @since 2023-04-04
  */
 @DS(SourceConstant.OA)
@@ -35,20 +36,23 @@ public class DailyReportCommentsServiceImpl extends ServiceImpl<DailyReportComme
     public Page<DailyReportCommentsVo> getPage(DailyReportCommentsSelectDto dto) {
         IWrapper<DailyReportComments> wrapper = getWrapper();
         wrapper.orderByDesc("drc", DailyReportComments::getId);
+        wrapper.eq(DailyReportComments::getDailyReportId, dto.getDailyReportId());
         //过滤掉回复评论
         wrapper.isNull("drc.reply_id");
         Page<DailyReportCommentsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         List<DailyReportCommentsVo> records = page.getRecords();
         //赋值用户名
-        UserUtil.assignmentNickName(records,DailyReportComments::getCreateUser,DailyReportCommentsVo::setUserName);
+        UserUtil.assignmentNickName(records, DailyReportComments::getCreateUser, DailyReportCommentsVo::setUserName);
         //赋值回复评论列表
         List<Long> dailyReportCommentsIds = records.stream().map(DailyReportComments::getId).collect(Collectors.toList());
-        for (DailyReportCommentsVo dailyReportComments:records){
-            List<DailyReportComments> list = list(q -> q.in(DailyReportComments::getReplyId, dailyReportCommentsIds));
-            List<DailyReportCommentsVo> dailyReportCommentsVos = BeanUtil.copyToList(list, DailyReportCommentsVo.class);
-            UserUtil.assignmentNickName(dailyReportCommentsVos,DailyReportComments::getCreateUser,DailyReportCommentsVo::setUserName);
-            dailyReportComments.setReplyList(dailyReportCommentsVos);
+        List<DailyReportComments> list = list(q -> q.in(DailyReportComments::getReplyId, dailyReportCommentsIds));
+        List<DailyReportCommentsVo> dailyReportCommentsVos = BeanUtil.copyToList(list, DailyReportCommentsVo.class);
+        UserUtil.assignmentNickName(dailyReportCommentsVos, DailyReportComments::getCreateUser, DailyReportCommentsVo::setUserName);
+        Map<Long, List<DailyReportCommentsVo>> collect = dailyReportCommentsVos.stream().collect(Collectors.groupingBy(DailyReportComments::getReplyId));
+        for (DailyReportCommentsVo dailyReportComments : records) {
+            dailyReportComments.setReplyList(collect.get(dailyReportComments.getId()));
         }
+
         return page;
     }
 

+ 13 - 10
hx-oa/src/main/java/com/fjhx/oa/service/daily/impl/DailyReportServiceImpl.java

@@ -51,24 +51,25 @@ public class DailyReportServiceImpl extends ServiceImpl<DailyReportMapper, Daily
         IWrapper<DailyReport> wrapper = getWrapper();
         wrapper.orderByDesc("date");
         Long userid = SecurityUtils.getUserId();
-        wrapper.eq("drd", DailyReportDetails::getRecipientId, userid);
-        wrapper.eq(ObjectUtil.isNotEmpty(dto.getSenderId()), "dr.create_user", dto.getSenderId());
-        if(ObjectUtil.isNotEmpty(dto.getDate())) {
+        wrapper.eq("dr", DailyReport::getCreateUser, dto.getSenderId());
+        wrapper.groupBy("dr.id");
+
+        if (ObjectUtil.isNotEmpty(dto.getDate())) {
             wrapper.apply("date_format(dr.create_time,'%Y-%m-%d') = date_format('" + sdf.format(dto.getDate()) + "','%Y-%m-%d')");
         }
         if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
-            wrapper.and(wrapper1 -> wrapper1.like(DailyReport::getCompletedWork, dto.getKeyword())
-                    .or().like(DailyReport::getUnfinishedWork, dto.getKeyword())
-                    .or().like(DailyReport::getIsVisibleToRecipient, dto.getKeyword()));
+            wrapper.and(wrapper1 -> wrapper1.like(DailyReport::getCompletedWork, dto.getKeyword()).or().like(DailyReport::getUnfinishedWork, dto.getKeyword()).or().like(DailyReport::getIsVisibleToRecipient, dto.getKeyword()));
         }
-        if(ObjectUtil.isNotEmpty(dto.getType())) {
+        if (ObjectUtil.isNotEmpty(dto.getType())) {
             if (dto.getType() == 1) {
                 //过滤我发出的日报
                 wrapper.eq("dr.create_user", userid);
             } else if (dto.getType() == 2) {
                 //过滤我收到的日报
-                wrapper.ne("dr.create_user", userid);
+                wrapper.eq("drd", DailyReportDetails::getRecipientId, userid);
             }
+        } else {
+            wrapper.and(q -> q.eq("dr", DailyReport::getCreateUser, userid).or().eq("drd", DailyReportDetails::getRecipientId, userid));
         }
         Page<DailyReportVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         UserUtil.assignmentNickName(page.getRecords(), DailyReport::getCreateUser, DailyReportVo::setUserName);
@@ -158,12 +159,14 @@ public class DailyReportServiceImpl extends ServiceImpl<DailyReportMapper, Daily
     }
 
     @Override
-    public void share(Long id, Long toUserId) {
+    public void share(Long id, List<Long> toUserIdList) {
         String username = SecurityUtils.getUsername();
         Map<String, Object> msgMap = new HashMap<>();
         msgMap.put("businessId", id);
         msgMap.put("msg", String.format("%s给你分享了日报", username));
-        WebSocketServer.sendInfo(toUserId, 1, msgMap);
+        for (Long toUserId : toUserIdList) {
+            WebSocketServer.sendInfo(toUserId, 1, msgMap);
+        }
     }
 
 }