提交修改
This commit is contained in:
parent
a44f593a59
commit
e7416df154
@ -48,6 +48,14 @@ public class BWaybillResp extends BBaseResp {
|
||||
@JsonProperty("sender_phone")
|
||||
private List<SenderPhoneDTO> senderPhone;
|
||||
|
||||
@JsonProperty("virtual_number")
|
||||
private List<SenderPhoneDTO> virtualNumber;
|
||||
@JsonProperty("virtual_number_last")
|
||||
private List<SenderPhoneDTO> virtualNumberLast;
|
||||
@JsonProperty("is_virtual_waybill")
|
||||
private List<SenderPhoneDTO> isVirtualWaybill;
|
||||
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class ImageInfoDTO {
|
||||
|
||||
@ -0,0 +1,180 @@
|
||||
package com.heyu.api.controller.traffic;
|
||||
|
||||
|
||||
import com.heyu.api.baidu.handle.traffic.BWaybillHandle;
|
||||
import com.heyu.api.baidu.request.traffic.BWaybillRequest;
|
||||
import com.heyu.api.baidu.response.traffic.BWaybillResp;
|
||||
import com.heyu.api.controller.BaseController;
|
||||
import com.heyu.api.data.annotation.CacheResult;
|
||||
import com.heyu.api.data.annotation.CustomPath;
|
||||
import com.heyu.api.data.utils.ApiR;
|
||||
import com.heyu.api.data.utils.R;
|
||||
import com.heyu.api.resp.traffic.WaybillResp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* https://console.bce.baidu.com/support/?_=1740411162437×tamp=1740412723534#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E4%BA%A4%E9%80%9A%E5%9C%BA%E6%99%AFOCR&api=rest%2F2.0%2Focr%2Fv1%2Fwaybill&method=post
|
||||
* 快递面单识别
|
||||
*
|
||||
*
|
||||
* 接口描述
|
||||
* 支持市面上常见版式的快递面单识别,包括申通/圆通/中通/百世汇通/韵达/顺丰/京东/邮政/极兔/天天等面单版式,结构化识别运单号、收/寄件人姓名、收/寄件人电话、收/寄件人地址等字段。同时支持识别隐私面单。
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@CustomPath("waybill")
|
||||
public class WaybillController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private BWaybillHandle bWaybillHandle;
|
||||
|
||||
|
||||
@RequestMapping("/recognize")
|
||||
@CacheResult
|
||||
public R recognize(BWaybillRequest request) {
|
||||
|
||||
List<WaybillResp> respList = new ArrayList<>();
|
||||
|
||||
|
||||
ApiR<BWaybillResp> bR = bWaybillHandle.handle(request);
|
||||
if (bR.isSuccess()) {
|
||||
|
||||
BWaybillResp bWaybillResp = bR.getData();
|
||||
if (CollectionUtils.isNotEmpty(bWaybillResp.getWordsResult())) {
|
||||
for (BWaybillResp.WordsResultDTO wordsResultDTO : bWaybillResp.getWordsResult()) {
|
||||
WaybillResp resp = new WaybillResp();
|
||||
|
||||
resp.setImageInfo(wordsResultDTO.getImageInfo().getDirection()); // 图像四方向
|
||||
|
||||
List<String> barCode = new ArrayList<>(); //条形码
|
||||
|
||||
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getBarCode())) {
|
||||
for (BWaybillResp.WordsResultDTO.BarCodeDTO barCodeDTO : wordsResultDTO.getBarCode()) {
|
||||
|
||||
barCode.add(barCodeDTO.getWord());
|
||||
}
|
||||
}
|
||||
resp.setBarCode(barCode);
|
||||
|
||||
List<String> waybillNumber = new ArrayList<>(); //快递运单号
|
||||
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getWaybillNumber())) {
|
||||
for (BWaybillResp.WordsResultDTO.WaybillNumberDTO waybillNumberDTO : wordsResultDTO.getWaybillNumber()) {
|
||||
waybillNumber.add(waybillNumberDTO.getWord());
|
||||
}
|
||||
}
|
||||
resp.setWaybillNumber(waybillNumber);
|
||||
|
||||
List<String> threeSegmentCode = new ArrayList<>(); //三段码
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getThreeSegmentCode())) {
|
||||
for (BWaybillResp.WordsResultDTO.ThreeSegmentCodeDTO threeSegmentCodeDTO : wordsResultDTO.getThreeSegmentCode()) {
|
||||
threeSegmentCode.add(threeSegmentCodeDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setThreeSegmentCode(threeSegmentCode);
|
||||
|
||||
List<String> recipientName = new ArrayList<>(); //收件人姓名
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getRecipientName())) {
|
||||
for (BWaybillResp.WordsResultDTO.RecipientNameDTO recipientNameDTO : wordsResultDTO.getRecipientName()) {
|
||||
recipientName.add(recipientNameDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setRecipientName(recipientName);
|
||||
|
||||
List<String> senderName = new ArrayList<>(); //寄件人姓名
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getSenderName())) {
|
||||
for (BWaybillResp.WordsResultDTO.SenderNameDTO senderNameDTO : wordsResultDTO.getSenderName()) {
|
||||
senderName.add(senderNameDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setSenderName(senderName);
|
||||
|
||||
List<String> recipientAddr = new ArrayList<>(); //收件人地址
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getRecipientAddr())) {
|
||||
for (BWaybillResp.WordsResultDTO.RecipientAddrDTO recipientAddrDTO : wordsResultDTO.getRecipientAddr()) {
|
||||
recipientAddr.add(recipientAddrDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setRecipientAddr(recipientAddr);
|
||||
|
||||
List<String> senderAddr = new ArrayList<>(); //寄件人地址
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getSenderAddr())) {
|
||||
for (BWaybillResp.WordsResultDTO.SenderAddrDTO senderAddrDTO : wordsResultDTO.getSenderAddr()) {
|
||||
senderAddr.add(senderAddrDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
resp.setSenderAddr(senderAddr);
|
||||
|
||||
|
||||
List<String> recipientPhone = new ArrayList<>(); //收件人电话
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getRecipientPhone())) {
|
||||
for (BWaybillResp.WordsResultDTO.RecipientPhoneDTO recipientPhoneDTO : wordsResultDTO.getRecipientPhone()) {
|
||||
recipientPhone.add(recipientPhoneDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setRecipientPhone(recipientPhone);
|
||||
|
||||
|
||||
List<String> senderPhone = new ArrayList<>(); // 寄件人电话String
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getSenderPhone())) {
|
||||
for (BWaybillResp.WordsResultDTO.SenderPhoneDTO senderPhoneDTO : wordsResultDTO.getSenderPhone()) {
|
||||
senderPhone.add(senderPhoneDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setSenderPhone(senderPhone);
|
||||
|
||||
List<String> virtualNumber = new ArrayList<>(); //虚拟面单号。当请求参数 is_identify_virtual_waybill = true 时返回该字段
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getVirtualNumber())) {
|
||||
for (BWaybillResp.WordsResultDTO.SenderPhoneDTO senderPhoneDTO : wordsResultDTO.getVirtualNumber()) {
|
||||
virtualNumber.add(senderPhoneDTO.getWord());
|
||||
}
|
||||
}
|
||||
|
||||
resp.setVirtualNumber(virtualNumber);
|
||||
|
||||
List<String> virtualNumberLast = new ArrayList<>(); //隐私面单的4位转接号。当请求参数 is_identify_virtual_waybill = true 时返回该字段
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getVirtualNumberLast())) {
|
||||
for (BWaybillResp.WordsResultDTO.SenderPhoneDTO senderPhoneDTO : wordsResultDTO.getVirtualNumberLast()) {
|
||||
virtualNumberLast.add(senderPhoneDTO.getWord());
|
||||
}
|
||||
}
|
||||
|
||||
resp.setVirtualNumberLast(virtualNumberLast);
|
||||
List<String> isVirtualWaybill = new ArrayList<>(); // 此张快递面单是否为隐私面单,“true”代表“是”,“false”代表“否”。当请求参数 is_identify_virtual_waybill = true 时返回该字段
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getIsVirtualWaybill())) {
|
||||
for (BWaybillResp.WordsResultDTO.SenderPhoneDTO senderPhoneDTO : wordsResultDTO.getIsVirtualWaybill()) {
|
||||
isVirtualWaybill.add(senderPhoneDTO.getWord());
|
||||
}
|
||||
}
|
||||
resp.setIsVirtualWaybill(isVirtualWaybill);
|
||||
|
||||
respList.add(resp);
|
||||
}
|
||||
}
|
||||
return R.ok().setData(respList);
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,139 @@
|
||||
package com.heyu.api.controller.traffic;
|
||||
|
||||
import com.heyu.api.baidu.handle.traffic.BWeightNoteHandle;
|
||||
import com.heyu.api.baidu.request.traffic.BWeightNoteRequest;
|
||||
import com.heyu.api.baidu.response.traffic.BWeightNoteResp;
|
||||
import com.heyu.api.controller.BaseController;
|
||||
import com.heyu.api.data.annotation.CacheResult;
|
||||
import com.heyu.api.data.annotation.NotIntercept;
|
||||
import com.heyu.api.data.utils.ApiR;
|
||||
import com.heyu.api.data.utils.R;
|
||||
import com.heyu.api.resp.traffic.WeightNoteResp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/***
|
||||
* https://console.bce.baidu.com/support/?_=1740411162437×tamp=1743167283288#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E4%BA%A4%E9%80%9A%E5%9C%BA%E6%99%AFOCR&api=rest%2F2.0%2Focr%2Fv1%2Fweight_note&method=post
|
||||
*
|
||||
* 磅单识别
|
||||
*
|
||||
* 接口描述
|
||||
* 结构化识别磅单的车牌号、打印时间、毛重、皮重、净重、发货单位、收货单位、单号8个关键字段,现阶段仅支持识别印刷体磅单。
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/weight/note")
|
||||
@NotIntercept
|
||||
public class WeightNoteController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private BWeightNoteHandle bWeightNoteHandle;
|
||||
|
||||
@RequestMapping("/recognize")
|
||||
@CacheResult
|
||||
public R recognize(BWeightNoteRequest request) {
|
||||
|
||||
List<WeightNoteResp> respList = new ArrayList<>();
|
||||
|
||||
|
||||
ApiR<BWeightNoteResp> bR = bWeightNoteHandle.handle(request);
|
||||
if (bR.isSuccess()) {
|
||||
BWeightNoteResp bWeightNoteResp = bR.getData();
|
||||
List<BWeightNoteResp.WordsResultDTO> wordsResultDTOS = bWeightNoteResp.getWordsResult();
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTOS)) {
|
||||
for (BWeightNoteResp.WordsResultDTO wordsResultDTO : wordsResultDTOS) {
|
||||
|
||||
WeightNoteResp resp = new WeightNoteResp();
|
||||
|
||||
|
||||
List<String> tareWeight = new ArrayList<>(); //皮重
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getTareWeight())) {
|
||||
for (BWeightNoteResp.WordsResultDTO.TareWeightDTO tareWeightDTO : wordsResultDTO.getTareWeight()) {
|
||||
tareWeight.add(tareWeightDTO.getWord());
|
||||
}
|
||||
}
|
||||
resp.setTareWeight(tareWeight);
|
||||
|
||||
List<String> crossWeight = new ArrayList<>(); //毛重
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getCrossWeight())) {
|
||||
for (BWeightNoteResp.WordsResultDTO.CrossWeightDTO crossWeightDTO : wordsResultDTO.getCrossWeight()) {
|
||||
crossWeight.add(crossWeightDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setCrossWeight(crossWeight);
|
||||
|
||||
|
||||
List<String> plateNum = new ArrayList<>(); //车牌号
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getPlateNum())) {
|
||||
for (BWeightNoteResp.WordsResultDTO.PlateNumDTO plateNumDTO : wordsResultDTO.getPlateNum()) {
|
||||
plateNum.add(plateNumDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setPlateNum(plateNum);
|
||||
|
||||
List<String> sendingCompany = new ArrayList<>();//货单位
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getSendingCompany())) {
|
||||
for (BWeightNoteResp.WordsResultDTO.SendingCompanyDTO sendingCompanyDTO : wordsResultDTO.getSendingCompany()) {
|
||||
sendingCompany.add(sendingCompanyDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setSendingCompany(sendingCompany);
|
||||
|
||||
List<String> deliveryNumber = new ArrayList<>(); //单号
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getDeliveryNumber())) {
|
||||
for (BWeightNoteResp.WordsResultDTO.DeliveryNumberDTO deliveryNumberDTO : wordsResultDTO.getDeliveryNumber()) {
|
||||
deliveryNumber.add(deliveryNumberDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setDeliveryNumber(deliveryNumber);
|
||||
|
||||
List<String> receivingCompany = new ArrayList<>(); //收货单位
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getReceivingCompany())) {
|
||||
for (BWeightNoteResp.WordsResultDTO.ReceivingCompanyDTO receivingCompanyDTO : wordsResultDTO.getReceivingCompany()) {
|
||||
receivingCompany.add(receivingCompanyDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setReceivingCompany(receivingCompany);
|
||||
|
||||
List<String> printTime = new ArrayList<>(); //打印时间
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getPrintTime())) {
|
||||
for (BWeightNoteResp.WordsResultDTO.PrintTimeDTO printTimeDTO : wordsResultDTO.getPrintTime()) {
|
||||
printTime.add(printTimeDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setPrintTime(printTime);
|
||||
|
||||
List<String> netWeight = new ArrayList<>(); //净重
|
||||
if (CollectionUtils.isNotEmpty(wordsResultDTO.getNetWeight())) {
|
||||
for (BWeightNoteResp.WordsResultDTO.NetWeightDTO netWeightDTO : wordsResultDTO.getNetWeight()) {
|
||||
netWeight.add(netWeightDTO.getWord());
|
||||
|
||||
}
|
||||
}
|
||||
resp.setNetWeight(netWeight);
|
||||
respList.add(resp);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return R.ok().setData(respList);
|
||||
}
|
||||
|
||||
return R.error(bR.getErrorMsg());
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.heyu.api.resp.traffic;
|
||||
|
||||
import com.heyu.api.data.dto.BaseResp;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WaybillResp extends BaseResp {
|
||||
|
||||
private String imageInfo; // 图像四方向
|
||||
private List<String> barCode; //条形码
|
||||
private List<String> waybillNumber; //快递运单号
|
||||
private List<String> threeSegmentCode; //三段码
|
||||
private List<String> recipientName; //收件人姓名
|
||||
private List<String> senderName; //寄件人姓名
|
||||
private List<String> recipientAddr; //收件人地址
|
||||
private List<String> senderAddr; //寄件人地址
|
||||
private List<String> recipientPhone; //收件人电话
|
||||
private List<String> senderPhone; // 寄件人电话String
|
||||
private List<String> virtualNumber;//虚拟面单号。当请求参数 is_identify_virtual_waybill = true 时返回该字段
|
||||
private List<String> virtualNumberLast; //隐私面单的4位转接号。当请求参数 is_identify_virtual_waybill = true 时返回该字段
|
||||
private List<String> isVirtualWaybill; // 此张快递面单是否为隐私面单,“true”代表“是”,“false”代表“否”。当请求参数 is_identify_virtual_waybill = true 时返回该字段
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.heyu.api.resp.traffic;
|
||||
|
||||
import com.heyu.api.data.dto.BaseResp;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WeightNoteResp extends BaseResp {
|
||||
|
||||
private List<String> tareWeight; //皮重
|
||||
private List<String> crossWeight; //毛重
|
||||
private List<String> plateNum; //车牌号
|
||||
private List<String> sendingCompany;//货单位
|
||||
private List<String> deliveryNumber; //单号
|
||||
private List<String> receivingCompany; //收货单位
|
||||
private List<String> printTime; //打印时间
|
||||
private List<String> netWeight; //净重
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user