| | |
| | | import com.google.zxing.Result; |
| | | import com.google.zxing.client.j2se.BufferedImageLuminanceSource; |
| | | import com.google.zxing.common.HybridBinarizer; |
| | | import com.whyc.dto.Response; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.imageio.ImageIO; |
| | |
| | | @Service |
| | | public class QRCodeService { |
| | | |
| | | |
| | | @Autowired |
| | | private BattRTStateService battRTStateService; |
| | | |
| | | public String extract(byte[] data) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | public Response extractAndGetData(byte[] data) { |
| | | String battGroupId = extract(data); |
| | | return battRTStateService.getOneByBattGroupId(battGroupId); |
| | | } |
| | | |
| | | public static String test() { |
| | | try { |
| | | //InputStream inputStream = new ByteArrayInputStream(data); |
| | | InputStream inputStream = new FileInputStream("C:\\code\\web\\InspectionSystem\\src\\main\\resources\\lib\\t5.jpg"); |
| | | InputStream inputStream = new FileInputStream("C:\\code\\web\\InspectionSystem\\src\\main\\resources\\lib\\t11.jpg"); |
| | | BufferedImage bufferedImage = ImageIO.read(inputStream); |
| | | BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(bufferedImage))); |
| | | Result result = new MultiFormatReader().decode(binaryBitmap); |
| | |
| | | public static void main(String[] args) { |
| | | System.out.println(test()); |
| | | } |
| | | |
| | | |
| | | } |