Commit 2ffa4c81 by zhanghou

提供接口可以让sessionNumber和sequenceNumber可以通过实现类生成

(cherry picked from commit e36b97eb82f8a45eda061f8834b024e75883877c)
parent 84b37ad9
......@@ -3,6 +3,7 @@ package com.brilliance.swift.mx2mt;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.MessageUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.util.XmlUtil;
......@@ -25,6 +26,7 @@ import javax.xml.datatype.XMLGregorianCalendar;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.*;
......@@ -371,8 +373,26 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
} else {
block1.setLogicalTerminal(processBicCode(senderBic));
}
block1.setSessionNumber(getRandomNumber(4));//mapping文档中给的是0000
block1.setSequenceNumber(getRandomNumber(6));//mapping文档中给的是000000
try {
String implName = "com.brilliance.swift.mx2mt.GenerateSesSeqNumberImpl";
InputStream resourceAsStream = AbstractMx2MtCreator.class.getResourceAsStream("/generateSesSeqNumber.properties");
if(!Objects.isNull(resourceAsStream)){
Properties properties = new Properties();
properties.load(resourceAsStream);
implName = properties.getProperty("generateNumber");
if(StringUtil.isEmpty(implName)){
implName = "com.brilliance.swift.mx2mt.GenerateSesSeqNumberImpl";
}
}
Object obj = Class.forName(implName).newInstance();
GenerateSesSeqNumber generateNumber = (GenerateSesSeqNumber) obj;
block1.setSessionNumber(generateNumber.generateSessionNumber());//mapping文档中给的是0000
block1.setSequenceNumber(generateNumber.generateSequenceNumber());//mapping文档中给的是000000
} catch (Exception e) {
throw new SwiftException(e.getMessage());
}
// block1.setSessionNumber(getRandomNumber(4));//mapping文档中给的是0000
// block1.setSequenceNumber(getRandomNumber(6));//mapping文档中给的是000000
context.get(SwiftMessage.class).setBlock1(block1);
}
......
package com.brilliance.swift.mx2mt;
/**
* @author zh
* @create 2023-05-08-13:44
*/
public interface GenerateSesSeqNumber {
String generateSessionNumber();
String generateSequenceNumber();
}
package com.brilliance.swift.mx2mt;
/**
* @author zh
* @create 2023-05-08-13:49
*/
public class GenerateSesSeqNumberImpl implements GenerateSesSeqNumber {
@Override
public String generateSessionNumber() {
return "0000";
}
@Override
public String generateSequenceNumber() {
return "000000";
}
}
generateNumber=com.brilliance.swift.mx2mt.GenerateSesSeqNumberImpl
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment