| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- package com.xunmei.sms.vo;
- import com.dc.eai.data.CompositeData;
- import com.dc.eai.data.Field;
- import com.dc.eai.data.FieldAttr;
- import com.dc.eai.data.FieldType;
- import lombok.Data;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- /**
- * @author wubiyu[2024/03/18]
- */
- @Data
- public class SmsInfoVo {
- private static Logger logger = LoggerFactory.getLogger(SmsInfoVo.class);
- /**
- * 交易类型
- */
- private String tranType;
- /**
- * 机构号
- */
- private String branchId;
- /**
- * 消费者系统流水号
- */
- private String consumerSeqNo;
- /**
- * 客户号
- */
- private String custNo;
- /**
- * 客户姓名
- */
- private String custName;
- /**
- * 性别
- */
- private String sex;
- /**
- * 手机号
- */
- private String mobile;
- /**
- * 帐号
- */
- private String acctNo;
- /**
- * 发生日期 格式:yyyy-MM-dd
- */
- private String occurDate;
- /**
- * 发生时间:格式:Hh:mm:ss
- */
- private String occurTime;
- /**
- * 交易金额1
- */
- private String tranAmt1;
- /**
- * 交易金额1
- */
- private String tranAmt2;
- /**
- * 交易金额1
- */
- private String tranAmt3;
- /**
- * 支出/存入位1
- */
- private String payoutStoreBit1;
- /**
- * 支出/存入位2
- */
- private String payoutStoreBit2;
- /**
- * 支出/存入位1
- */
- private String payoutStoreBit3;
- /**
- * 交易摘要
- */
- private String tranRemark;
- /**
- * 帐户状态
- */
- private String acctStatus;
- /**
- * 渠道类型
- */
- private String channelType;
- /**
- * 备用1
- */
- private String bak1;
- /**
- * 备用2
- */
- private String bak2;
- /**
- * 备用3
- */
- private String bak3;
- public static CompositeData convertTo(SmsInfoVo source) {
- try {
- /***********************************************************************
- * *********构造请求数据,定义相关结构体*******
- **********************************************************************/
- CompositeData reqData = new CompositeData();
- CompositeData sysData = new CompositeData();
- CompositeData appData = new CompositeData();
- CompositeData body = new CompositeData();
- reqData.addStruct("SYS_HEAD", sysData);
- reqData.addStruct("APP_HEAD", appData);
- reqData.addStruct("BODY", body);
- /***********************************************************************
- * ********* 系统头 ******************
- **********************************************************************/
- if (source.getConsumerSeqNo() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 15, 0));
- field.setValue(source.getConsumerSeqNo());
- sysData.addField("CONSUMER_SEQ_NO", field);
- }
- /***********************************************************************
- * ********** 应用头 ***************
- **********************************************************************/
- if (source.getBranchId() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 9, 0));
- field.setValue(source.getBranchId());
- appData.addField("BRANCH_ID", field);
- }
- // 应用头其他需要上送的数据。。。
- /***********************************************************************
- * ************* 报文体 ************ 服务代码为11003000002,场景为07定义的输入数据
- **********************************************************************/
- if (source.getTranType() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 6, 0));
- field.setValue(source.getTranType());
- body.addField("TRAN_TYPE", field);
- }
- if (source.getCustNo() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 22, 0));
- field.setValue(source.getCustNo());
- body.addField("CUST_NO", field);
- }
- if (source.getCustName() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 50, 0));
- field.setValue(source.getCustNo());
- body.addField("CUST_NAME", field);
- }
- if (source.getSex() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 2, 0));
- field.setValue(source.getSex());
- body.addField("SEX", field);
- }
- if (source.getMobile() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 20, 0));
- field.setValue(source.getMobile());
- body.addField("MOBILE", field);
- }
- if (source.getAcctNo() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 32, 0));
- field.setValue(source.getAcctNo());
- body.addField("ACCT_NO", field);
- }
- if (source.getOccurDate() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 10, 0));
- field.setValue(source.getOccurDate());
- body.addField("OCCUR_DATE", field);
- }
- if (source.getOccurTime() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 10, 0));
- field.setValue(source.getOccurTime());
- body.addField("OCCUR_TIME", field);
- }
- if (source.getTranAmt1() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 17, 0));
- field.setValue(source.getTranAmt1());
- body.addField("TRAN_AMT1", field);
- }
- if (source.getTranAmt2() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 17, 0));
- field.setValue(source.getTranAmt2());
- body.addField("TRAN_AMT2", field);
- }
- if (source.getTranAmt3() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 17, 0));
- field.setValue(source.getTranAmt3());
- body.addField("TRAN_AMT3", field);
- }
- if (source.getPayoutStoreBit1() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 1, 0));
- field.setValue(source.getPayoutStoreBit1());
- body.addField("PAYOUT_STORE_BIT1", field);
- }
- if (source.getPayoutStoreBit2() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 1, 0));
- field.setValue(source.getPayoutStoreBit2());
- body.addField("PAYOUT_STORE_BIT2", field);
- }
- if (source.getPayoutStoreBit3() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 1, 0));
- field.setValue(source.getPayoutStoreBit3());
- body.addField("PAYOUT_STORE_BIT3", field);
- }
- if (source.getTranRemark() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 30, 0));
- field.setValue(source.getTranRemark());
- body.addField("TRAN_REMARK", field);
- }
- if (source.getAcctStatus() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 100, 0));
- field.setValue(source.getAcctStatus());
- body.addField("ACCT_STATUS", field);
- }
- if (source.getChannelType() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 2, 0));
- field.setValue(source.getChannelType());
- body.addField("CHANNEL_TYPE", field);
- }
- if (source.getBak1() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 50, 0));
- field.setValue(source.getBak1());
- body.addField("BAK1", field);
- }
- if (source.getBak2() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 50, 0));
- field.setValue(source.getBak2());
- body.addField("BAK2", field);
- }
- if (source.getBak3() != null) {
- Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 50, 0));
- field.setValue(source.getBak3());
- body.addField("BAK3", field);
- }
- return reqData;
- } catch (Exception ex) {
- logger.error("【发送短信】转换数据异常", ex);
- return null;
- }
- }
- }
|