| | |
| | | package com.ruoyi.management.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.util.UUIDUtils; |
| | | import com.alibaba.nacos.common.utils.UuidUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.ruoyi.management.service.SlVolumeProductionRkService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.management.service.SlVolumeProductionRkglService; |
| | | import com.ruoyi.management.util.ObsUploadUtil; |
| | | import com.ruoyi.management.util.QRCodeUtil; |
| | | import com.ruoyi.management.util.UUIDUtil; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import org.apache.logging.log4j.core.util.UuidUtil; |
| | | import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream; |
| | | import org.springframework.core.io.ByteArrayResource; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.imageio.ImageIO; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.sql.Array; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<QRCodeVO> codeInfo(Long id) { |
| | | public List<QRCodeVO> codeInfo(Long id) throws Exception { |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | List<QRCodeVO> res = new ArrayList<>(); |
| | | LambdaQueryWrapper< SlVolumeProductionRk> wrapper1= Wrappers.lambdaQuery(); |
| | |
| | | for (SlVolumeProductionRk byId : list) { |
| | | // 根据生成二维码数量 复制 |
| | | for (int i = 0; i < byId.getErwmNum(); i++) { |
| | | String blueS = "{\"rkNumber\": "+byId.getRkNumber()+"}"; |
| | | BufferedImage blueImage = QRCodeUtil.createImage(blueS); |
| | | MultipartFile blueFile = convert(blueImage, new Date().getTime() + UUIDUtil.getRandomCode(3) + ".PNG"); |
| | | // 生成的二维码连接 |
| | | String s = ObsUploadUtil.obsUpload(blueFile); |
| | | QRCodeVO vo=new QRCodeVO(); |
| | | String letter = getLetter(i); |
| | | vo.setCategory(letter); |
| | |
| | | vo.setMaterials(byId.getRkNumber()); |
| | | SlStoreManagement slStoreManagement = slStoreManagementMapper.selectById(byId.getManagementId()); |
| | | vo.setStoreManagementName(slStoreManagement.getStoreManagementName()); |
| | | vo.setQrCode(s); |
| | | res.add(vo); |
| | | } |
| | | |
| | |
| | | return res; |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | String blueS = "{\"rkNumber\": CD-1721989472748"+"}"; |
| | | BufferedImage blueImage = QRCodeUtil.createImage(blueS); |
| | | MultipartFile blueFile = convert(blueImage, new Date().getTime() + UUIDUtil.getRandomCode(3) + ".PNG"); |
| | | // 生成的二维码连接 |
| | | String s = ObsUploadUtil.obsUpload(blueFile); |
| | | System.err.println(s); |
| | | } |
| | | public static MultipartFile convert(BufferedImage bufferedImage, String fileName) throws IOException { |
| | | // 将 BufferedImage 转换为字节数组 |
| | | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | | ImageIO.write(bufferedImage, "png", baos); |
| | | byte[] bytes = baos.toByteArray(); |
| | | |
| | | // 创建 ByteArrayResource |
| | | ByteArrayResource resource = new ByteArrayResource(bytes); |
| | | |
| | | // 创建 MockMultipartFile |
| | | MockMultipartFile multipartFile = new MockMultipartFile( |
| | | "file", |
| | | fileName, |
| | | "image/png", |
| | | resource.getInputStream() |
| | | ); |
| | | |
| | | return multipartFile; |
| | | } |
| | | // 根据传入数字是几 返回对应的字母 |
| | | public static String getLetter(int num) { |
| | | String[] str = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; |