parent
86be40072e
commit
6f6a670378
@ -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<MdmGmfxxtbReqBO> mdmGmfxxtbReqBOS = JSONObject.parseArray(requestBody, MdmGmfxxtbReqBO.class); |
||||||
|
List<GmfxxtbReqBO> 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<GmfxxtbRspBO> gmfxxtbRspList = interfaceServiceV3.syncBuyerMessage(gmfxxtbReqList, ""); |
||||||
|
return JsonUtils.getInstance().toJsonStringNullToEmpty(gmfxxtbRspList); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue