From 7ef4892f9f24f941aca37e6b3991b808a0aca619 Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期五, 08 九月 2023 11:16:35 +0800 Subject: [PATCH] 优化 --- ycl-platform/src/main/java/com/ycl/controller/epuipment/EquipmentBayonetController.java | 69 ++++++++++------------------------ 1 files changed, 20 insertions(+), 49 deletions(-) diff --git a/ycl-platform/src/main/java/com/ycl/controller/epuipment/EquipmentBayonetController.java b/ycl-platform/src/main/java/com/ycl/controller/epuipment/EquipmentBayonetController.java index c8b1904..59cbc6f 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/epuipment/EquipmentBayonetController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/epuipment/EquipmentBayonetController.java @@ -1,29 +1,23 @@ package com.ycl.controller.epuipment; -import com.alibaba.excel.EasyExcel; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ycl.annotation.LogSave; import com.ycl.api.CommonResult; import com.ycl.controller.BaseController; -import com.ycl.entity.dict.DataDictionary; import com.ycl.entity.equipment.EquipmentBayonet; import com.ycl.service.dict.IDataDictionaryService; import com.ycl.service.equipment.IEquipmentBayonetService; +import com.ycl.service.region.ISccgRegionService; +import com.ycl.utils.EasyExcelUtils; import com.ycl.vo.equipment.EquipmentBayonetVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.SneakyThrows; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.stream.Collectors; /** * <p> @@ -42,28 +36,19 @@ IEquipmentBayonetService iEquipmentBayonetService; @Autowired IDataDictionaryService iDataDictionaryService; + @Autowired + ISccgRegionService iSccgRegionService; @GetMapping("/query") @ApiOperation("鏌ヨ") - @LogSave + @LogSave(operationType = "鍗″彛绠$悊", contain = "鏌ヨ鍗″彛") public CommonResult search(@RequestParam(required = false) Integer size, @RequestParam(required = false) Integer current, @RequestParam(required = false) String bayonetName) { Page<EquipmentBayonet> equipmentBayonetPage = new Page<>(); equipmentBayonetPage.setCurrent(current); equipmentBayonetPage.setSize(size); - return CommonResult.success(iEquipmentBayonetService - .page(equipmentBayonetPage, new LambdaQueryWrapper<EquipmentBayonet>() - .like(StringUtils.isNotBlank(bayonetName), EquipmentBayonet::getBayonetName, bayonetName)) - .getRecords() - .stream() - .map(item -> { - EquipmentBayonetVO equipmentBayonetVO = new EquipmentBayonetVO(); - BeanUtils.copyProperties(item, equipmentBayonetVO); - equipmentBayonetVO.setFrontEndType(iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getId, item.getFrontEndType())).getName()); - equipmentBayonetVO.setInOutCityType(iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getId, item.getInOutCityType())).getName()); - return equipmentBayonetVO; - }).collect(Collectors.toList())); + return CommonResult.success(iEquipmentBayonetService.selectEquipmentPage(equipmentBayonetPage, bayonetName)); } @PostMapping("/addition") @@ -80,34 +65,20 @@ return CommonResult.success(iEquipmentBayonetService.updateById(equipmentBayonet)); } - @GetMapping("/export") - @ApiOperation("瀵煎嚭") - @SneakyThrows + @DeleteMapping("/delete/{id}") + @ApiOperation("鍒犻櫎") @LogSave(operationType = "鍗″彛绠$悊", contain = "鍒犻櫎鍗″彛") - public void export(HttpServletResponse response, - @RequestParam(required = false) Integer size, - @RequestParam(required = false) Integer current, - @RequestParam(required = false) String bayonetName) { - Page<EquipmentBayonet> equipmentBayonetPage = new Page<>(); - equipmentBayonetPage.setCurrent(current); - equipmentBayonetPage.setSize(size); - response.setContentType("application/vnd.ms-excel"); - response.setCharacterEncoding("utf-8"); - response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx"); - EasyExcel.write(response.getOutputStream(), EquipmentBayonetVO.class) - .sheet("鏁版嵁") - .doWrite(iEquipmentBayonetService - .page(equipmentBayonetPage, new LambdaQueryWrapper<EquipmentBayonet>() - .like(StringUtils.isNotBlank(bayonetName), EquipmentBayonet::getBayonetName, bayonetName)) - .getRecords() - .stream() - .map(item -> { - EquipmentBayonetVO equipmentBayonetVO = new EquipmentBayonetVO(); - BeanUtils.copyProperties(item, equipmentBayonetVO); - equipmentBayonetVO.setFrontEndType(iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getId, item.getFrontEndType())).getName()); - equipmentBayonetVO.setInOutCityType(iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getId, item.getInOutCityType())).getName()); - return equipmentBayonetVO; - }).collect(Collectors.toList())); + public CommonResult delete(@PathVariable Integer id) { + return CommonResult.success(iEquipmentBayonetService.removeById(id)); } -} + + @PostMapping("/export") + @ApiOperation("瀵煎嚭") + @SneakyThrows + @LogSave(operationType = "鍗″彛绠$悊", contain = "瀵煎嚭鍗″彛") + public void export(HttpServletResponse response, + @RequestParam(required = false) String bayonetName) { + EasyExcelUtils.export(response, "鏁版嵁", EquipmentBayonetVO.class, iEquipmentBayonetService.selectEquipmentList(bayonetName)); + } +} \ No newline at end of file -- Gitblit v1.8.0