| | |
| | | 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.entity.region.SccgRegion; |
| | | import com.ycl.service.dict.IDataDictionaryService; |
| | | import com.ycl.service.equipment.IEquipmentBayonetService; |
| | | import com.ycl.service.region.ISccgRegionService; |
| | |
| | | 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> |
| | |
| | | |
| | | @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()); |
| | | equipmentBayonetVO.setBelongArea(iSccgRegionService.getOne(new LambdaQueryWrapper<SccgRegion>().eq(SccgRegion::getId,item.getBelongArea())).getRegionName()); |
| | | return equipmentBayonetVO; |
| | | }).collect(Collectors.toList())); |
| | | return CommonResult.success(iEquipmentBayonetService.selectEquipmentPage(equipmentBayonetPage, bayonetName)); |
| | | } |
| | | |
| | | @PostMapping("/addition") |
| | |
| | | return CommonResult.success(iEquipmentBayonetService.updateById(equipmentBayonet)); |
| | | } |
| | | |
| | | @GetMapping("/export") |
| | | @DeleteMapping("/delete/{id}") |
| | | @ApiOperation("删除") |
| | | @LogSave(operationType = "卡口管理", contain = "删除卡口") |
| | | 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) Integer size, |
| | | @RequestParam(required = false) Integer current, |
| | | @RequestParam(required = false) String bayonetName) { |
| | | Page<EquipmentBayonet> equipmentBayonetPage = new Page<>(); |
| | | equipmentBayonetPage.setCurrent(current); |
| | | equipmentBayonetPage.setSize(size); |
| | | EasyExcelUtils.export(response,"数据",EquipmentBayonetVO.class,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())); |
| | | EasyExcelUtils.export(response, "数据", EquipmentBayonetVO.class, iEquipmentBayonetService.selectEquipmentList(bayonetName)); |
| | | } |
| | | } |