接口工具类
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; | ||||
| 
 | ||||
| 	  | ||||
| } | ||||
|  | @ -1,141 +1,141 @@ | |||
| 
 | ||||
| package nc.impl.pu.dhjyd.dhjydmaster; | ||||
| 
 | ||||
| import java.io.File; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import nc.md.MDBaseQueryFacade; | ||||
| import nc.md.model.IBusinessEntity; | ||||
| import nc.md.model.MetaDataException; | ||||
| import nc.ui.bd.ref.AbstractRefModel; | ||||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.vo.platform.appsystemplate.AreaVO; | ||||
| import nc.vo.platform.appsystemplate.FormPropertyVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pub.ExtendedAggregatedValueObject; | ||||
| import nccloud.bs.excel.process.AbstractExcelOutputProcessor; | ||||
| import nccloud.itf.trade.excelexport.convertor.IRefPropertyProcess; | ||||
| import nccloud.itf.trade.excelimport.ExportDataInfo; | ||||
| import nccloud.ui.trade.excelimport.InputItem; | ||||
| import nccloud.vo.excel.scheme.BillDefination; | ||||
| 
 | ||||
| import nc.vo.pu.dhjyd.AggDhjydMasterVO; | ||||
| import nc.itf.pu.dhjyd.dhjydmaster.IDhjydMasterVOService; | ||||
| /* | ||||
|  *	导出 | ||||
|  */ | ||||
| public class AggDhjydMasterVOExcelOutputProcessor extends AbstractExcelOutputProcessor { | ||||
| 
 | ||||
| 	@Override | ||||
| 	public File writeExportData(String filename, Object[] values, List<InputItem> inputitems, | ||||
| 			BillDefination billDefination) throws Exception { | ||||
| 		return super.writeExportData(filename, values, inputitems, billDefination); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	public File writeExportData(String filename, Object[] values, List<InputItem> inputitems, | ||||
| 			BillDefination billDefination, boolean isExportByTemp, Map<String, AreaVO> areamap) throws Exception { | ||||
| 		return super.writeExportData(filename, values, inputitems, billDefination, isExportByTemp, areamap); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	public Object[] getObjectValueByPks(String[] pks) throws BusinessException { | ||||
| 		// 要改成调用接口根据前端传过来的pks参数查询对应VO返回 | ||||
| 		AggDhjydMasterVO[] queryResult = getService().listAggDhjydMasterVOByPk(pks); | ||||
| 		if (queryResult == null || queryResult.length <= 0) { | ||||
| 			return null; | ||||
| 		} | ||||
| 		return queryResult; | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	protected ExportDataInfo getValue(Object[] vos, List<InputItem> exportItems, BillDefination billdefination) | ||||
| 			throws BusinessException { | ||||
| 		ExtendedAggregatedValueObject[] aggvos = getConvertorForTemp(new DefRefPropertyProcess()) | ||||
| 				.convertDataFromEditorData(billdefination, vos, exportItems); | ||||
| 			return new ExportDataInfo(aggvos); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	public void setAreamap(Map<String, AreaVO> areamap) { | ||||
| 		super.setAreamap(areamap); | ||||
| 	} | ||||
| 
 | ||||
| 	private IDhjydMasterVOService getService() { | ||||
| 		return NCLocator.getInstance().lookup(IDhjydMasterVOService.class); | ||||
| 	} | ||||
| 	class DefRefPropertyProcess implements IRefPropertyProcess{ | ||||
| 
 | ||||
| 		@Override | ||||
| 		public void ProcessRefProperty(AbstractRefModel refmodel) { | ||||
| 			refmodel.setSealedDataShow(true); | ||||
| 		} | ||||
| 
 | ||||
| 		@Override | ||||
| 		public AbstractRefModel getRefModelByProperty(FormPropertyVO property) { | ||||
| 			String classid = property.getClassid(); | ||||
| 			String pid = null; | ||||
| 			try { | ||||
| 				IBusinessEntity entity = (IBusinessEntity)MDBaseQueryFacade.getInstance().getBeanByID(classid); | ||||
| 				pid = entity.getBizInterfaceMapInfo("nc.vo.bd.meta.IBDObject") == null ? null : entity.getBizInterfaceMapInfo("nc.vo.bd.meta.IBDObject").get("pid"); | ||||
| 			} catch (MetaDataException e) { | ||||
| 				throw new RuntimeException(e); | ||||
| 			} | ||||
| 			// 1、判断是否有树形上级参照自身字段 | ||||
| 			if("04dd87e3-2bda-45d5-879b-3e320a4bc3d3".equals(classid) && pid != null && pid.equals(property.getCode())) { | ||||
| 				DefAbstractRefModel refModel = new DefAbstractRefModel(property); | ||||
| 				return refModel; | ||||
| 			} | ||||
| 			return null; | ||||
| 		}} | ||||
| 	class DefAbstractRefModel extends AbstractRefModel{ | ||||
| 		FormPropertyVO property; | ||||
| 		String tablename; | ||||
| 		String pkcolname; | ||||
| 		String pkattrname; | ||||
| 		String codename; | ||||
| 		String namename; | ||||
| 		public DefAbstractRefModel(FormPropertyVO property) { | ||||
| 			super(); | ||||
| 			this.property = property; | ||||
| 			String classid = property.getClassid(); | ||||
| 			IBusinessEntity entity; | ||||
| 			Map<String, String> bizInterfaceMapInfo; | ||||
| 			try { | ||||
| 				entity = (IBusinessEntity)MDBaseQueryFacade.getInstance().getBeanByID(classid); | ||||
| 				bizInterfaceMapInfo = entity.getBizInterfaceMapInfo("nc.vo.bd.meta.IBDObject"); | ||||
| 			} catch (MetaDataException e) { | ||||
| 				throw new RuntimeException(e); | ||||
| 			} | ||||
| 			tablename = entity.getTable().getName(); | ||||
| 			pkcolname = entity.getKeyAttribute().getColumn().getName(); | ||||
| 			pkattrname = entity.getKeyAttribute().getName(); | ||||
| 			codename = bizInterfaceMapInfo.get("code"); | ||||
| 			namename = bizInterfaceMapInfo.get("name"); | ||||
| 			this.reset(); | ||||
| 		} | ||||
| 		@Override | ||||
| 		public void reset() { | ||||
| 			this.setFieldCode(new String[] {codename}); | ||||
| 			this.setFieldName(new String[] {namename}); | ||||
| 			this.setTableName(this.tablename); | ||||
| 			this.setPkFieldCode(this.pkattrname); | ||||
| 			this.setRefCodeField(codename); | ||||
| 			this.setRefNameField(namename); | ||||
| 			this.resetFieldName(); | ||||
| 		} | ||||
| 		@Override | ||||
| 		public String[] getFieldCode() { | ||||
| 			return new String[] {pkcolname, codename, namename}; | ||||
| 		} | ||||
| 		@Override | ||||
| 		public String[] getFieldName() { | ||||
| 			return new String[] {pkcolname, codename, namename}; | ||||
| 		} | ||||
| 		@Override | ||||
| 		public String getWherePart() { | ||||
| 			return " 1 = 1 "; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| package nc.impl.pu.dhjyd.dhjydmaster; | ||||
| 
 | ||||
| import java.io.File; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import nc.md.MDBaseQueryFacade; | ||||
| import nc.md.model.IBusinessEntity; | ||||
| import nc.md.model.MetaDataException; | ||||
| import nc.ui.bd.ref.AbstractRefModel; | ||||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.vo.platform.appsystemplate.AreaVO; | ||||
| import nc.vo.platform.appsystemplate.FormPropertyVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pub.ExtendedAggregatedValueObject; | ||||
| import nccloud.bs.excel.process.AbstractExcelOutputProcessor; | ||||
| import nccloud.itf.trade.excelexport.convertor.IRefPropertyProcess; | ||||
| import nccloud.itf.trade.excelimport.ExportDataInfo; | ||||
| import nccloud.ui.trade.excelimport.InputItem; | ||||
| import nccloud.vo.excel.scheme.BillDefination; | ||||
| 
 | ||||
| import nc.vo.pu.dhjyd.AggDhjydMasterVO; | ||||
| import nc.itf.pu.dhjyd.dhjydmaster.IDhjydMasterVOService; | ||||
| /* | ||||
|  *	导出 | ||||
|  */ | ||||
| public class AggDhjydMasterVOExcelOutputProcessor extends AbstractExcelOutputProcessor { | ||||
| //z住宿 | ||||
| 	@Override | ||||
| 	public File writeExportData(String filename, Object[] values, List<InputItem> inputitems, | ||||
| 			BillDefination billDefination) throws Exception { | ||||
| 		return super.writeExportData(filename, values, inputitems, billDefination); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	public File writeExportData(String filename, Object[] values, List<InputItem> inputitems, | ||||
| 			BillDefination billDefination, boolean isExportByTemp, Map<String, AreaVO> areamap) throws Exception { | ||||
| 		return super.writeExportData(filename, values, inputitems, billDefination, isExportByTemp, areamap); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	public Object[] getObjectValueByPks(String[] pks) throws BusinessException { | ||||
| 		// 要改成调用接口根据前端传过来的pks参数查询对应VO返回 | ||||
| 		AggDhjydMasterVO[] queryResult = getService().listAggDhjydMasterVOByPk(pks); | ||||
| 		if (queryResult == null || queryResult.length <= 0) { | ||||
| 			return null; | ||||
| 		} | ||||
| 		return queryResult; | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	protected ExportDataInfo getValue(Object[] vos, List<InputItem> exportItems, BillDefination billdefination) | ||||
| 			throws BusinessException { | ||||
| 		ExtendedAggregatedValueObject[] aggvos = getConvertorForTemp(new DefRefPropertyProcess()) | ||||
| 				.convertDataFromEditorData(billdefination, vos, exportItems); | ||||
| 			return new ExportDataInfo(aggvos); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	public void setAreamap(Map<String, AreaVO> areamap) { | ||||
| 		super.setAreamap(areamap); | ||||
| 	} | ||||
| 
 | ||||
| 	private IDhjydMasterVOService getService() { | ||||
| 		return NCLocator.getInstance().lookup(IDhjydMasterVOService.class); | ||||
| 	} | ||||
| 	class DefRefPropertyProcess implements IRefPropertyProcess{ | ||||
| 
 | ||||
| 		@Override | ||||
| 		public void ProcessRefProperty(AbstractRefModel refmodel) { | ||||
| 			refmodel.setSealedDataShow(true); | ||||
| 		} | ||||
| 
 | ||||
| 		@Override | ||||
| 		public AbstractRefModel getRefModelByProperty(FormPropertyVO property) { | ||||
| 			String classid = property.getClassid(); | ||||
| 			String pid = null; | ||||
| 			try { | ||||
| 				IBusinessEntity entity = (IBusinessEntity)MDBaseQueryFacade.getInstance().getBeanByID(classid); | ||||
| 				pid = entity.getBizInterfaceMapInfo("nc.vo.bd.meta.IBDObject") == null ? null : entity.getBizInterfaceMapInfo("nc.vo.bd.meta.IBDObject").get("pid"); | ||||
| 			} catch (MetaDataException e) { | ||||
| 				throw new RuntimeException(e); | ||||
| 			} | ||||
| 			// 1、判断是否有树形上级参照自身字段 | ||||
| 			if("04dd87e3-2bda-45d5-879b-3e320a4bc3d3".equals(classid) && pid != null && pid.equals(property.getCode())) { | ||||
| 				DefAbstractRefModel refModel = new DefAbstractRefModel(property); | ||||
| 				return refModel; | ||||
| 			} | ||||
| 			return null; | ||||
| 		}} | ||||
| 	class DefAbstractRefModel extends AbstractRefModel{ | ||||
| 		FormPropertyVO property; | ||||
| 		String tablename; | ||||
| 		String pkcolname; | ||||
| 		String pkattrname; | ||||
| 		String codename; | ||||
| 		String namename; | ||||
| 		public DefAbstractRefModel(FormPropertyVO property) { | ||||
| 			super(); | ||||
| 			this.property = property; | ||||
| 			String classid = property.getClassid(); | ||||
| 			IBusinessEntity entity; | ||||
| 			Map<String, String> bizInterfaceMapInfo; | ||||
| 			try { | ||||
| 				entity = (IBusinessEntity)MDBaseQueryFacade.getInstance().getBeanByID(classid); | ||||
| 				bizInterfaceMapInfo = entity.getBizInterfaceMapInfo("nc.vo.bd.meta.IBDObject"); | ||||
| 			} catch (MetaDataException e) { | ||||
| 				throw new RuntimeException(e); | ||||
| 			} | ||||
| 			tablename = entity.getTable().getName(); | ||||
| 			pkcolname = entity.getKeyAttribute().getColumn().getName(); | ||||
| 			pkattrname = entity.getKeyAttribute().getName(); | ||||
| 			codename = bizInterfaceMapInfo.get("code"); | ||||
| 			namename = bizInterfaceMapInfo.get("name"); | ||||
| 			this.reset(); | ||||
| 		} | ||||
| 		@Override | ||||
| 		public void reset() { | ||||
| 			this.setFieldCode(new String[] {codename}); | ||||
| 			this.setFieldName(new String[] {namename}); | ||||
| 			this.setTableName(this.tablename); | ||||
| 			this.setPkFieldCode(this.pkattrname); | ||||
| 			this.setRefCodeField(codename); | ||||
| 			this.setRefNameField(namename); | ||||
| 			this.resetFieldName(); | ||||
| 		} | ||||
| 		@Override | ||||
| 		public String[] getFieldCode() { | ||||
| 			return new String[] {pkcolname, codename, namename}; | ||||
| 		} | ||||
| 		@Override | ||||
| 		public String[] getFieldName() { | ||||
| 			return new String[] {pkcolname, codename, namename}; | ||||
| 		} | ||||
| 		@Override | ||||
| 		public String getWherePart() { | ||||
| 			return " 1 = 1 "; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -1,52 +1,54 @@ | |||
| package nc.bs.pu.dhjyd; | ||||
| 
 | ||||
| import nc.bs.dao.BaseDAO; | ||||
| import nc.bs.pub.pf.CheckStatusCallbackContext; | ||||
| import nc.bs.pub.pf.ICheckStatusCallback; | ||||
| import nc.itf.uap.pf.metadata.IFlowBizItf; | ||||
| import nc.md.data.access.NCObject; | ||||
| import nc.vo.pub.AggregatedValueObject; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pub.SuperVO; | ||||
| 
 | ||||
| /** | ||||
| * 对应单据类型中的审批流检查类。 | ||||
| * 检查过程判断如果不是终止流程则会return返回。 | ||||
| * 如果从流程实例管理节点终止流程实例,或者收回单据时会更新单据状态。 | ||||
| */ | ||||
| public class PfDhjydMasterVOCheck implements ICheckStatusCallback { | ||||
| 
 | ||||
|     private BaseDAO baseDAO = null; | ||||
| 
 | ||||
|     @Override | ||||
|     public void callCheckStatus(CheckStatusCallbackContext cscc) throws BusinessException { | ||||
|         if (!cscc.isTerminate()||cscc.getBillVo()==null) { | ||||
|         	return ; | ||||
|         } | ||||
|         NCObject ncObj = NCObject.newInstance(cscc.getBillVo()); | ||||
|         IFlowBizItf itf = ncObj.getBizInterface(IFlowBizItf.class); | ||||
|         String[] fields = new String[1]; | ||||
|         // 从上下文获取审批状态 | ||||
|         itf.setApproveStatus(cscc.getCheckStatus()); | ||||
|         // 审批状态的字段 | ||||
|         fields[0] = itf.getColumnName(IFlowBizItf.ATTRIBUTE_APPROVESTATUS); | ||||
|          | ||||
|         // 保存修改后数据 | ||||
|         SuperVO vo = (SuperVO) ((AggregatedValueObject) cscc.getBillVo()).getParentVO(); | ||||
|         if(vo==null){ | ||||
|         	return; | ||||
|         } | ||||
|         // 更新vo | ||||
|         getBaseDAO().updateVO(vo, fields); | ||||
|         // 更新parentVO | ||||
|         vo = (SuperVO) getBaseDAO().retrieveByPK(vo.getClass(), vo.getPrimaryKey()); | ||||
|         ((AggregatedValueObject) cscc.getBillVo()).setParentVO(vo); | ||||
|     } | ||||
| 
 | ||||
|     private BaseDAO getBaseDAO() { | ||||
|         if (baseDAO == null) { | ||||
|             baseDAO = new BaseDAO(); | ||||
|         } | ||||
|         return baseDAO; | ||||
|     } | ||||
| } | ||||
| package nc.bs.pu.dhjyd; | ||||
| 
 | ||||
| import nc.bs.dao.BaseDAO; | ||||
| import nc.bs.pub.pf.CheckStatusCallbackContext; | ||||
| import nc.bs.pub.pf.ICheckStatusCallback; | ||||
| import nc.itf.uap.pf.metadata.IFlowBizItf; | ||||
| import nc.md.data.access.NCObject; | ||||
| import nc.vo.pub.AggregatedValueObject; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pub.SuperVO; | ||||
| 
 | ||||
| /** | ||||
| * 对应单据类型中的审批流检查类。 | ||||
| * 检查过程判断如果不是终止流程则会return返回。 | ||||
| * 如果从流程实例管理节点终止流程实例,或者收回单据时会更新单据状态。 | ||||
| */ | ||||
| public class PfDhjydMasterVOCheck implements ICheckStatusCallback { | ||||
| 
 | ||||
| 	 | ||||
| 	 | ||||
|     private BaseDAO baseDAO = null; | ||||
| 
 | ||||
|     @Override | ||||
|     public void callCheckStatus(CheckStatusCallbackContext cscc) throws BusinessException { | ||||
|         if (!cscc.isTerminate()||cscc.getBillVo()==null) { | ||||
|         	return ; | ||||
|         } | ||||
|         NCObject ncObj = NCObject.newInstance(cscc.getBillVo()); | ||||
|         IFlowBizItf itf = ncObj.getBizInterface(IFlowBizItf.class); | ||||
|         String[] fields = new String[1]; | ||||
|         // 从上下文获取审批状态 | ||||
|         itf.setApproveStatus(cscc.getCheckStatus()); | ||||
|         // 审批状态的字段 | ||||
|         fields[0] = itf.getColumnName(IFlowBizItf.ATTRIBUTE_APPROVESTATUS); | ||||
|          | ||||
|         // 保存修改后数据 | ||||
|         SuperVO vo = (SuperVO) ((AggregatedValueObject) cscc.getBillVo()).getParentVO(); | ||||
|         if(vo==null){ | ||||
|         	return; | ||||
|         } | ||||
|         // 更新vo | ||||
|         getBaseDAO().updateVO(vo, fields); | ||||
|         // 更新parentVO | ||||
|         vo = (SuperVO) getBaseDAO().retrieveByPK(vo.getClass(), vo.getPrimaryKey()); | ||||
|         ((AggregatedValueObject) cscc.getBillVo()).setParentVO(vo); | ||||
|     } | ||||
| 
 | ||||
|     private BaseDAO getBaseDAO() { | ||||
|         if (baseDAO == null) { | ||||
|             baseDAO = new BaseDAO(); | ||||
|         } | ||||
|         return baseDAO; | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue