| | |
| | | package com.dy.pmsPlatform.station; |
| | | |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.dy.common.aop.SsoPowerAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pmsGlobal.aop.Log; |
| | | import com.dy.pmsGlobal.pojoPlt.PltStation; |
| | | import com.dy.pmsGlobal.util.QrCodeUtil; |
| | | import com.google.zxing.WriterException; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | @RequestMapping(path="station") |
| | | @SuppressWarnings("unchecked") |
| | | public class StationCtrl { |
| | | private static final String fileName = "工站信息" ; |
| | | private static final String sheetName = "工站信息" ; |
| | | private static final String stationPrefix = "103" ; |
| | | private StationSv sv; |
| | | @Autowired |
| | | public StationCtrl(StationSv sv){ |
| | |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | | } |
| | | @PostMapping(path="export") |
| | | @SsoPowerAop(power = "10300000") |
| | | @Log("导出工站信息") |
| | | public void export(HttpServletResponse response){ |
| | | try{ |
| | | List<Converter> list = new ArrayList<>() ; |
| | | |
| | | List<PltStation> stations = sv.selectAll(); |
| | | // 使用并行流提高性能 |
| | | stations.parallelStream().forEach(station -> { |
| | | ExcelVo vo = new ExcelVo(); |
| | | vo.name = station.name; |
| | | // vo.code = "103"+station.id; |
| | | vo.lineName = station.lineName; |
| | | try { |
| | | vo.qrCode = QrCodeUtil.genQrCode(stationPrefix+station.id); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } catch (WriterException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | list.add(vo); |
| | | }); |
| | | QrCodeUtil.downloadExcel(response, fileName,sheetName,list); |
| | | }catch (Exception e){ |
| | | log.error("导出产品信息异常", e); |
| | | } |
| | | } |
| | | } |
| | | |