|
@@ -3,19 +3,23 @@ package com.ozs.web.controller.base;
|
|
|
import com.ozs.base.domain.BaseProfessional;
|
|
|
import com.ozs.base.domain.vo.BaseProfessionalVo;
|
|
|
import com.ozs.base.service.BaseProfessionalService;
|
|
|
+import com.ozs.common.config.PurchaseConfig;
|
|
|
import com.ozs.common.core.controller.BaseController;
|
|
|
import com.ozs.common.core.domain.AjaxResult;
|
|
|
import com.ozs.common.core.domain.R;
|
|
|
import com.ozs.common.core.domain.model.LoginUser;
|
|
|
import com.ozs.common.exception.ServiceException;
|
|
|
import com.ozs.common.utils.StringUtils;
|
|
|
+import com.ozs.common.utils.file.FileUtils;
|
|
|
import com.ozs.common.utils.poi.ExcelUtil;
|
|
|
import com.ozs.plan.doman.ProvisionalPlan;
|
|
|
import com.ozs.plan.doman.vo.requestVo.ProvisionalPlanVo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
@@ -35,12 +39,13 @@ import java.util.List;
|
|
|
@Api(tags = "专业库管理")
|
|
|
@RestController
|
|
|
@RequestMapping("/base/professional")
|
|
|
+@Slf4j
|
|
|
public class BaseProfessionalController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private BaseProfessionalService baseProfessionalService;
|
|
|
|
|
|
- @ApiOperation(value = "新增专业库", notes = "必传 专业库名称、一级分类、编码、父级编码;没有父级编码传0")
|
|
|
+ @ApiOperation(value = "新增专业库" , notes = "必传 专业库名称、一级分类、编码、父级编码;没有父级编码传0")
|
|
|
@PostMapping("/insertProfessional")
|
|
|
public AjaxResult insertProfessional(@RequestBody BaseProfessional baseProfessional) {
|
|
|
if (StringUtils.isNull(baseProfessional)
|
|
@@ -53,7 +58,7 @@ public class BaseProfessionalController extends BaseController {
|
|
|
return toAjax(baseProfessionalService.save(baseProfessional));
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "删除专业库", notes = "必传 id")
|
|
|
+ @ApiOperation(value = "删除专业库" , notes = "必传 id")
|
|
|
@PostMapping("/deleteProfessional")
|
|
|
public AjaxResult deleteProfessional(@RequestBody BaseProfessional baseProfessional) {
|
|
|
if (StringUtils.isNull(baseProfessional) || StringUtils.isNull(baseProfessional.getId())) {
|
|
@@ -62,14 +67,14 @@ public class BaseProfessionalController extends BaseController {
|
|
|
return toAjax(baseProfessionalService.removeById(baseProfessional.getId()));
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "批量删除专业库", notes = "必传 idList")
|
|
|
+ @ApiOperation(value = "批量删除专业库" , notes = "必传 idList")
|
|
|
@PostMapping("/deleteIds")
|
|
|
public AjaxResult deleteByIdLIst(@RequestBody BaseProfessionalVo baseProfessionalVo) {
|
|
|
baseProfessionalService.deleteIds(baseProfessionalVo.getDeleteIds());
|
|
|
return success();
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "修改专业库", notes = "必传 id 及修改数据")
|
|
|
+ @ApiOperation(value = "修改专业库" , notes = "必传 id 及修改数据")
|
|
|
@PostMapping("/updateProfessional")
|
|
|
public AjaxResult updateProfessional(@RequestBody BaseProfessional baseProfessional) {
|
|
|
if (StringUtils.isNull(baseProfessional) || StringUtils.isNull(baseProfessional.getId())) {
|
|
@@ -78,14 +83,14 @@ public class BaseProfessionalController extends BaseController {
|
|
|
return toAjax(baseProfessionalService.updateById(baseProfessional));
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "查询专业库树结构", notes = "非必传 查询条件:品目名称")
|
|
|
+ @ApiOperation(value = "查询专业库树结构" , notes = "非必传 查询条件:品目名称")
|
|
|
@PostMapping("/selectBaseProfessional")
|
|
|
public AjaxResult selectBaseProfessional(@RequestBody BaseProfessionalVo baseProfessionalVo) {
|
|
|
List<BaseProfessionalVo> baseSupplierList = baseProfessionalService.selectBaseProfessionalVo(baseProfessionalVo);
|
|
|
return success(baseSupplierList);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "导入专业库", notes = "导入表格")
|
|
|
+ @ApiOperation(value = "导入专业库" , notes = "导入表格")
|
|
|
@PostMapping("/importBaseProfessional")
|
|
|
public AjaxResult importBaseProfessional(MultipartFile file, boolean updateSupport) throws Exception {
|
|
|
ExcelUtil<BaseProfessional> util = new ExcelUtil<>(BaseProfessional.class);
|
|
@@ -108,10 +113,21 @@ public class BaseProfessionalController extends BaseController {
|
|
|
|
|
|
@ApiOperation("文件下载")
|
|
|
@GetMapping("/downloaExcel")
|
|
|
- public AjaxResult downloadZip(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- // 文件路径
|
|
|
- String downloadPath = "/Users/sunhuanhuan/Documents/project/106/project/purchase/purchase-admin/专业库模板.xlsx";
|
|
|
- // 下载文件
|
|
|
- return baseProfessionalService.downloadPathFile(downloadPath, request, response);
|
|
|
+ public void downloadZip(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ try {
|
|
|
+ // 文件路径
|
|
|
+ String downloadPath = Class.class.getClass().getResource("/").getPath() + "template/专业库模板.xlsx";
|
|
|
+ // 下载文件
|
|
|
+ String realFileName = "专业库模板.xlsx";
|
|
|
+ String filePath = downloadPath;
|
|
|
+ response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
+ FileUtils.setAttachmentResponseHeader(response, realFileName);
|
|
|
+ FileUtils.writeBytes(filePath, response.getOutputStream());
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("下载文件失败" , e);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|