|
|
@@ -1,5 +1,6 @@
|
|
|
package com.ktg.iscs.controller;
|
|
|
|
|
|
+import cn.hutool.core.lang.Assert;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.ktg.common.annotation.Log;
|
|
|
@@ -19,6 +20,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.Parameters;
|
|
|
+import org.apache.commons.io.FilenameUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -38,8 +40,7 @@ import java.util.List;
|
|
|
@Api(tags = "物资")
|
|
|
@RestController
|
|
|
@RequestMapping("/iscs/materials")
|
|
|
-public class IsMaterialsController extends BaseController
|
|
|
-{
|
|
|
+public class IsMaterialsController extends BaseController {
|
|
|
@Autowired
|
|
|
private IIsMaterialsService isMaterialsService;
|
|
|
|
|
|
@@ -77,8 +78,7 @@ public class IsMaterialsController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('iscs:materials:export')")
|
|
|
@Log(title = "物资", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/exportIsMaterials")
|
|
|
- public void exportIsMaterials(HttpServletResponse response, IsMaterials isMaterials)
|
|
|
- {
|
|
|
+ public void exportIsMaterials(HttpServletResponse response, IsMaterials isMaterials) {
|
|
|
List<IsMaterials> list = isMaterialsService.selectIsMaterialsList(isMaterials);
|
|
|
ExcelUtil<IsMaterials> util = new ExcelUtil<IsMaterials>(IsMaterials.class);
|
|
|
util.exportExcel(response, list, "物资数据");
|
|
|
@@ -91,8 +91,7 @@ public class IsMaterialsController extends BaseController
|
|
|
@Parameter(name = "materialsId", description = "materialsId")
|
|
|
@PreAuthorize("@ss.hasPermi('iscs:materials:query')")
|
|
|
@GetMapping(value = "/selectIsMaterialsById")
|
|
|
- public CommonResult<IsMaterials> selectIsMaterialsById(Long materialsId)
|
|
|
- {
|
|
|
+ public CommonResult<IsMaterials> selectIsMaterialsById(Long materialsId) {
|
|
|
return CommonResult.success(isMaterialsService.selectIsMaterialsByMaterialsId(materialsId));
|
|
|
}
|
|
|
|
|
|
@@ -103,8 +102,7 @@ public class IsMaterialsController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('iscs:materials:add')")
|
|
|
@Log(title = "物资", businessType = BusinessType.INSERT)
|
|
|
@PostMapping("/insertIsMaterials")
|
|
|
- public CommonResult<Boolean> insertIsMaterials(@RequestBody @Parameter(name = "isMaterials", description = "新增数据类,放到body") IsMaterials isMaterials)
|
|
|
- {
|
|
|
+ public CommonResult<Boolean> insertIsMaterials(@RequestBody @Parameter(name = "isMaterials", description = "新增数据类,放到body") IsMaterials isMaterials) {
|
|
|
return CommonResult.success(isMaterialsService.insertIsMaterials(isMaterials) == 1);
|
|
|
}
|
|
|
|
|
|
@@ -115,8 +113,7 @@ public class IsMaterialsController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('iscs:materials:edit')")
|
|
|
@Log(title = "物资", businessType = BusinessType.UPDATE)
|
|
|
@PostMapping("/updateIsMaterials")
|
|
|
- public CommonResult<Boolean> updateIsMaterials(@RequestBody @Parameter(name = "isMaterials", description = "修改数据类,放到body") IsMaterials isMaterials)
|
|
|
- {
|
|
|
+ public CommonResult<Boolean> updateIsMaterials(@RequestBody @Parameter(name = "isMaterials", description = "修改数据类,放到body") IsMaterials isMaterials) {
|
|
|
return CommonResult.success(isMaterialsService.updateIsMaterials(isMaterials) == 1);
|
|
|
}
|
|
|
|
|
|
@@ -124,8 +121,7 @@ public class IsMaterialsController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('iscs:materials:loan')")
|
|
|
@Log(title = "借出/归还物资", businessType = BusinessType.UPDATE)
|
|
|
@PostMapping("/updateIsMaterialById")
|
|
|
- public CommonResult<Boolean> updateIsMaterialById(@RequestBody @Parameter(name = "dto", description = "修改数据类,放到body") LoanParamDTO dto)
|
|
|
- {
|
|
|
+ public CommonResult<Boolean> updateIsMaterialById(@RequestBody @Parameter(name = "dto", description = "修改数据类,放到body") LoanParamDTO dto) {
|
|
|
return CommonResult.success(isMaterialsService.updateIsMaterialById(dto));
|
|
|
}
|
|
|
|
|
|
@@ -135,17 +131,15 @@ public class IsMaterialsController extends BaseController
|
|
|
@ApiOperation("删除物资")
|
|
|
@PreAuthorize("@ss.hasPermi('iscs:materials:remove')")
|
|
|
@Log(title = "物资", businessType = BusinessType.DELETE)
|
|
|
- @PostMapping("/deleteIsMaterialsByMaterialsIds")
|
|
|
- public CommonResult<Boolean> deleteIsMaterialsByMaterialsIds(String materialsIds)
|
|
|
- {
|
|
|
+ @PostMapping("/deleteIsMaterialsByMaterialsIds")
|
|
|
+ public CommonResult<Boolean> deleteIsMaterialsByMaterialsIds(String materialsIds) {
|
|
|
return CommonResult.success(isMaterialsService.deleteIsMaterialsByMaterialsIds(materialsIds) != 0);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("导入模板-物资")
|
|
|
@Log(title = "导入模板-物资")
|
|
|
@PostMapping("/importTemplate")
|
|
|
- public void importTemplate(HttpServletResponse response)
|
|
|
- {
|
|
|
+ public void importTemplate(HttpServletResponse response) {
|
|
|
ExcelUtil<ImportMaterialsVO> util = new ExcelUtil<>(ImportMaterialsVO.class);
|
|
|
ImportMaterialsVO importMaterialsVO = new ImportMaterialsVO();
|
|
|
importMaterialsVO.setCabinetName("一号物资柜");
|
|
|
@@ -164,8 +158,11 @@ public class IsMaterialsController extends BaseController
|
|
|
@Log(title = "导入-物资", businessType = BusinessType.IMPORT)
|
|
|
@PreAuthorize("@ss.hasPermi('iscs:materials:import')")
|
|
|
@PostMapping("/importMaterials")
|
|
|
- public AjaxResult importMaterials(MultipartFile file, boolean updateSupport) throws Exception
|
|
|
- {
|
|
|
+ public AjaxResult importMaterials(MultipartFile file, boolean updateSupport) throws Exception {
|
|
|
+ String filename = file.getOriginalFilename();
|
|
|
+ String extension = FilenameUtils.getExtension(filename);
|
|
|
+ // 文件不是 .xlsx 或 .xls
|
|
|
+ Assert.isFalse(!"xls".equalsIgnoreCase(extension) && !"xlsx".equalsIgnoreCase(extension), "文件不是xls或xlsx,请重新上传!");
|
|
|
ExcelUtil<ImportMaterialsVO> util = new ExcelUtil<>(ImportMaterialsVO.class);
|
|
|
List<ImportMaterialsVO> itemList = util.importExcel(file.getInputStream());
|
|
|
String operName = getUsername();
|
|
|
@@ -177,8 +174,7 @@ public class IsMaterialsController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('iscs:materials:binding')")
|
|
|
@Log(title = "物资", businessType = BusinessType.UPDATE)
|
|
|
@PostMapping("/updateMaterialsBinding")
|
|
|
- public CommonResult<Boolean> updateMaterialsBinding(@RequestBody @Parameter(name = "dto", description = "修改数据类,放到body") MaterialBindingDTO dto)
|
|
|
- {
|
|
|
+ public CommonResult<Boolean> updateMaterialsBinding(@RequestBody @Parameter(name = "dto", description = "修改数据类,放到body") MaterialBindingDTO dto) {
|
|
|
return CommonResult.success(isMaterialsService.updateMaterialsBinding(dto));
|
|
|
}
|
|
|
}
|