From f3b5567f272599fceddc39f0624dc9d3764f2cf0 Mon Sep 17 00:00:00 2001 From: gongquanlin <1025081659@qq.com> Date: Tue, 14 Feb 2023 18:26:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=88=87=E6=8D=A2=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../openapi/api/InvoiceRestSDEnregy.java | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/api/InvoiceRestSDEnregy.java diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/api/InvoiceRestSDEnregy.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/api/InvoiceRestSDEnregy.java new file mode 100644 index 00000000..9fa47118 --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/api/InvoiceRestSDEnregy.java @@ -0,0 +1,98 @@ +package com.dxhy.order.consumer.openapi.api; + +import com.alibaba.fastjson.JSONObject; +import com.dxhy.order.baseservice.module.buyer.protocol.GmfxxtbReqBO; +import com.dxhy.order.baseservice.module.buyer.protocol.GmfxxtbRspBO; +import com.dxhy.order.consumer.openapi.protocol.v6.sdenergy.MdmGmfxxtbMulticodeValuelistBO; +import com.dxhy.order.consumer.openapi.protocol.v6.sdenergy.MdmGmfxxtbReqBO; +import com.dxhy.order.consumer.openapi.service.InterfaceServiceV3; +import com.dxhy.order.utils.JsonUtils; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.util.CollectionUtils; +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.RestController; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.List; + +/** + * @Description + * @Author 巩权林 + * @Date 2023/2/14 15:28 + **/ +@Slf4j +@RestController +@RequestMapping("/invoice/api/invoice_sd_energy") +public class InvoiceRestSDEnregy { + + + @Resource + private InterfaceServiceV3 interfaceServiceV3; + + /** + * @param requestBody + * @return + */ + @PostMapping("/sync_buyer_message") + public String syncBuyerMessage(@RequestBody String requestBody) { + List mdmGmfxxtbReqBOS = JSONObject.parseArray(requestBody, MdmGmfxxtbReqBO.class); + List gmfxxtbReqList = new ArrayList<>(); + for (MdmGmfxxtbReqBO tempMdmGmfxxtbReqBO : mdmGmfxxtbReqBOS) { + GmfxxtbReqBO gmfxxtbReqBO = new GmfxxtbReqBO(); + gmfxxtbReqBO.setGMFBM(tempMdmGmfxxtbReqBO.getCODE()); // 取code + gmfxxtbReqBO.setXHFSBH(tempMdmGmfxxtbReqBO.getDESC14()); + gmfxxtbReqBO.setXHFMC(tempMdmGmfxxtbReqBO.getDESC1()); + + // 判断下DESC14是否为身份证,如果为身份证,则填写03,否则填写01,其余情况置空 + // 身份证正则表达式 + String idCardRegex = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)"; + // 税号正则表达式 + String taxNoRegex = "^[a-zA-Z0-9]{15,20}$"; + gmfxxtbReqBO.setGMFLX(""); + if (StringUtils.isNotEmpty(tempMdmGmfxxtbReqBO.getDESC14())) { + if (tempMdmGmfxxtbReqBO.getDESC14().matches(idCardRegex)) { + gmfxxtbReqBO.setGMFLX("03"); // 有可能出现个人 + } + if (tempMdmGmfxxtbReqBO.getDESC14().matches(taxNoRegex)) { + gmfxxtbReqBO.setGMFLX("01"); + } + } + + gmfxxtbReqBO.setGMFMC(tempMdmGmfxxtbReqBO.getDESC48()); + gmfxxtbReqBO.setGMFSBH(tempMdmGmfxxtbReqBO.getDESC49()); + gmfxxtbReqBO.setGMFDH(tempMdmGmfxxtbReqBO.getDESC26()); // ? + // 根据要求,取VALUELIST中的第一组数据作为银行数据 + if (tempMdmGmfxxtbReqBO.getMULTICODE() != null && !CollectionUtils.isEmpty(tempMdmGmfxxtbReqBO.getMULTICODE().getVALUELIST())) { + // 处理开户行银行 + MdmGmfxxtbMulticodeValuelistBO firstValueList = tempMdmGmfxxtbReqBO.getMULTICODE().getVALUELIST().get(0); + if (firstValueList != null) { + gmfxxtbReqBO.setGMFYH(firstValueList.getDESC3()); + gmfxxtbReqBO.setGMFZH(firstValueList.getDESC4()); + } + } + + gmfxxtbReqBO.setGMFSJH(tempMdmGmfxxtbReqBO.getDESC27()); + gmfxxtbReqBO.setGMFYX(tempMdmGmfxxtbReqBO.getDESC29()); + gmfxxtbReqBO.setCZLX("3"); // 可能重复推送,重复推送可能出现更新的情况,增加先查询,存在则更新不存在则插入的逻辑 + + // 拼接邮箱和地址 + String buyerAddress = ""; + buyerAddress = buyerAddress.concat(StringUtils.isEmpty(tempMdmGmfxxtbReqBO.getDESC22()) ? "" : tempMdmGmfxxtbReqBO.getDESC22()); + buyerAddress = buyerAddress.concat(StringUtils.isEmpty(tempMdmGmfxxtbReqBO.getDESC23()) ? "" : tempMdmGmfxxtbReqBO.getDESC23()); + buyerAddress = buyerAddress.concat(StringUtils.isEmpty(tempMdmGmfxxtbReqBO.getDESC24()) ? "" : tempMdmGmfxxtbReqBO.getDESC24()); + gmfxxtbReqBO.setGMFDZ(buyerAddress); + gmfxxtbReqBO.setINVOICE_NAME(tempMdmGmfxxtbReqBO.getDESC48()); + gmfxxtbReqBO.setINVOICE_TAXNO(tempMdmGmfxxtbReqBO.getDESC49()); + + gmfxxtbReqBO.setMDM_MULTICODE_JSON(JsonUtils.getInstance().toJsonStringNullToEmpty(tempMdmGmfxxtbReqBO.getMULTICODE())); + gmfxxtbReqList.add(gmfxxtbReqBO); + } + List gmfxxtbRspList = interfaceServiceV3.syncBuyerMessage(gmfxxtbReqList, ""); + return JsonUtils.getInstance().toJsonStringNullToEmpty(gmfxxtbRspList); + } +}