Barcode 리더 사용시 바코드 정보 parsing -> 제품코드, 제조번호, 유효기간, 제품일련번호

dev
Jonguk. Lim 6 months ago
parent 4d39716bcb
commit 3f2228f1f5

@ -248,8 +248,12 @@ public class BizNimsResponse {
/**
* <pre>
* 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
* </pre>

@ -61,8 +61,9 @@ public interface BizNimsService {
BizNimsRequest.DsuseMgt saveDsuseMgt(BizNimsRequest.DsuseMgt dto);
List<BizNimsResponse.DsuseMgtRes> getDsuseMgts(BizNimsRequest.DsuseMgtInq dto);
NimsApiDto.ProductInfoKd getPrdMnfSeqInfoOfBarcode(final String barcodeStr);
// @Deprecated
// @Deprecated
// List<BizNimsResponse.DsuseRptInfoResponse> saveDsuseMgts(List<BizNimsRequest.DsuseMgt> dtos);

@ -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<NimsApiDto.ProductInfoKd> 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);
}
/**
* <pre>

@ -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 제품 제조 정보 조회<br><br>Barcode를 통한 제품 제조 정보 조회<br><br>ex) 01088065780457311717050110A1234210000000006")
@GetMapping(value = "/getPrdMnfSeqInfoOfBarcode")
public ApiBaseResponse<NimsApiDto.ProductInfoKd> getPrdMnfSeqInfoOfBarcode(
final String barcodeStr
) {
return ApiBaseResponse.of(bizNimsService.getPrdMnfSeqInfoOfBarcode(barcodeStr));
}
@Operation(summary = "barcode 이미지 제품 제조 정보 조회", description = "barcode 이미지 제품 제조 정보 조회<br><br>barcode 이미지를 통한 제품 제조 정보 조회")
@PostMapping(value = "/getProductInfoByQrcodeImg", consumes = { "multipart/form-data" })
//@PostMapping(value = "/api/biz/nims/v1/getQrcode")
public ApiBaseResponse<List<NimsApiDto.ProductInfoKd>> getProductInfoByQrcodeImg(
@RequestParam("uploadFiles")
final List<MultipartFile> multipartFiles
) {
List<NimsApiDto.ProductInfoKd> 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);
}

@ -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;
/**
* <pre>
* description :
*
* packageName : cokr.xit.adds.biz.web
* fileName : QrController
* author : limju
* date : 2024-04-01
* ======================================================================
*
* ----------------------------------------------------------------------
* 2024-04-01 limju
*
* </pre>
*/
@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<NimsApiDto.MnfSeqInfo> uploadQrCode(
@RequestParam("uploadFiles")
final List<MultipartFile> multipartFiles
) {
List<NimsApiDto.MnfSeqInfo> mnfSeqInfos = new ArrayList<>();
List<Map<String, String>> list = multipartFiles.stream().map(mf -> {
System.out.println(mf.getOriginalFilename());
System.out.println(mf.getSize());
Map<String, String> 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<String,String> map: list){
System.out.println(map.get("qrcode"));
BizNimsResponse.Barcode barcode = new BizNimsResponse.Barcode();
mnfSeqInfos.add(barcode.parseBarcode(map.get("qrcode")));
}
return mnfSeqInfos;
}
}

@ -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();
}

@ -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: () => {

Loading…
Cancel
Save