| | |
| | | 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 com.ycl.utils.EasyExcelUtils; |
| | | import com.ycl.vo.equipment.EquipmentBayonetVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | IEquipmentBayonetService iEquipmentBayonetService; |
| | | @Autowired |
| | | IDataDictionaryService iDataDictionaryService; |
| | | @Autowired |
| | | ISccgRegionService iSccgRegionService; |
| | | |
| | | @GetMapping("/query") |
| | | @ApiOperation("查询") |
| | |
| | | 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())); |
| | | } |
| | | |
| | | @PostMapping("/addition") |
| | | @ApiOperation("添加") |
| | | @LogSave(operationType = "卡口管理",contain = "添加卡口") |
| | | @LogSave(operationType = "卡口管理", contain = "添加卡口") |
| | | public CommonResult add(@RequestBody EquipmentBayonet equipmentBayonet) { |
| | | return CommonResult.success(iEquipmentBayonetService.save(equipmentBayonet)); |
| | | } |
| | | |
| | | @PutMapping("/modification") |
| | | @ApiOperation("修改") |
| | | @LogSave(operationType = "卡口管理",contain = "修改卡口") |
| | | @LogSave(operationType = "卡口管理", contain = "修改卡口") |
| | | public CommonResult modify(@RequestBody EquipmentBayonet equipmentBayonet) { |
| | | return CommonResult.success(iEquipmentBayonetService.updateById(equipmentBayonet)); |
| | | } |
| | |
| | | @GetMapping("/export") |
| | | @ApiOperation("导出") |
| | | @SneakyThrows |
| | | @LogSave(operationType = "卡口管理",contain = "删除卡口") |
| | | @LogSave(operationType = "卡口管理", contain = "导出卡口") |
| | | public void export(HttpServletResponse response, |
| | | @RequestParam(required = false) Integer size, |
| | | @RequestParam(required = false) Integer current, |
| | |
| | | Page<EquipmentBayonet> equipmentBayonetPage = new Page<>(); |
| | | equipmentBayonetPage.setCurrent(current); |
| | | equipmentBayonetPage.setSize(size); |
| | | StringBuilder fileName = new StringBuilder(); |
| | | fileName.append(LocalDateTime.now().getYear()) |
| | | .append("-") |
| | | .append(LocalDateTime.now().getMonthValue()) |
| | | .append("-") |
| | | .append(LocalDateTime.now().getDayOfMonth()) |
| | | .append("卡口数据"); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String file = URLEncoder.encode(fileName.toString(), "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + file + ".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())); |
| | | 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())); |
| | | } |
| | | |
| | | } |
| | | } |