|
@@ -1,7 +1,9 @@
|
|
|
package com.ozs.web.controller.base;
|
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.excel.ExcelWriter;
|
|
|
+import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ozs.base.domain.BaseExpert;
|
|
|
import com.ozs.base.domain.BaseProfessional;
|
|
@@ -15,19 +17,23 @@ import com.ozs.common.core.controller.BaseController;
|
|
|
import com.ozs.common.core.domain.AjaxResult;
|
|
|
import com.ozs.common.core.domain.model.LoginUser;
|
|
|
import com.ozs.common.enums.BusinessType;
|
|
|
+import com.ozs.common.exception.base.BaseException;
|
|
|
import com.ozs.common.utils.PageUtils;
|
|
|
import com.ozs.common.utils.StringUtils;
|
|
|
import com.ozs.common.utils.bean.BeanUtils;
|
|
|
import com.ozs.common.utils.poi.ExcelUtil;
|
|
|
+import com.ozs.plan.doman.vo.responseVo.PlanYearsResponseVo;
|
|
|
import com.ozs.system.domain.vo.SysRegionVO;
|
|
|
import com.ozs.system.service.ISysDictDataService;
|
|
|
import com.ozs.system.service.SysRegionService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.joda.time.DateTime;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -35,7 +41,12 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -47,6 +58,7 @@ import java.util.stream.Collectors;
|
|
|
* @author sunhh
|
|
|
*/
|
|
|
@Api(tags = "专家库管理")
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/base/expert")
|
|
|
public class BaseExpertController extends BaseController {
|
|
@@ -61,7 +73,7 @@ public class BaseExpertController extends BaseController {
|
|
|
private ISysDictDataService dictDataService;
|
|
|
|
|
|
|
|
|
- @ApiOperation(value = "新增专家库" , notes = "必传 专家库名称")
|
|
|
+ @ApiOperation(value = "新增专家库", notes = "必传 专家库名称")
|
|
|
@PostMapping("/insertExpert")
|
|
|
@PreAuthorize("@ss.hasPermi('base:expert:insertExpert')")
|
|
|
@Log(title = ModularConstans.expert, businessType = BusinessType.INSERT)
|
|
@@ -247,4 +259,38 @@ public class BaseExpertController extends BaseController {
|
|
|
}
|
|
|
return baseExpertService.selectExtractionExpert(baseExpertVo);
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation("模板下载")
|
|
|
+ @GetMapping("/downloaExcel")
|
|
|
+ public void downloadZip(HttpServletResponse response) {
|
|
|
+ List<BaseExpertVo> list = new ArrayList<BaseExpertVo>();
|
|
|
+ list.add(new BaseExpertVo("张先生", "法务专家", "男",
|
|
|
+ "2023-07-06", "15152223667", "安全工程03",
|
|
|
+ "科室一", "高级职称", "天津市/河东区", "050050101"
|
|
|
+ ));
|
|
|
+ list.add(new BaseExpertVo("李先生", "经济专家", "女",
|
|
|
+ "2023-07-06", "14448485656", "测试工程07",
|
|
|
+ "科室二", "中级职称", "山西省/阳泉市/平定县", "41133535035"
|
|
|
+ ));
|
|
|
+ InputStream resourceAsStream = this.getClass().getResourceAsStream("/template/base_expert.xlsx");
|
|
|
+ OutputStream outputStream = null;
|
|
|
+ try {
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+
|
|
|
+ String fileName = URLEncoder.encode("专家信息(模板)", "UTF-8").replaceAll("\\+", "%20");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
|
|
+ outputStream = response.getOutputStream();
|
|
|
+ ExcelWriter excelWriter = EasyExcel.write(outputStream)
|
|
|
+ .withTemplate(resourceAsStream).autoCloseStream(true).build();
|
|
|
+ WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
|
|
+ excelWriter.fill(list, writeSheet);
|
|
|
+ excelWriter.finish();
|
|
|
+ outputStream.flush();
|
|
|
+ outputStream.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ throw new BaseException("下载异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|