接口工具类
This commit is contained in:
parent
ce70df8142
commit
ef7078fc2b
Binary file not shown.
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding='gb2312'?>
|
||||||
|
<module name="uapbd">
|
||||||
|
<public>
|
||||||
|
<component remote="true" singleton="true" tx="CMT">
|
||||||
|
<interface>nc.pubitf.ic.egap.INCCForEGAPIntf</interface>
|
||||||
|
<implementation>nc.impl.ic.egap.INCCForEGAPImpl</implementation>
|
||||||
|
</component>
|
||||||
|
</public>
|
||||||
|
<private>
|
||||||
|
</private>
|
||||||
|
</module>
|
|
@ -0,0 +1,45 @@
|
||||||
|
package nc.impl.ic.egap;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import nc.bs.dao.BaseDAO;
|
||||||
|
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||||
|
|
||||||
|
import nc.pubitf.ic.egap.INCCForEGAPIntf;
|
||||||
|
|
||||||
|
import nc.vo.pub.BusinessException;
|
||||||
|
|
||||||
|
import weaver.formmode.webservices.SysFomForHttp;
|
||||||
|
|
||||||
|
public class INCCForEGAPImpl implements INCCForEGAPIntf {
|
||||||
|
|
||||||
|
public BaseDAO dao=null;
|
||||||
|
|
||||||
|
public BaseDAO getDao() {
|
||||||
|
if(dao==null) {
|
||||||
|
dao=new BaseDAO();
|
||||||
|
}
|
||||||
|
return dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendEGAP(String json, String mothodCode,String pk) throws BusinessException {
|
||||||
|
String ulr=getUrl(mothodCode);
|
||||||
|
new SysFomForHttp().doPost(ulr,null,null,null,json,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getUrl(String string) throws BusinessException {
|
||||||
|
String sql=" select url from pub_url where code='"+string+"' ";
|
||||||
|
|
||||||
|
Object o=getDao().executeQuery(sql, new ColumnProcessor());
|
||||||
|
if(o==null) {
|
||||||
|
throw new BusinessException("编码为"+string+"EPAP接口为空,请设置接口地址");
|
||||||
|
}
|
||||||
|
return o.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
package weaver.formmode.webservices;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
import nc.vo.pub.BusinessException;
|
||||||
|
|
||||||
|
import org.apache.http.NameValuePair;
|
||||||
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class SysFomForHttp {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String doPost(String baseUrl, Map<String, String> paramMap, String mediaType, Map<String, String> headers, String json,String pk) throws BusinessException{
|
||||||
|
|
||||||
|
HttpURLConnection urlConnection = null;
|
||||||
|
InputStream in = null;
|
||||||
|
OutputStream out = null;
|
||||||
|
BufferedReader bufferedReader = null;
|
||||||
|
String result = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
sb.append(baseUrl);
|
||||||
|
if (paramMap != null) {
|
||||||
|
sb.append("?");
|
||||||
|
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
String value = entry.getValue();
|
||||||
|
sb.append(key + "=" + value).append("&");
|
||||||
|
}
|
||||||
|
baseUrl = sb.toString().substring(0, sb.toString().length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
URL urlObj = new URL(baseUrl);
|
||||||
|
urlConnection = (HttpURLConnection) urlObj.openConnection();
|
||||||
|
urlConnection.setConnectTimeout(50000);
|
||||||
|
urlConnection.setRequestMethod("POST");
|
||||||
|
urlConnection.setDoOutput(true);
|
||||||
|
urlConnection.setDoInput(true);
|
||||||
|
urlConnection.setUseCaches(false);
|
||||||
|
urlConnection.addRequestProperty("content-type", "multipart/form-data");
|
||||||
|
if (headers != null) {
|
||||||
|
for (String key : headers.keySet()) {
|
||||||
|
urlConnection.addRequestProperty(key, headers.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out = urlConnection.getOutputStream();
|
||||||
|
out.write(json.getBytes("utf-8"));
|
||||||
|
out.flush();
|
||||||
|
|
||||||
|
int resCode = urlConnection.getResponseCode();
|
||||||
|
if (resCode == HttpURLConnection.HTTP_OK || resCode == HttpURLConnection.HTTP_CREATED || resCode == HttpURLConnection.HTTP_ACCEPTED) {
|
||||||
|
in = urlConnection.getInputStream();
|
||||||
|
} else {
|
||||||
|
in = urlConnection.getErrorStream();
|
||||||
|
}
|
||||||
|
bufferedReader = new BufferedReader(new InputStreamReader(in, "utf-8"));
|
||||||
|
StringBuffer temp = new StringBuffer();
|
||||||
|
String line = bufferedReader.readLine();
|
||||||
|
while (line != null) {
|
||||||
|
temp.append(line).append("\r\n");
|
||||||
|
line = bufferedReader.readLine();
|
||||||
|
}
|
||||||
|
String ecod = urlConnection.getContentEncoding();
|
||||||
|
if (ecod == null) {
|
||||||
|
ecod = Charset.forName("utf-8").name();
|
||||||
|
}
|
||||||
|
result = new String(temp.toString().getBytes("utf-8"), ecod);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BusinessException(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
|
||||||
|
if (null != bufferedReader) {
|
||||||
|
try {
|
||||||
|
bufferedReader.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (null != out) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (null != in) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
urlConnection.disconnect();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,233 @@
|
||||||
|
package nc.bd.itf.tools;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import nc.vo.pub.lang.UFBoolean;
|
||||||
|
import nc.vo.pub.lang.UFDate;
|
||||||
|
import nc.vo.pub.lang.UFDateTime;
|
||||||
|
import nc.vo.pub.lang.UFDouble;
|
||||||
|
|
||||||
|
public class BFPubTools
|
||||||
|
{
|
||||||
|
public static UFDouble ZERO = UFDouble.ZERO_DBL;
|
||||||
|
|
||||||
|
public static boolean isEmpty(String value)
|
||||||
|
{
|
||||||
|
return (value == null) || (value.trim().length() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UFBoolean getUFBoolean_NullAs(Object value, UFBoolean bDefautValue)
|
||||||
|
{
|
||||||
|
if ((value == null) || (value.toString().trim().equals("")))
|
||||||
|
return bDefautValue;
|
||||||
|
if ((value instanceof UFBoolean)) {
|
||||||
|
return (UFBoolean)value;
|
||||||
|
}
|
||||||
|
return new UFBoolean(value.toString().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UFDate getUFDate(Object value)
|
||||||
|
{
|
||||||
|
if ((value == null) || (value.toString().trim().equals("")))
|
||||||
|
return null;
|
||||||
|
if ((value instanceof UFDate)) {
|
||||||
|
return (UFDate)value;
|
||||||
|
}
|
||||||
|
return new UFDate(value.toString().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UFDateTime getUFDateTime(Object value)
|
||||||
|
{
|
||||||
|
if ((value == null) || (value.toString().trim().equals("")))
|
||||||
|
return null;
|
||||||
|
if ((value instanceof UFDateTime)) {
|
||||||
|
return (UFDateTime)value;
|
||||||
|
}
|
||||||
|
return new UFDateTime(value.toString().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UFDouble getUFDouble_NullAsZero(Object value)
|
||||||
|
{
|
||||||
|
if ((value == null) || (value.toString().trim().equals("")) || (value.toString().trim().equals("~")))
|
||||||
|
return ZERO;
|
||||||
|
if ((value instanceof UFDouble))
|
||||||
|
return (UFDouble)value;
|
||||||
|
if ((value instanceof BigDecimal)) {
|
||||||
|
return new UFDouble((BigDecimal)value);
|
||||||
|
}
|
||||||
|
return new UFDouble(value.toString().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UFDouble getUFDouble_ValueAsValue(double dValue)
|
||||||
|
{
|
||||||
|
if (dValue == 0.0D) {
|
||||||
|
return ZERO;
|
||||||
|
}
|
||||||
|
return new UFDouble(dValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UFDouble getUFDouble_ValueAsValue(Object value)
|
||||||
|
{
|
||||||
|
if ((value == null) || (value.toString().trim().equals("")))
|
||||||
|
return null;
|
||||||
|
if ((value instanceof UFDouble))
|
||||||
|
return (UFDouble)value;
|
||||||
|
if ((value instanceof BigDecimal)) {
|
||||||
|
return new UFDouble((BigDecimal)value);
|
||||||
|
}
|
||||||
|
return new UFDouble(value.toString().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UFDouble getUFDouble_ZeroAsNull(double dValue)
|
||||||
|
{
|
||||||
|
if (dValue == 0.0D) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new UFDouble(dValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UFDouble getUFDouble_ZeroAsNull(Object value)
|
||||||
|
{
|
||||||
|
UFDouble dValue = getUFDouble_NullAsZero(value);
|
||||||
|
if (dValue.compareTo(ZERO) == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return dValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getString_TrimZeroLenAsNull(Object value)
|
||||||
|
{
|
||||||
|
if ((value == null) || (value.toString().trim().length() == 0)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return value.toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getString_TrimZeroLenAs(Object value, String str)
|
||||||
|
{
|
||||||
|
if ((value == null) || (value.toString().trim().length() == 0)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return value.toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getString_TrimAsNull(Object value) {
|
||||||
|
if ((value == null) || (value.toString().trim().length() == 0)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return value.toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getInStr(Collection<?> coll)
|
||||||
|
{
|
||||||
|
String intStr = null;
|
||||||
|
if ((coll != null) && (coll.size() > 0)) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String[] values = (String[])coll.toArray(new String[0]);
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
sb.append("'").append(values[i]).append("'");
|
||||||
|
if (i < values.length - 1)
|
||||||
|
sb.append(",");
|
||||||
|
}
|
||||||
|
intStr = sb.toString();
|
||||||
|
}
|
||||||
|
return intStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getInSqlWithOutAnd(String sFieldName, ArrayList<?> alValue, int start, int num)
|
||||||
|
{
|
||||||
|
if ((sFieldName == null) || (sFieldName.trim().length() == 0) ||
|
||||||
|
(alValue == null) || (start < 0) || (num < 0))
|
||||||
|
return null;
|
||||||
|
StringBuffer sbSQL = new StringBuffer(200);
|
||||||
|
sbSQL.append(" (").append(sFieldName).append(" IN (");
|
||||||
|
int end = start + num;
|
||||||
|
for (int i = start; i < end; i++) {
|
||||||
|
if ((alValue.get(i) != null) &&
|
||||||
|
(alValue.get(i).toString().trim().length() > 0)) {
|
||||||
|
sbSQL.append("'").append(alValue.get(i)).append("'");
|
||||||
|
if ((i != alValue.size() - 1) && ((i <= 0) || (i % 200 != 0)))
|
||||||
|
sbSQL.append(",");
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ((i > 0) && (i % 200 == 0))
|
||||||
|
sbSQL.append(" ) OR ").append(sFieldName).append(" IN ( ");
|
||||||
|
}
|
||||||
|
sbSQL.append(" ) )");
|
||||||
|
return sbSQL.toString();
|
||||||
|
}
|
||||||
|
public static String getInSqlWithOutAnd(String sFieldName, List<?> alValue, int start, int num)
|
||||||
|
{
|
||||||
|
if ((sFieldName == null) || (sFieldName.trim().length() == 0) ||
|
||||||
|
(alValue == null) || (start < 0) || (num < 0))
|
||||||
|
return null;
|
||||||
|
StringBuffer sbSQL = new StringBuffer(200);
|
||||||
|
sbSQL.append(" (").append(sFieldName).append(" IN (");
|
||||||
|
int end = start + num;
|
||||||
|
for (int i = start; i < end; i++) {
|
||||||
|
if ((alValue.get(i) != null) &&
|
||||||
|
(alValue.get(i).toString().trim().length() > 0)) {
|
||||||
|
sbSQL.append("'").append(alValue.get(i)).append("'");
|
||||||
|
if ((i != alValue.size() - 1) && ((i <= 0) || (i % 200 != 0)))
|
||||||
|
sbSQL.append(",");
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ((i > 0) && (i % 200 == 0))
|
||||||
|
sbSQL.append(" ) OR ").append(sFieldName).append(" IN ( ");
|
||||||
|
}
|
||||||
|
sbSQL.append(" ) )");
|
||||||
|
return sbSQL.toString();
|
||||||
|
}
|
||||||
|
public static String getInSqlWithOutAnd(String sFieldName, String[] saValue, int start, int num)
|
||||||
|
{
|
||||||
|
if ((sFieldName == null) || (sFieldName.trim().length() == 0) ||
|
||||||
|
(saValue == null) || (start < 0) || (num < 0) ||
|
||||||
|
(saValue.length < start + num))
|
||||||
|
return null;
|
||||||
|
StringBuffer sbSQL = new StringBuffer(200);
|
||||||
|
sbSQL.append(" (").append(sFieldName).append(" IN ( ");
|
||||||
|
int end = start + num;
|
||||||
|
for (int i = start; i < end; i++) {
|
||||||
|
if ((saValue[i] != null) && (saValue[i].trim().length() > 0)) {
|
||||||
|
sbSQL.append("'").append(saValue[i]).append("'");
|
||||||
|
if ((i != saValue.length - 1) && ((i <= 0) || (i % 200 != 0)))
|
||||||
|
sbSQL.append(",");
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ((i > 0) && (i % 200 == 0))
|
||||||
|
sbSQL.append(" ) OR ").append(sFieldName).append(" IN ( ");
|
||||||
|
}
|
||||||
|
sbSQL.append(" ) )");
|
||||||
|
return sbSQL.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getInSqlWithOutAnd(String sFieldName, Object[] oValue, int start, int num) {
|
||||||
|
if ((sFieldName == null) || (sFieldName.trim().length() == 0) ||
|
||||||
|
(oValue == null) || (start < 0) || (num < 0) ||
|
||||||
|
(oValue.length < start + num))
|
||||||
|
return null;
|
||||||
|
StringBuffer sbSQL = new StringBuffer(200);
|
||||||
|
sbSQL.append(" (").append(sFieldName).append(" IN ( ");
|
||||||
|
int end = start + num;
|
||||||
|
for (int i = start; i < end; i++) {
|
||||||
|
String sValue = getString_TrimZeroLenAsNull(oValue);
|
||||||
|
if (oValue[i] != null) {
|
||||||
|
sbSQL.append("'").append(sValue).append("'");
|
||||||
|
if ((i != oValue.length - 1) && ((i <= 0) || (i % 200 != 0)))
|
||||||
|
sbSQL.append(",");
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ((i > 0) && (i % 200 == 0))
|
||||||
|
sbSQL.append(" ) OR ").append(sFieldName).append(" IN ( ");
|
||||||
|
}
|
||||||
|
sbSQL.append(" ) )");
|
||||||
|
return sbSQL.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package nc.pubitf.ic.egap;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
import nc.vo.mmpac.dmo.entity.AggDmoVO;
|
||||||
|
import nc.vo.pu.m23.entity.ArriveVO;
|
||||||
|
import nc.vo.pub.BusinessException;
|
||||||
|
import nc.vo.bd.bankaccount.cust.CustBankaccUnionVO;
|
||||||
|
public interface INCCForEGAPIntf {
|
||||||
|
//json ,接口编码 ,单据pk
|
||||||
|
public void sendEGAP(String json,String mothodCode,String pk)throws BusinessException;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ import nc.itf.pu.dhjyd.dhjydmaster.IDhjydMasterVOService;
|
||||||
* µ¼³ö
|
* µ¼³ö
|
||||||
*/
|
*/
|
||||||
public class AggDhjydMasterVOExcelOutputProcessor extends AbstractExcelOutputProcessor {
|
public class AggDhjydMasterVOExcelOutputProcessor extends AbstractExcelOutputProcessor {
|
||||||
|
//zץËŢ
|
||||||
@Override
|
@Override
|
||||||
public File writeExportData(String filename, Object[] values, List<InputItem> inputitems,
|
public File writeExportData(String filename, Object[] values, List<InputItem> inputitems,
|
||||||
BillDefination billDefination) throws Exception {
|
BillDefination billDefination) throws Exception {
|
||||||
|
|
|
@ -16,6 +16,8 @@ import nc.vo.pub.SuperVO;
|
||||||
*/
|
*/
|
||||||
public class PfDhjydMasterVOCheck implements ICheckStatusCallback {
|
public class PfDhjydMasterVOCheck implements ICheckStatusCallback {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private BaseDAO baseDAO = null;
|
private BaseDAO baseDAO = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue