From 3f2228f1f519312fb5548174c44912d08b11ceab Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Mon, 13 May 2024 15:47:17 +0900 Subject: [PATCH] =?UTF-8?q?Barcode=20=EB=A6=AC=EB=8D=94=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=8B=9C=20=EB=B0=94=EC=BD=94=EB=93=9C=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20parsing=20->=20=EC=A0=9C=ED=92=88=EC=BD=94=EB=93=9C?= =?UTF-8?q?,=20=EC=A0=9C=EC=A1=B0=EB=B2=88=ED=98=B8,=20=EC=9C=A0=ED=9A=A8?= =?UTF-8?q?=EA=B8=B0=EA=B0=84,=20=EC=A0=9C=ED=92=88=EC=9D=BC=EB=A0=A8?= =?UTF-8?q?=EB=B2=88=ED=98=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adds/biz/nims/model/BizNimsResponse.java | 6 +- .../adds/biz/nims/service/BizNimsService.java | 3 +- .../nims/service/bean/BizNimsServiceBean.java | 18 +++++ .../adds/biz/nims/web/BizNimsController.java | 34 ++++++++- .../xit/adds/biz/nims/web/QrController.java | 75 ------------------- .../core/spring/config/SpringDocsConfig.java | 6 +- src/main/resources/static/zxing/index.html | 2 +- 7 files changed, 63 insertions(+), 81 deletions(-) delete mode 100644 src/main/java/cokr/xit/adds/biz/nims/web/QrController.java diff --git a/src/main/java/cokr/xit/adds/biz/nims/model/BizNimsResponse.java b/src/main/java/cokr/xit/adds/biz/nims/model/BizNimsResponse.java index 025a2b5..9791756 100644 --- a/src/main/java/cokr/xit/adds/biz/nims/model/BizNimsResponse.java +++ b/src/main/java/cokr/xit/adds/biz/nims/model/BizNimsResponse.java @@ -248,8 +248,12 @@ public class BizNimsResponse { /** *
 		 * 바코드 reader 사용시 - Barcode(GS1-128) 정보 파싱
-		 * 상품코드, 제조번호, 유효기간, 제조일련번호
+		 * 최소 30자리 이상
+		 * AI상품식별코드(2) + 상품코드(14) + AI최대유통일자(2) + 유통일자(6) + AI로트번호(2) + 제조번호(1) + AI일련번호(2) + 제품일련번호(1)
+		 * -> 상품코드(확장코드(1) + 상품코드(13)), 제조번호(1), 제품일련번호(1) 은 필수로 포함한다는 가정
+		 * -> 상품코드, 제조번호, 유효기간, 제조일련번호 정보 추출
 		 *
+		 * ex) 01088065780457311717050110A1234210000000006
 		 * @param barcodeStr
 		 * @return NimsApiDto.MnfSeqInfo
 		 * 
diff --git a/src/main/java/cokr/xit/adds/biz/nims/service/BizNimsService.java b/src/main/java/cokr/xit/adds/biz/nims/service/BizNimsService.java index c909364..7ce4876 100644 --- a/src/main/java/cokr/xit/adds/biz/nims/service/BizNimsService.java +++ b/src/main/java/cokr/xit/adds/biz/nims/service/BizNimsService.java @@ -61,8 +61,9 @@ public interface BizNimsService { BizNimsRequest.DsuseMgt saveDsuseMgt(BizNimsRequest.DsuseMgt dto); List getDsuseMgts(BizNimsRequest.DsuseMgtInq dto); + NimsApiDto.ProductInfoKd getPrdMnfSeqInfoOfBarcode(final String barcodeStr); - // @Deprecated + // @Deprecated // List saveDsuseMgts(List dtos); diff --git a/src/main/java/cokr/xit/adds/biz/nims/service/bean/BizNimsServiceBean.java b/src/main/java/cokr/xit/adds/biz/nims/service/bean/BizNimsServiceBean.java index 3242fc1..c3d73ba 100644 --- a/src/main/java/cokr/xit/adds/biz/nims/service/bean/BizNimsServiceBean.java +++ b/src/main/java/cokr/xit/adds/biz/nims/service/bean/BizNimsServiceBean.java @@ -372,7 +372,25 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe return resList; } + @Override + public NimsApiDto.ProductInfoKd getPrdMnfSeqInfoOfBarcode(final String barcodeStr) { + NimsApiDto.MnfSeqInfo mnfSeqInfo = new BizNimsResponse.Barcode().parseBarcode(barcodeStr); + + NimsApiRequest.ProductInfoReq prdReq = NimsApiRequest.ProductInfoReq.builder() + .fg("1") + .pg("1") + .p(mnfSeqInfo.getPrductCd()) + .dbSkipYn("N") + .build(); + List productInfoKds = saveProductInfoKd(prdReq, false); + if(productInfoKds.size() != 1) { + throw ApiCustomException.create(String.format("제품정보 오류[Barcode 상품[%s] 데이타 확인이 필요 합니다.]", mnfSeqInfo.getPrductCd())); + } + mnfSeqInfo.setPrductNm(productInfoKds.get(0).getPrductNm()); + productInfoKds.get(0).getMnfSeqInfos().add(mnfSeqInfo); + return productInfoKds.get(0); + } /** *
diff --git a/src/main/java/cokr/xit/adds/biz/nims/web/BizNimsController.java b/src/main/java/cokr/xit/adds/biz/nims/web/BizNimsController.java
index 2cdf269..bb3a7cf 100644
--- a/src/main/java/cokr/xit/adds/biz/nims/web/BizNimsController.java
+++ b/src/main/java/cokr/xit/adds/biz/nims/web/BizNimsController.java
@@ -1,17 +1,24 @@
 package cokr.xit.adds.biz.nims.web;
 
+import java.io.IOException;
 import java.util.List;
 
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import com.google.zxing.NotFoundException;
 
 import cokr.xit.adds.biz.nims.model.BizNimsRequest;
 import cokr.xit.adds.biz.nims.model.BizNimsResponse;
 import cokr.xit.adds.biz.nims.service.BizNimsService;
 import cokr.xit.adds.core.model.ApiBaseResponse;
+import cokr.xit.adds.core.util.XingUtils;
 import cokr.xit.adds.inf.nims.model.NimsApiDto;
 import cokr.xit.adds.inf.nims.model.NimsApiRequest;
 import io.swagger.v3.oas.annotations.Operation;
@@ -146,8 +153,33 @@ public class BizNimsController {
     }
 
 
+    @Operation(summary = "barcode string 제품 제조 정보 조회", description = "barcode string 제품 제조 정보 조회

Barcode를 통한 제품 제조 정보 조회

ex) 01088065780457311717050110A1234210000000006") + @GetMapping(value = "/getPrdMnfSeqInfoOfBarcode") + public ApiBaseResponse getPrdMnfSeqInfoOfBarcode( + final String barcodeStr + ) { + return ApiBaseResponse.of(bizNimsService.getPrdMnfSeqInfoOfBarcode(barcodeStr)); + } - + @Operation(summary = "barcode 이미지 제품 제조 정보 조회", description = "barcode 이미지 제품 제조 정보 조회

barcode 이미지를 통한 제품 제조 정보 조회") + @PostMapping(value = "/getProductInfoByQrcodeImg", consumes = { "multipart/form-data" }) + //@PostMapping(value = "/api/biz/nims/v1/getQrcode") + public ApiBaseResponse> getProductInfoByQrcodeImg( + @RequestParam("uploadFiles") + final List multipartFiles + ) { + List list = multipartFiles.stream().map(mf -> { + //System.out.println(mf.getOriginalFilename()); + //System.out.println(mf.getSize()); + try { + return bizNimsService.getPrdMnfSeqInfoOfBarcode(XingUtils.readQrcodeFromFile(XingUtils.convert(mf))); + } catch (IOException | NotFoundException e) { + throw new RuntimeException(e); + } + }).toList(); + + return ApiBaseResponse.of(list); + } diff --git a/src/main/java/cokr/xit/adds/biz/nims/web/QrController.java b/src/main/java/cokr/xit/adds/biz/nims/web/QrController.java deleted file mode 100644 index 0d35701..0000000 --- a/src/main/java/cokr/xit/adds/biz/nims/web/QrController.java +++ /dev/null @@ -1,75 +0,0 @@ -package cokr.xit.adds.biz.nims.web; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.ModelAndView; - -import com.google.zxing.NotFoundException; - -import cokr.xit.adds.biz.nims.model.BizNimsResponse; -import cokr.xit.adds.core.util.XingUtils; -import cokr.xit.adds.inf.nims.model.NimsApiDto; -import io.swagger.v3.oas.annotations.tags.Tag; - -/** - *
- * description : 
- *
- * packageName : cokr.xit.adds.biz.web
- * fileName    : QrController
- * author      : limju
- * date        : 2024-04-01
- * ======================================================================
- * 변경일         변경자        변경 내용
- * ----------------------------------------------------------------------
- * 2024-04-01    limju       최초 생성
- *
- * 
- */ -@Tag(name = "QrController", description = "qrcode API") -@RestController -public class QrController { - - @GetMapping("/api/biz/nims/v1/qrcodeForm") - public ModelAndView qrcodeForm() { - return new ModelAndView("/zxing/index.html"); - } - - @PostMapping(value = "/api/biz/nims/v1/getQrcode", consumes = { "multipart/form-data" }) - public List uploadQrCode( - @RequestParam("uploadFiles") - final List multipartFiles - ) { - List mnfSeqInfos = new ArrayList<>(); - - List> list = multipartFiles.stream().map(mf -> { - System.out.println(mf.getOriginalFilename()); - System.out.println(mf.getSize()); - Map map = new HashMap<>(); - try { - map.put("qrcode", XingUtils.readQrcodeFromFile(XingUtils.convert(mf))); - map.put("name", mf.getOriginalFilename()); - } catch (IOException | NotFoundException e) { - throw new RuntimeException(e); - } - return map; - }).toList(); - - for(Map map: list){ - System.out.println(map.get("qrcode")); - - BizNimsResponse.Barcode barcode = new BizNimsResponse.Barcode(); - mnfSeqInfos.add(barcode.parseBarcode(map.get("qrcode"))); - } - return mnfSeqInfos; - } -} diff --git a/src/main/java/cokr/xit/adds/core/spring/config/SpringDocsConfig.java b/src/main/java/cokr/xit/adds/core/spring/config/SpringDocsConfig.java index 8a0540f..0555d4c 100644 --- a/src/main/java/cokr/xit/adds/core/spring/config/SpringDocsConfig.java +++ b/src/main/java/cokr/xit/adds/core/spring/config/SpringDocsConfig.java @@ -95,7 +95,8 @@ public class SpringDocsConfig { .group("2. BIZ API interface") .pathsToMatch( "/api/biz/nims/**", - "/api/biz/iros/**" + "/api/biz/iros/**", + "/api/biz/mois/**" ) .build(); } @@ -106,7 +107,8 @@ public class SpringDocsConfig { .group("3. Interface API") .pathsToMatch( "/api/inf/nims/**", - "/api/inf/iros/**" + "/api/inf/iros/**", + "/api/inf/mois/**" ) .build(); } diff --git a/src/main/resources/static/zxing/index.html b/src/main/resources/static/zxing/index.html index 3e95561..f4ab801 100644 --- a/src/main/resources/static/zxing/index.html +++ b/src/main/resources/static/zxing/index.html @@ -169,7 +169,7 @@ document.getElementById('result').textContent = '' requestSubmit({ - url: '/biz/nims/v1/getQrcode', + url: '/api/biz/nims/v1/getProductInfoByQrcodeImg', method: 'POST', data: formData, progress: () => {