EASGUI常用代码和功能点

常用代码

扩展方式

前台:client后加PIEx和CTEx,原理本文中介绍了
后台:动态扩展平台实体配置扩展类为*****controllerBeanEx,然后后台开发继承原本controllerBean的controllerBeanEX类,重写具体方法
dep扩展:略
web扩展平台:略

webservice对接

创建webserviceFacade,发布webservice,按照下文的方式部署webservice
制定具体json或xml格式解析单据信息,封装好后调用对应factory的addnew方法新增单据

可关联导入导出模板的webservice引入

同上发布webservice接口后,接口参数增加模板编号,对应eas的引入引出模板
webservice接口获取json数据后,通过模板字段解析json
通过metadata解析元数据实体属性,遍历key和json构造单据对象
参考工具类:


import java.math.BigDecimal;
import java.text.MessageFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.IObjectCollection;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.framework.DynamicObjectFactory;
import com.kingdee.bos.metadata.MetaDataLoaderFactory;
import com.kingdee.bos.metadata.entity.DataType;
import com.kingdee.bos.metadata.entity.EntityObjectInfo;
import com.kingdee.bos.metadata.entity.LinkPropertyInfo;
import com.kingdee.bos.metadata.entity.OwnPropertyInfo;
import com.kingdee.bos.metadata.entity.PropertyCollection;
import com.kingdee.bos.metadata.entity.PropertyInfo;
import com.kingdee.bos.metadata.entity.RelationshipType;
import com.kingdee.bos.util.BOSObjectType;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.basedata.master.material.MaterialInfo;
import com.kingdee.eas.ep.BillEntryCustomCollection;
import com.kingdee.eas.ep.BillEntryCustomInfo;
import com.kingdee.eas.fi.ap.OtherBillInfo;
import com.kingdee.eas.fi.ap.OtherBillType;
import com.kingdee.eas.fi.ap.OtherBillentryCollection;
import com.kingdee.eas.fi.ap.PayRequestBillInfo;
import com.kingdee.eas.fm.common.FMConstants;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.framework.CoreBillEntryBaseCollection;
import com.kingdee.eas.framework.CoreBillEntryBaseInfo;
import com.kingdee.eas.util.ResourceBase;
import com.kingdee.util.TypeConversionUtils;

public class Sfimportor {
    
    
	 
	public  CoreBaseInfo preImportApOtherBill(Context ctx, JSONObject hsData, HashMap keyMap,CoreBaseInfo info) throws BOSException{
    
    
		CoreBaseInfo otherbillinfo = preImport(ctx, hsData, keyMap,  BOSObjectType.create("48DA3A71"), info); 
		return otherbillinfo;
	}
	public CoreBaseInfo preImport(Context ctx, JSONObject hsData, HashMap keyMap,
			BOSObjectType destBostype,CoreBaseInfo info) throws BOSException {
    
    

		BOSObjectType type = destBostype;
		EntityObjectInfo entity = MetaDataLoaderFactory.getLocalMetaDataLoader(
				ctx).getEntity(type);
		PropertyCollection properties = entity.getPropertiesRuntime(); 
		try {
    
    
			if(info.getId() == null){
    
    
				info = (CoreBaseInfo) Class.forName(
						entity.getBusinessImplName() + "Info").newInstance();
			}
		} catch (Exception e) {
    
    
			throw new BOSException(e);
		}

		for (int i = 0; i < properties.size(); ++i) {
    
    
			PropertyInfo prop = properties.get(i);
			String name = prop.getName();
			if (name == null) {
    
    
				continue;
			}
			Object data = hsData.get(keyMap.get(name));
			if (data == null || data == "")
				continue;
			IObjectCollection obj;
			if (prop instanceof LinkPropertyInfo) {
    
    
				IObjectValue value = null;
				LinkPropertyInfo new_name = (LinkPropertyInfo) prop;
				EntityObjectInfo sobj = new_name.getRelationship()
						.getSupplierObject();
				if(new_name.getRelationship().getType() == RelationshipType.COMPOSITION){
    
    
					JSONArray entrysJson = JSONArray.fromObject(data);
					IObjectCollection billbizCollection =  (IObjectCollection) info.get(name);
					if(billbizCollection==null){
    
    
						billbizCollection = new BillEntryCustomCollection();
						info.put(name,billbizCollection);
					}
					for(int eni = 0;eni<entrysJson.size();eni++){
    
    
						CoreBillEntryBaseInfo entryinfo;
						EntityObjectInfo enentity = null ;
						BOSObjectType sobjtype = null;
						try{
    
    
							 sobjtype = sobj.getType();
							 enentity = MetaDataLoaderFactory.getLocalMetaDataLoader(
									ctx).getEntity(sobjtype);
							 entryinfo = (CoreBillEntryBaseInfo) Class.forName(
									enentity.getBusinessImplName() + "Info").newInstance();
						}catch (ClassNotFoundException e){
    
    
							 entryinfo = new BillEntryCustomInfo();
						} catch (Exception e) {
    
    
							throw new BOSException(e);
						}
						if(entryinfo.getId()==null){
    
    
							entryinfo.setId(BOSUuid.create(sobjtype));
						}
						prepareImport(ctx, entryinfo, JSONObject.fromObject(entrysJson.get(eni)), name,keyMap,enentity);
						billbizCollection.addObject(entryinfo);
					}
				}else{
    
    
					BOSObjectType sobjtype = sobj.getType();
					obj = getCollectionByNumber(ctx, data, sobjtype);
					if ((obj != null) && (obj.size() >= 1)) {
    
    
						value = obj.getObject(0);
						info.put(name, value);
					}else{
    
    
						String msgStr = MessageFormat.format(ResourceBase.getString(
								"com.kingdee.eas.fi.cas.CASHandResource",
								"dataTransferError", ctx.getLocale()),
								new Object[] {
    
      keyMap.get(name).toString()+data  });
						throw new BOSException(msgStr);
					}
				}
			} else {
    
    
				if (!(prop instanceof OwnPropertyInfo))
					continue;
				OwnPropertyInfo new_name = (OwnPropertyInfo) prop;
				DataType datatype = new_name.getDataType();
				if (datatype == DataType.STRING) {
    
    
					info.setString(name, getString(ctx, data));
				} else if (datatype == DataType.DATE) {
    
    
					info.setDate(name, getDate(ctx, data));
				} else if (datatype == DataType.TIMESTAMP) {
    
    
					info.setDate(name, getDate(ctx, data));
				} else if (datatype == DataType.DECIMAL) {
    
    
					info.setBigDecimal(name, getAmount(ctx, data));
				} else if (datatype == DataType.INTEGER){
    
    
					info.setInt(name, getInt(ctx, data));
				} else if (datatype == DataType.BOOLEAN){
    
    
					info.setBoolean(name, Boolean.valueOf(String.valueOf(data)));
				}
			}
		}
		return info ;
	}

	protected int getInt(Context ctx, Object data) throws BOSException {
    
    
		if ((data == null) || (data.toString().trim().length() == 0)) {
    
    
			return 0;
		}
		int value;
		try {
    
    
			value = TypeConversionUtils.objToInt(data);
		} catch (Exception e) {
    
    
			String msgStr = MessageFormat.format(ResourceBase.getString(
					"com.kingdee.eas.fi.cas.CASHandResource",
					"dataTransferError", ctx.getLocale()),
					new Object[] {
    
     data });
			throw new BOSException(msgStr);
		}
		return value;
	}

	protected String getString(Context ctx, Object data) {
    
    
		if ((data == null) || (data.toString().trim().length() == 0)) {
    
    
			return null;
		}
		return data.toString().trim();
	}

	protected Date getDate(Context ctx, Object data) throws BOSException {
    
    
		if ((data == null) || (data.toString().trim().length() == 0)) {
    
    
			return null;
		}
		Date date = null;
		try {
    
    
			date = TypeConversionUtils.objToUtilDate(data);
		} catch (Exception e) {
    
    
			try {
    
    
				date = new SimpleDateFormat().parse(data.toString());
			} catch (ParseException e1) {
    
    
				String msgStr = MessageFormat.format(ResourceBase.getString(
						"com.kingdee.eas.fi.cas.CASHandResource",
						"dateTransferError", ctx.getLocale()),
						new Object[] {
    
     data });
				throw new BOSException(msgStr);
			}

		}

		return date;
	}

	protected BigDecimal getAmount(Context ctx, Object data)
			throws BOSException {
    
    
		if ((data == null) || (data.toString().trim().length() == 0)) {
    
    
			return FMConstants.ZERO;
		}

		BigDecimal value = null;
		try {
    
    
			value = TypeConversionUtils.objToBigDecimal(data);
		} catch (Exception e) {
    
    
			String msgStr = MessageFormat.format(ResourceBase.getString(
					"com.kingdee.eas.fi.cas.CASHandResource",
					"dataTransferError", ctx.getLocale()),
					new Object[] {
    
     data });
			throw new BOSException(msgStr);
		}
		return value;
	}
	public IObjectCollection getCollectionByNumber(Context ctx, Object data,
			BOSObjectType sobjtype) throws BOSException {
    
    
		IObjectCollection obj = null;
		try {
    
    
			obj = DynamicObjectFactory.getLocalInstance(ctx).getCollection(
					sobjtype,
					"select * where number ='" + data + "' or name='" + "'");
		} catch (Exception exp) {
    
    
			exp.printStackTrace();
		}
		return obj;
	}
	protected void prepareImport(Context ctx, IObjectValue info,
			JSONObject hsData, String prefix, HashMap keyMap, EntityObjectInfo enentity) throws BOSException {
    
    
		PropertyCollection properties = enentity.getPropertiesRuntime();
		if(info instanceof BillEntryCustomInfo){
    
    
			info = (BillEntryCustomInfo)info;
			((BillEntryCustomInfo) info).setBOSType(enentity.getBOSType());
		}
		for (int i = 0; i < properties.size(); ++i) {
    
    
			PropertyInfo prop = properties.get(i);
			String name = prop.getName();
			if (name == null) {
    
    
				continue;
			}
			String importKey = null;
			if (prefix==null||prefix.length()==0) {
    
    
				importKey = name;
			} else {
    
    
				importKey = prefix + "." + name;
			}
			Object data = hsData.get(keyMap.get(importKey));
			if (data == null)
				continue;
			IObjectCollection obj;
			if (prop instanceof LinkPropertyInfo) {
    
    
				IObjectValue value = null;
				LinkPropertyInfo new_name = (LinkPropertyInfo) prop;
				EntityObjectInfo sobj = new_name.getRelationship()
						.getSupplierObject();
				BOSObjectType sobjtype = sobj.getType();
				obj = getCollectionByNumber(ctx, data, sobjtype);
				if ((obj != null) && (obj.size() >= 1)) {
    
    
					value = obj.getObject(0);
					info.put(name, value);
				}else{
    
    
					String msgStr = MessageFormat.format(ResourceBase.getString(
							"com.kingdee.eas.fi.cas.CASHandResource",
							"dataTransferError", ctx.getLocale()),
							new Object[] {
    
     keyMap.get(importKey).toString()+data });
					throw new BOSException(msgStr);
				}
			} else {
    
    
				if (!(prop instanceof OwnPropertyInfo))
					continue;
				OwnPropertyInfo new_name = (OwnPropertyInfo) prop;
				DataType datatype = new_name.getDataType();
				if (datatype == DataType.STRING) {
    
    
					info.setString(name, getString(ctx, data));
				} else if (datatype == DataType.DATE) {
    
    
					info.setDate(name, getDate(ctx, data));
				} else if (datatype == DataType.TIMESTAMP) {
    
    
					info.setDate(name, getDate(ctx, data));
				} else if (datatype == DataType.DECIMAL) {
    
    
					info.setBigDecimal(name, getAmount(ctx, data));
				} else if (datatype == DataType.INTEGER){
    
    
					info.setInt(name, getInt(ctx, data));
				} else if (datatype == DataType.BOOLEAN){
    
    
					info.setBoolean(name, Boolean.valueOf(String.valueOf(data)));
				}
			}
		}
	}

}

附件对接

FTP对接

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.SocketException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Vector;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.net.ftp.FTPSClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jcraft.jsch.SftpException;
import com.kingdee.bos.BOSException;
import com.kingdee.eas.custom.sf.rp.app.SFTPUtil.miTM;
public class FTPSUtil {
    
    
	private static final Logger logger = LoggerFactory.getLogger(FTPSUtil.class);
	public static final String NO_FILE = "No such file";
	private String username;
	private String password;
	private String host;
	private int port;
	private FTPSClient ftpClient = new FTPSClient(true);
	
	private FileOutputStream fos = null;

	public FTPSUtil(String username, String password, String host, int port) {
    
    
		this.username = username;
		this.password = password;
		this.host = host;
		this.port = port;
	}

	public void connect() throws BOSException {
    
    
		try {
    
    
			logger.info("开始连接...");
			logger.info("[username]" + username + "[host]" + host + "[port]" + port + "[password]" + password);
			// 连接
			
			this.ftpClient.setConnectTimeout(10*1000);
			ignoreSsl();
			this.ftpClient.connect(host, port);
			int reply = this.ftpClient.getReplyCode();
			if (!FTPReply.isPositiveCompletion(reply)) {
    
    
				this.ftpClient.disconnect();
				throw new BOSException("连接失败!");
			}
			// 登录
			logger.info("开始登录!");
			this.ftpClient.login(username, password);
			this.ftpClient.setBufferSize(1024 * 30);
			this.ftpClient.setDataTimeout(600000);
			this.ftpClient.setControlKeepAliveReplyTimeout(12000);
			this.ftpClient.setControlKeepAliveTimeout(1200);
			this.ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
			this.ftpClient.execPROT("P");
			this.ftpClient.enterLocalPassiveMode(); // 设置被动模式去传输
			this.ftpClient.setUseEPSVwithIPv4(true);
			this.ftpClient.setControlEncoding("utf8");
			logger.info("登录成功!");
		} catch (SocketException e) {
    
    
			logger.error("连接失败!", e);
			throw new BOSException("连接失败!"+e);
		} catch (Exception e) {
    
    
			logger.error("下载失败!", e);
			throw new BOSException("下载失败!"+e);
		}
	}

	private boolean downFileOrDirNoClose(String ftpFileName, String localDir) {
    
    
		boolean flag = false;
		try {
    
    
			// 源文件
			File file = new File(ftpFileName);
			// 目标文件
			File temp = new File(localDir);
			if (!temp.exists()) {
    
    
				temp.mkdirs();
			}
			ftpClient.enterLocalPassiveMode();
			// 判断是否是目录
			if (isDir(ftpFileName)) {
    
    
				String[] names = ftpClient.listNames();
				for (int i = 0; i < names.length; i++) {
    
    
					logger.info(names[i] + "^^^^^^^^^^^^^^");
					if (isDir(names[i])) {
    
    
						downFileOrDirNoClose(ftpFileName + '/' + names[i], localDir + File.separator + names[i]);
						ftpClient.changeToParentDirectory();
					} else {
    
    
						File localfile = new File(localDir + File.separator + names[i]);
						if (!localfile.exists()) {
    
    
							fos = new FileOutputStream(localfile);
							ftpClient.retrieveFile(names[i], fos);
						} else {
    
    
							// 文件已存在,先进行删除
							logger.debug("开始删除已存在文件");
							file.delete();
							logger.debug("已存在文件已经删除");
							fos = new FileOutputStream(localfile);
							ftpClient.retrieveFile(ftpFileName, fos);
						}
					}
				}
			} else {
    
    
				File localfile = new File(localDir + File.separator + file.getName());
				if (!localfile.exists()) {
    
    
					fos = new FileOutputStream(localfile);
					if (ftpClient.retrieveFile(ftpFileName, fos)) {
    
    
						logger.info("下载成功");
						return true;
					} else {
    
    
						logger.info("下载失败");
						return false;
					}

				} else {
    
    
					// 文件已存在,先进行删除
					logger.debug("开始删除已存在文件");
					file.delete();
					logger.debug("已存在文件已经删除");
					fos = new FileOutputStream(localfile);
					if (ftpClient.retrieveFile(ftpFileName, fos)) {
    
    
						logger.info("下载成功");
						return true;
					} else {
    
    
						logger.info("下载失败");
						return false;
					}
				}
			}
			flag = true;

		} catch (SocketException e) {
    
    
			logger.error("连接失败!", e);
		} catch (Exception e) {
    
    
			logger.error("下载失败!", e);
		}
		return flag;
	}

	/**
	 * * 手动关闭连接
	 */
	public void closeFtpClient() {
    
    
		try {
    
    
			ftpClient.logout();
		} catch (IOException e) {
    
    
			logger.error("ftpClient.logout()执行失败", e);
		}
		close(fos);
	}

	/**
	 * * 关闭连接及输出流 * * @param fos
	 */
	private void close(FileOutputStream fos) {
    
    
		try {
    
    

			if (fos != null) {
    
    
				fos.close();
			}
			logger.info("退出登录");
			if (this.ftpClient != null) {
    
    
				try {
    
    
					ftpClient.disconnect();
					ftpClient = null;
				} catch (IOException ioe) {
    
    
					logger.error("ftpClient.disconnect()执行失败", ioe);
				}

			}
			logger.info("关闭连接");
		} catch (IOException e) {
    
    
			logger.error("关闭连接失败", e);
		}
	}

	public boolean downloadFile(String ftpFileName, String localDir) throws BOSException {
    
    
		connect();
		boolean flag = false;
		flag = downFileOrDirNoClose(ftpFileName, localDir);
		return flag;
	}

	/**
	 * * 判断是否是目录 * * @param fileName * @return
	 */
	public boolean isDir(String fileName) {
    
    
		boolean flag = false;
		try {
    
    
			// 切换目录,若当前是目录则返回true,否则返回false。
			flag = ftpClient.changeWorkingDirectory(fileName);
		} catch (Exception e) {
    
    
			logger.error("判断目录失败", e);
		}
		return flag;
	}
	/**
     * 下载文件。
     * @param directory 下载目录
     * @param downloadFile 下载的文件
     * @param saveFile 存在本地的路径
     * @throws IOException 
	 * @throws BOSException 
     */
	public boolean download(String directory, String downloadFile, String saveFile) throws IOException, BOSException {
    
    
		if (!this.ftpClient.isConnected()) {
    
    
			connect();
		}
		boolean flag = false;
		if (this.ftpClient.isConnected()) {
    
    
			OutputStream os=null;
	    	if (directory != null && !"".equals(directory)) {
    
    
	    		ftpClient.changeWorkingDirectory(directory);
	        }
	        File localFile = new File(saveFile + "/" + downloadFile);
	        if (!localFile.getParentFile().exists()) {
    
    
	            localFile.getParentFile().mkdirs();
	            localFile.createNewFile();
	        }
	        os = new FileOutputStream(localFile);
	        ftpClient.retrieveFile(downloadFile, os);
	        os.close();
	        flag=true;
		}
		return flag;
	}

	/**
	 * * 下载 * * @param strUrlPath * @param strLocalPath * @param strFolderPath
	 * * @return
	 */
	public boolean downloadFile(String strUrlPath, String strLocalPath, String strFolderPath) {
    
    
		boolean result = true;
		GetMethod httpGet = new GetMethod(strUrlPath);
		if (!strFolderPath.equals("")) {
    
    
			File Folder = new File(strFolderPath);
			if (!Folder.exists()) {
    
    
				System.out.println(Folder.mkdirs());
			}
		}

		InputStream in = null;
		FileOutputStream out = null;
		try {
    
    
			HttpClient httpClient = new HttpClient();
			httpClient.executeMethod(httpGet);
			in = httpGet.getResponseBodyAsStream();
			out = new FileOutputStream(new File(strLocalPath));
			byte[] b = new byte[1024];
			int len = 0;
			while ((len = in.read(b)) != -1) {
    
    
				out.write(b, 0, len);
			}
			in.close();
			out.close();
		} catch (Exception e) {
    
    
			logger.error("httpClient下载文件失败", e);
			result = false;
		} finally {
    
    
			httpGet.releaseConnection();
			try {
    
    
				if (in != null) {
    
    
					in.close();
				}
				if (out != null) {
    
    
					out.close();
				}
			} catch (Exception e1) {
    
    
				logger.error("文件流信息关闭失败", e1);
				result = false;
			}

		}
		logger.info("####下载文件成功:" + strUrlPath);
		return result;
	}
	/**
     * 列出目录下的文件
     * @param directory 要列出的目录
	 * @throws IOException 
     */
    public Vector<?> listFiles(String directory) throws SftpException, IOException {
    
    
    	ArrayList<String> arFiles;
    	ftpClient.changeWorkingDirectory(directory);
    	Vector<FTPFile> v = new Vector();
    	 FTPFile[] files = ftpClient.listFiles();
    	 for (FTPFile file : files) {
    
    
    		 if (file.isFile()) {
    
    
    			 v.addElement(file);
    		 }
    	 }
    	 return v;
    }
    public static void ignoreSsl() throws Exception{
    
    
    	HostnameVerifier hv = new HostnameVerifier() {
    
    
    		public boolean verify(String urlHostName, SSLSession session) {
    
    
    			System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
    			return true;
    		}
    	};
    	trustAllHttpsCertificates();
    	HttpsURLConnection.setDefaultHostnameVerifier(hv);
    }
    private static void trustAllHttpsCertificates() throws Exception {
    
    
    	TrustManager[] trustAllCerts = new TrustManager[1];
    	TrustManager tm = new miTM();
    	trustAllCerts[0] = tm;
    	SSLContext sc = SSLContext.getInstance("SSL");
    	sc.init(null, trustAllCerts, null);
    	HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    }
    static class miTM implements TrustManager,X509TrustManager {
    
    
        public X509Certificate[] getAcceptedIssuers() {
    
    
            return null;
        }
 
        public boolean isServerTrusted(X509Certificate[] certs) {
    
    
            return true;
        }
 
        public boolean isClientTrusted(X509Certificate[] certs) {
    
    
            return true;
        }
 

		@Override
		public void checkClientTrusted(
				X509Certificate[] paramArrayOfX509Certificate,
				String paramString) throws CertificateException {
    
    
			return;
		}

		@Override
		public void checkServerTrusted(
				X509Certificate[] paramArrayOfX509Certificate,
				String paramString) throws CertificateException {
    
    
			return;
		}
    }

}

定时任务

1、创建Facade元数据,注意:命名规则要求Facade结尾,可配置参数
发布facade代码
2、部署到{eashom}\eas\server\metas\sp和{eashom}\eas\server\lib\sp,重新生成子系统树
3、找到后台事务定义,配置具体功能和时间频率

单据listui改造为共享

   @Override
	protected FilterInfo getDefaultFilterForQuery() {
    
    
    	//5月15日新增,按照用户有权限的组织过滤查询,目前关联权限为银行对账表查询权限
		Set<String> ids = getAuthorizedOrgIds(new ObjectUuidPK(SysContext.getSysContext().getCurrentUserInfo().getId()));
		FilterInfo filter = super.getDefaultFilterForQuery();
		FilterInfo filter2 = new FilterInfo();
		filter2.getFilterItems().add(new FilterItemInfo("FICompany.id",ids,CompareType.INCLUDE));
		try {
    
    
			filter.mergeFilter(filter2, "AND");
		} catch (BOSException e) {
    
    
			e.printStackTrace();
		}
		return filter;
	}
    
    @SuppressWarnings("unchecked")
	public Set<String> getAuthorizedOrgIds(IObjectPK userpk){
    
    
    	String cuid = SysContext.getSysContext().getCurrentCtrlUnit().getId().toString();
		try {
    
    
			return PermissionFactory.getRemoteInstance().getAuthorizedOrgIds(userpk, OrgType.Company,new ObjectUuidPK(BOSUuid.read(cuid)), "custome_saleRecRpt_view");//成本报表查询
		} catch (EASBizException e) {
    
    
			MsgBox.showConfirm2("获取用户权限组织范围异常");
			SysUtil.abort();
		} catch (BOSException e) {
    
    
			MsgBox.showConfirm2("获取用户权限组织范围异常");
			SysUtil.abort();
		}
		return new HashSet<String>();
	}
 @Override
    protected boolean isIgnoreCUFilter() {
    
    
    	return true;
    }

分析辅助

服务器debug启动方式

服务器debug启动目的是跟踪断点服务端代码分析问题,适用于非正式环境
启动后可以用bos或eclipse远程调试,端口8000

linux服务器

cd打开{eashom}\eas\server\profiles\server*\bin下
集群环境建议启动server2
单实例不要用管理控制台启动即可
sh startserver.sh debug 等待启动
sh killserver.sh 杀服务

windows服务器

打开{eashom}\eas\server\profiles\server*\bin下
双击debugserver.bat

序时簿界面查询sql

返回sql通过方法com.kingdee.bos.metadata.query.util.QuerySqlAccessBase.getSql(boolean, Map<Integer, Object>)解析,可在此处断点截取sql

piex和ctex原理

com.kingdee.eas.base.uiframe.client.UIFactoryHelper.initUIObject(String, Map, Map, String)
其中调用
com.kingdee.bos.ui.face.AbstractUIFactory.createUIObjectNoInit(String)
对应代码:

public static IUIObject createUIObjectNoInit(String name)
			throws UIException {
    
    
		try {
    
    
			Class c = null;
			try {
    
    
				c = Class.forName(name + "CTEx", false, AbstractUIFactory.class
						.getClassLoader());
			} catch (ClassNotFoundException ex) {
    
    
				try {
    
    
					c = Class.forName(name + "PIEx", false,
							AbstractUIFactory.class.getClassLoader());
				} catch (ClassNotFoundException _) {
    
    
					c = Class.forName(name);
				}
			}
			IUIObject uiObj = (IUIObject) c.newInstance();
			return uiObj;
		} catch (Exception e) {
    
    
			throw new UIException("Can not create ui object!", e);
		}
	}

sql设置f7过滤

public static void prmtAdDept_willShow(SelectorEvent e,KDBizPromptBox prmtAdCompany,KDBizPromptBox prmtAdDept) throws Exception {
    
    
    	ClientUtil.checkControlLegitimacy(new JComponent[]{
    
    prmtAdCompany}, e);
    	ADCompanyMapInfo adCompanyInfo = (ADCompanyMapInfo) prmtAdCompany.getValue();
    	String adCompLongNumber = adCompanyInfo.getLongNumber();
		StringBuffer sql=new StringBuffer();
		sql.append(" SELECT fid   FROM CT_SCP_ADCompanyMap WHERE FLongNumber like '%").append(adCompLongNumber).append("%' ");
//    	EntityViewInfo view=FilterUtil.getEntityViewInfo("id", "id",CompareType.INNER);
		EntityViewInfo view=FilterUtil.getEntityViewInfo("id",sql.toString(),CompareType.INNER);
    	view.getFilter().getFilterItems().add(new FilterItemInfo("orgUnit.id",null,CompareType.NOTEQUALS));
		prmtAdDept.setEntityViewInfo(view);
		prmtAdDept.getQueryAgent().resetRuntimeEntityView();
}

botp 配自定义公式

Botp新建一个规则里面按f9
例:取科目

java.lang.StringBuffer sql = new java.lang.StringBuffer();
sql.append("select                                                              \t\n");
sql.append("top 1                                                               \t\n");
sql.append("   c.fnumber, --组织编码                                            \t\n");
sql.append("  b.FPERIOD, --期间                                                 \t\n");
sql.append("  cy.fname_l2, --币别                                               \t\n");
sql.append("  av.fnumber as facctnum, --科目编码                                \t\n");
sql.append("  hg.FLONGNAMEGROUP_L2, --核算项目组合                              \t\n");
sql.append("  b.FBEGINBALANCEFOR, --期初余额                                    \t\n");
sql.append("  b.FDEBITFOR, --本期借方发生                                       \t\n");
sql.append("  b.FCREDITFOR, --本期贷方发生                                      \t\n");
sql.append("  b.FENDBALANCEFOR, --期末余额                                      \t\n");
sql.append("hg.FASSTACCOUNTID                                                   \t\n");
sql.append("from T_GL_ASSISTBALANCE_1F b --过账辅助余额表                       \t\n");
sql.append("join t_org_company c on c.fid = b.forgunitid                        \t\n");
sql.append("join t_bd_accountview av on av.fid = b.faccountid                   \t\n");
sql.append("join t_bd_assistanthg hg on hg.fid = b.fassistgrpid                 \t\n");
sql.append("join t_bd_currency cy on cy.fid = b.fcurrencyid                     \t\n");
sql.append("left join T_BD_AccountBanks ab on ab.FCOMPANYID  = c.fid            \t\n");
sql.append("where 1=1                                                           \t\n");
sql.append("and av.FNUMBER  in ('1221.01','2241.01') --科目编码                 \t\n");
sql.append("and b.FENDBALANCEFOR>0                                              \t\n");
sql.append("and ab.FBANKACCOUNTNUMBER  = '").append(acctNum).append("'          \t\n");
sql.append("and  hg.FLONGNAMEGROUP_L2  like  concat(concat('%',c.FNAME_l2),'%') \t\n");
sql.append("order by  b.FPERIOD desc                                            \t\n");



java.sql.Connection con = com.kingdee.bos.framework.ejb.EJBFactory.getConnection(__bosContext);
java.sql.Statement batchStatement = con.createStatement( );
java.sql.ResultSet rst = batchStatement.executeQuery(sql.toString( ));
String number = "";
while (rst.next( )) 
{
    
     
	number = rst.getString("facctnum").toString();
} 
com.kingdee.util.db.SQLUtils.cleanup(batchStatement , con );
com.kingdee.util.db.SQLUtils.cleanup( con );
return __BOTgetAccountViewByNumber(number);


取核算项目

java.lang.StringBuffer sql = new java.lang.StringBuffer();
sql.append("select                                                              \t\n");
sql.append("top 1                                                               \t\n");
sql.append("   c.fnumber, --组织编码                                            \t\n");
sql.append("  b.FPERIOD, --期间                                                 \t\n");
sql.append("  cy.fname_l2, --币别                                               \t\n");
sql.append("  av.fnumber as facctnum, --科目编码                                \t\n");
sql.append("  hg.FLONGNAMEGROUP_L2, --核算项目组合                              \t\n");
sql.append("  b.FBEGINBALANCEFOR, --期初余额                                    \t\n");
sql.append("  b.FDEBITFOR, --本期借方发生                                       \t\n");
sql.append("  b.FCREDITFOR, --本期贷方发生                                      \t\n");
sql.append("  b.FENDBALANCEFOR, --期末余额                                      \t\n");
sql.append("hg.FASSTACCOUNTID                                                   \t\n");
sql.append("from T_GL_ASSISTBALANCE_1F b --过账辅助余额表                       \t\n");
sql.append("join t_org_company c on c.fid = b.forgunitid                        \t\n");
sql.append("join t_bd_accountview av on av.fid = b.faccountid                   \t\n");
sql.append("join t_bd_assistanthg hg on hg.fid = b.fassistgrpid                 \t\n");
sql.append("join t_bd_currency cy on cy.fid = b.fcurrencyid                     \t\n");
sql.append("left join T_BD_AccountBanks ab on ab.FCOMPANYID  = c.fid            \t\n");
sql.append("where 1=1                                                           \t\n");
sql.append("and av.FNUMBER  in ('1221.01','2241.01') --科目编码                 \t\n");
sql.append("and b.FENDBALANCEFOR>0                                              \t\n");
sql.append("and ab.FBANKACCOUNTNUMBER  = '").append(acctNum).append("'          \t\n");
sql.append("and  hg.FLONGNAMEGROUP_L2  like  concat(concat('%',c.FNAME_l2),'%') \t\n");
sql.append("order by  b.FPERIOD desc                                            \t\n");



java.sql.Connection con = com.kingdee.bos.framework.ejb.EJBFactory.getConnection(__bosContext);
java.sql.Statement batchStatement = con.createStatement( );
java.sql.ResultSet rst = batchStatement.executeQuery(sql.toString( ));
String number = "";
while (rst.next( )) 
{
    
     
	number = rst.getString("FASSTACCOUNTID").toString();
} 
com.kingdee.util.db.SQLUtils.cleanup(batchStatement , con );
com.kingdee.util.db.SQLUtils.cleanup( con );

return com.kingdee.eas.basedata.master.auxacct.AsstAccountFactory.getLocalInstance(__bosContext).getAsstAccountInfo("where id = '"+number+"'");

ksql日期型转换

to_date(‘2019-01-03’)
convert(nvarchar(10),fbizdate,112)
百度参考sqlserver经验

TO_CHAR(fbizdate,‘YYYY-MM-DD’)//好用
to_date(TO_CHAR(fbizdate,‘YYYY-MM-DD’))

Ksql日期形 {ts’2020-06-23’}

配置新webservice接口

1、bos开发工具中,设计开发工具页签,选定路径建立facade,并新增方法,设定参数
2、发布facade元数据
3、设计开发工具页签右键facade发布webservice,选择路径并生成,获得wsdd文件和proxy.java文件
4、刷新java页签下的代码,找到对应路径下的controllerbean
5、controllerbean中写方法的具体实现(可以置后)
6、修改元数据jar包中的.properties文件(bostype=路径)
7、修改服务器上server/deploy/eas.ear/web.war文件中的server-config.wsdd文件(新增facade的wsdd的代码段),并在server-config.wsdd同路径下放入第三步中的wsdd文件
8、在java视图中,controllerbean的路径新增webservice包,放入第三步的proxy.java文件
9、部署,重新生成子系统树

配置log4j

log4j.logger.com.kingdee.eas.el.rec=info, rec
log4j.additivity.com.kingdee.eas.el.rec=false log4j.appender.rec=org.apache.log4j.RollingFileAppender log4j.appender.rec.MaxBackupIndex=10
log4j.appender.rec.MaxFileSize=10MB
log4j.appender.rec.layout=org.apache.log4j.PatternLayout log4j.appender.rec.layout.ConversionPattern=[%t %l %d{yyy MMM dd HH:mm:ss}]%m%n log4j.appender.rec.File=${EAS_INSTANCE_HOME}/logs/rec.log log4j.appender.rec.encoding=UTF-8
在这里插入图片描述

引入引出核心思路

引入系统实现类:com.kingdee.eas.tools.datatask.task.TaskExternalCodeRunner
实现方法:com.kingdee.eas.tools.datatask.task.TaskExternalCodeRunner.onEachRunningLoop()
引出查询方法:
com.kingdee.eas.tools.datatask.task.TaskExportEASDataRunner.onBeforeEachRunningLoop()
引出系统循环构造方法:
com.kingdee.eas.tools.datatask.task.TaskExportEASDataRunner.onEachRunningLoop()
系统控制bean:
com.kingdee.eas.tools.datatask.app.DatataskRunServerControllerBean
引出方法编码不绑定具体导出字段,在代码export中实现每个query字段和excel字段的绑定

一般执行引入后,还会再进一次:
com.kingdee.eas.tools.datatask.DefaultDataTransmission.transmit(Map, CoreBaseInfo)
如果重写了transmit方法, 导致进入DefaultDataTransmission的info对象不为空,会不重新生成info
后续会进dataBinder的tran方法转换
判断位置在DefaultDataTransmission.transmit中,数据塞入和系统补全的对象会在这个方法中体现:
com.kingdee.eas.tools.datatask.databind.DataBinder.trans(Map, CoreBaseInfo)
补全单据字段位置:
com.kingdee.eas.tools.datatask.databind.DataBinder.generateInfo(CoreBaseInfo)
把引入引出模板中的分录的实现类字段勾选,可以避免DataBinder.generateInfo重新生成覆盖

Gui列表界面常用的需重写标志位方法

是否需要补充多组织查询过滤

isIgnoreCUFilter()

凭证生成不显示选择具体规则弹框

isNeedShowBOTPRule()

通过id获取元数据信息

// BOSUuid uuid = BOSUuid.read(billID);
// EntityObjectInfo eoi = MetaDataLoaderFactory.getLocalMetaDataLoader(ctx).getEntity(uuid.getType()); //得到对象
// String tableName = eoi.getTable().getName();//得到表

GUI界面获取panel下的控件

Jpanel.Component(int),挨个获取,可以判断具体类型和名称

报表创建

创建报表展示UI,父ui对象CommRptBaseUI,ui类型选emptyObject,进界面后手工改新增一个kdtable
过滤界面继承
com.kingdee.eas.framework.report.client.CommRptBaseConditionUI

完美银行对账表相关sql

1.看官请忽略sql
银行对账表查询匹配单头分录的sql

SELECT
	*
FROM
	ct_spc_accountbalancebillentry entryMain
LEFT JOIN (select * from(
	SELECT 
		bill.fid,
		company.fid as companyid,bill.fbizdate,
		(
			SELECT
				SUM (
					isnull(
						billbank.cfbankaccountamt,
						0
					) - isnull(billbank.cfbankflowamt, 0) - isnull(entrybank.cfbankflowamt, 0)
				) AS totalamt
			FROM
				ct_spc_accountBalanceBill billbank
			LEFT JOIN (
				SELECT
					fparentid,
					isnull(SUM(cfbankflowamt), 0) AS cfbankflowamt,
					isnull(SUM(cfshopflowamt), 0) AS cfshopflowamt
				FROM
					ct_spc_accountBalanceBillEntry
				GROUP BY
					fparentid
			) entrybank ON billbank.fid = entrybank.fparentid
			WHERE
				bill.cfaccount = billbank.cfaccount
			AND bill.fbizdate + 1 > billbank.fbizdate
			GROUP BY
				billbank.cfaccount
		) + isnull(entry.cfbankflowamt, 0) AS totalbankdifamt
	FROM
		ct_spc_accountBalanceBill bill
	LEFT JOIN (
		SELECT
			fparentid,
			isnull(SUM(cfbankflowamt), 0) AS cfbankflowamt,
			isnull(SUM(cfshopflowamt), 0) AS cfshopflowamt
		FROM
			ct_spc_accountBalanceBillEntry
		GROUP BY
			fparentid
	) entry ON bill.fid = entry.fparentid
	LEFT JOIN T_ORG_COMPANY company ON company.fid = bill.cfficompanyid
	LEFT JOIN T_BD_ACCOUNTBANKS bdbank ON bill.cfaccount = bdbank.FBANKACCOUNTNUMBER
	LEFT JOIN t_bd_bank bank ON bdbank.fbank = bank.fid
)) as t5   ON t5.totalbankdifamt = entryMain.cfbankflowamt and entryMain.cfbizdate = t5.fbizdate
WHERE
	entryMain.fparentid NOT IN (
		SELECT
			fid
		FROM
			ct_spc_accountbalancebill
	)
And t5.companyid = 'NhqGUAEYEADgACa5rBAIGMznrtQ=' and entryMain.cfbankflowamt <> 0


银行对账表sql

--查询银行流水金额
SELECT
	*
FROM
	(
		SELECT
			SUM (cfamount) AS yinhangamt,
			cfrecaccountnum,
			cfficompanyid,
			fbizdate
		FROM
			(
				SELECT
					cfamount,
					cfrecaccountnum,
					cfficompanyid,
					fbizdate
				FROM
					ct_rpt_salerecrptbill
				WHERE
					cfbillstate = '4'
				UNION ALL
					SELECT
						cfamount,
						cfrecaccountnum,
						cfficompanyid,
						fbizdate
					FROM
						ct_rpt_overstockrptbill
					WHERE
						cfbillstate = '4'
					UNION ALL
						SELECT
							cfamount,
							cfrecaccountnum,
							cfficompanyid,
							fbizdate
						FROM
							ct_rpt_makebyhandrptbill
						WHERE
							cfbillstate = '4'
			)
		GROUP BY
			cfficompanyid,
			cfrecaccountnum,
			fbizdate
	) t1
LEFT JOIN ct_spc_accountbalancebill accountbalance ON accountbalance.CFAccount = t1.cfrecaccountnum
AND t1.fbizdate = accountbalance.FBIZDATE
WHERE
	accountbalance.fid IS NULL 
AND t1.fbizdate >= to_date ('2020-01-01 00:00:00')

--查询银企流水金额
SELECT
	SUM (bill.FACTRECAMT) AS yinqiamt,
	accountbank.FBANKACCOUNTNUMBER,
	bill.FBIZDATE,
	bill.FCOMPANYID
FROM
	t_cas_receivingbill bill
INNER JOIN T_BD_ACCOUNTBANKS accountbank ON bill.FPAYEEACCOUNTBANKID = accountbank.FID
LEFT JOIN ct_spc_accountbalancebill accountbalance ON accountbalance.CFAccount = accountbank.FBANKACCOUNTNUMBER
AND accountbalance.fbizdate = bill.FBIZDATE
WHERE
	bill.FBILLSTATUS = '14'
AND bill.FBIZDATE >= to_date ('2020-01-01 00:00:00')
AND accountbalance.fid IS NULL
GROUP BY
	accountbank.FBANKACCOUNTNUMBER,
	bill.FBIZDATE,
	bill.FCOMPANYID
	
--按照账户查询
SELECT
	company.fid AS id,
	bill.fbizDate AS bizDate,
	company.fname_l2 AS companyname,
	isnull(
		SUM (bill.cfbankaccountamt),
		0
	) AS bankaccountamt,
	SUM (bill.cfbankflowamt) AS bankflowamt,
	SUM (
		isnull(bill.cfbankaccountamt, 0) - isnull(bill.cfbankflowamt, 0)
	) AS flowdifamt,
	SUM (
		(
			SELECT
				SUM (
					isnull(
						billbank.cfbankaccountamt,
						0
					) - isnull(billbank.cfbankflowamt, 0) - isnull(entrybank.cfbankflowamt, 0)
				) AS totalamt
			FROM
				ct_spc_accountBalanceBill billbank
			LEFT JOIN (
				SELECT
					fparentid,
					isnull(SUM(cfbankflowamt), 0) AS cfbankflowamt,
					isnull(SUM(cfshopflowamt), 0) AS cfshopflowamt
				FROM
					ct_spc_accountBalanceBillEntry
				GROUP BY
					fparentid
			) entrybank ON billbank.fid = entrybank.fparentid
			WHERE
				bill.cfaccount = billbank.cfaccount
			AND bill.fbizdate + 1 > billbank.fbizdate
			GROUP BY
				billbank.cfaccount
		) + isnull(entry.cfbankflowamt, 0)
	) AS totalbankdifamt,
	SUM (
		(
			SELECT
				SUM (
					isnull(
						billbank.cfbankaccountamt,
						0
					) - isnull(billbank.cfbankflowamt, 0) - isnull(entrybank.cfbankflowamt, 0)
				) AS totalamt
			FROM
				ct_spc_accountBalanceBill billbank
			LEFT JOIN (
				SELECT
					fparentid,
					isnull(SUM(cfbankflowamt), 0) AS cfbankflowamt,
					isnull(SUM(cfshopflowamt), 0) AS cfshopflowamt
				FROM
					ct_spc_accountBalanceBillEntry
				GROUP BY
					fparentid
			) entrybank ON billbank.fid = entrybank.fparentid
			WHERE
				bill.cfaccount = billbank.cfaccount
			AND bill.fbizdate + 1 > billbank.fbizdate
			GROUP BY
				billbank.cfaccount
		)
	) AS totalbankTrimDifAmt,
	SUM (bill.cfshopflowamt) AS shopflowamt,
	SUM (
		bill.cfbankaccountamt - bill.cfshopflowamt
	) AS shopdifamt,
	SUM (
		(
			SELECT
				SUM (
					billshop.cfbankaccountamt - billshop.cfshopflowamt - isnull(entryshop.cfshopflowamt, 0)
				) AS totalamt
			FROM
				ct_spc_accountBalanceBill billshop
			LEFT JOIN (
				SELECT
					fparentid,
					isnull(SUM(cfbankflowamt), 0) AS cfbankflowamt,
					isnull(SUM(cfshopflowamt), 0) AS cfshopflowamt
				FROM
					ct_spc_accountBalanceBillEntry
				GROUP BY
					fparentid
			) entryshop ON billshop.fid = entryshop.fparentid
			WHERE
				bill.cfaccount = billshop.cfaccount
			AND bill.fbizdate + 1 > billshop.fbizdate
			GROUP BY
				billshop.cfaccount
		) + isnull(entry.cfshopflowamt, 0)
	) AS totalshopdifamt,
	SUM (
		(
			SELECT
				SUM (
					billshop.cfbankaccountamt - billshop.cfshopflowamt - isnull(entryshop.cfshopflowamt, 0)
				) AS totalamt
			FROM
				ct_spc_accountBalanceBill billshop
			LEFT JOIN (
				SELECT
					fparentid,
					isnull(SUM(cfbankflowamt), 0) AS cfbankflowamt,
					isnull(SUM(cfshopflowamt), 0) AS cfshopflowamt
				FROM
					ct_spc_accountBalanceBillEntry
				GROUP BY
					fparentid
			) entryshop ON billshop.fid = entryshop.fparentid
			WHERE
				bill.cfaccount = billshop.cfaccount
			AND bill.fbizdate + 1 > billshop.fbizdate
			GROUP BY
				billshop.cfaccount
		)
	) AS totalShopTrimDifAmt
FROM
	ct_spc_accountBalanceBill bill
LEFT JOIN (
	SELECT
		fparentid,
		isnull(SUM(cfbankflowamt), 0) AS cfbankflowamt,
		isnull(SUM(cfshopflowamt), 0) AS cfshopflowamt
	FROM
		ct_spc_accountBalanceBillEntry
	GROUP BY
		fparentid
) entry ON bill.fid = entry.fparentid
LEFT JOIN T_ORG_COMPANY company ON company.fid = bill.cfficompanyid
WHERE
	1 = 1
AND bill.cfincomedate >= to_date ('2020-04-01')
AND bill.cfincomedate <= to_date ('2020-04-16')
and company.fid = 'NhqGUAEYEADgACaarBAIGMznrtQ='
GROUP BY
	bill.fbizDate,
	company.fid,
	company.fname_l2
ORDER BY
	companyname,
	bizDate ASC


--按照公司汇总
SELECT
	company.fid AS id,
	bill.fbizDate AS bizDate,
	company.fname_l2 AS companyname,
	isnull(
		SUM (bill.cfbankaccountamt),
		0
	) AS bankaccountamt,
	SUM (bill.cfbankflowamt) AS bankflowamt,
	SUM (
		isnull(bill.cfbankaccountamt, 0) - isnull(bill.cfbankflowamt, 0)
	) AS flowdifamt,
	SUM (
		(
			SELECT
				SUM (
					isnull(
						billbank.cfbankaccountamt,
						0
					) - isnull(billbank.cfbankflowamt, 0) - isnull(entrybank.cfbankflowamt, 0)
				) AS totalamt
			FROM
				ct_spc_accountBalanceBill billbank
			LEFT JOIN (
				SELECT
					fparentid,
					isnull(SUM(cfbankflowamt), 0) AS cfbankflowamt,
					isnull(SUM(cfshopflowamt), 0) AS cfshopflowamt
				FROM
					ct_spc_accountBalanceBillEntry
				GROUP BY
					fparentid
			) entrybank ON billbank.fid = entrybank.fparentid
			WHERE
				bill.cfficompanyid = billbank.cfficompanyid
			AND bill.fbizdate + 1 > billbank.fbizdate
			GROUP BY
				billbank.cfficompanyid
		) + isnull(entry.cfbankflowamt, 0)
	) AS totalbankdifamt,
	SUM (
		(
			SELECT
				SUM (
					isnull(
						billbank.cfbankaccountamt,
						0
					) - isnull(billbank.cfbankflowamt, 0) - isnull(entrybank.cfbankflowamt, 0)
				) AS totalamt
			FROM
				ct_spc_accountBalanceBill billbank
			LEFT JOIN (
				SELECT
					fparentid,
					isnull(SUM(cfbankflowamt), 0) AS cfbankflowamt,
					isnull(SUM(cfshopflowamt), 0) AS cfshopflowamt
				FROM
					ct_spc_accountBalanceBillEntry
				GROUP BY
					fparentid
			) entrybank ON billbank.fid = entrybank.fparentid
			WHERE
				bill.cfficompanyid = billbank.cfficompanyid
			AND bill.fbizdate + 1 > billbank.fbizdate
			GROUP BY
				billbank.cfficompanyid
		)
	) AS totalbankTrimDifAmt,
	SUM (bill.cfshopflowamt) AS shopflowamt,
	SUM (
		bill.cfbankaccountamt - bill.cfshopflowamt
	) AS shopdifamt,
	SUM (
		(
			SELECT
				SUM (
					billshop.cfbankaccountamt - billshop.cfshopflowamt - isnull(entryshop.cfshopflowamt, 0)
				) AS totalamt
			FROM
				ct_spc_accountBalanceBill billshop
			LEFT JOIN (
				SELECT
					fparentid,
					isnull(SUM(cfbankflowamt), 0) AS cfbankflowamt,
					isnull(SUM(cfshopflowamt), 0) AS cfshopflowamt
				FROM
					ct_spc_accountBalanceBillEntry
				GROUP BY
					fparentid
			) entryshop ON billshop.fid = entryshop.fparentid
			WHERE
				bill.cfficompanyid = billshop.cfficompanyid
			AND bill.fbizdate + 1 > billshop.fbizdate
			GROUP BY
				billshop.cfficompanyid
		) + isnull(entry.cfshopflowamt, 0)
	) AS totalshopdifamt,
	SUM (
		(
			SELECT
				SUM (
					billshop.cfbankaccountamt - billshop.cfshopflowamt - isnull(entryshop.cfshopflowamt, 0)
				) AS totalamt
			FROM
				ct_spc_accountBalanceBill billshop
			LEFT JOIN (
				SELECT
					fparentid,
					isnull(SUM(cfbankflowamt), 0) AS cfbankflowamt,
					isnull(SUM(cfshopflowamt), 0) AS cfshopflowamt
				FROM
					ct_spc_accountBalanceBillEntry
				GROUP BY
					fparentid
			) entryshop ON billshop.fid = entryshop.fparentid
			WHERE
				bill.cfaccount = billshop.cfaccount
			AND bill.fbizdate + 1 > billshop.fbizdate
			GROUP BY
				billshop.cfaccount
		)
	) AS totalShopTrimDifAmt
FROM
	ct_spc_accountBalanceBill bill
LEFT JOIN (
	SELECT
		fparentid,
		isnull(SUM(cfbankflowamt), 0) AS cfbankflowamt,
		isnull(SUM(cfshopflowamt), 0) AS cfshopflowamt
	FROM
		ct_spc_accountBalanceBillEntry
	GROUP BY
		fparentid
) entry ON bill.fid = entry.fparentid
LEFT JOIN T_ORG_COMPANY company ON company.fid = bill.cfficompanyid
WHERE
	1 = 1
AND bill.cfincomedate >= to_date ('2020-04-01')
AND bill.cfincomedate <= to_date ('2020-04-16')
and company.fid = 'NhqGUAEYEADgACaarBAIGMznrtQ='
GROUP BY
	bill.fbizDate,
	company.fid,
	company.fname_l2
ORDER BY
	companyname,
	bizDate ASC


--查询银行对账流水更新金额
                                                                                                                               

select sum(cfamount) as yinhangamt,t1.cfrecaccountnum,t1.cfficompanyid,t1.fbizdate from (                                                                                          

SELECT cfamount,cfrecaccountnum,cfficompanyid,fbizdate FROM  ct_rpt_salerecrptbill where cfbillstate = '4'                         

union all                                                                                                                          

SELECT cfamount,cfrecaccountnum,cfficompanyid,fbizdate FROM  ct_rpt_overstockrptbill where cfbillstate = '4'                       

union all                                                                                                                          

SELECT cfamount,cfrecaccountnum,cfficompanyid,fbizdate FROM  ct_rpt_makebyhandrptbill where cfbillstate = '4' ) t1                 


 where  t1.fbizdate>= to_date('2020-01-01 00:00:00')  and t1.cfrecaccountnum = '15000090192554'

  group by t1.cfficompanyid,t1.cfrecaccountnum,t1.fbizdate 
order by fbizdate desc




----修复银行对账单编码
update ct_spc_accountbalancebill set fnumber = TO_CHAR(fbizdate,'YYYYMMDD') || cfAccount
--删除无流水填充
delete  from ct_spc_accountbalancebill where fdescription = '无流水填充' and fid not in (select fparentid from ct_spc_accountbalancebillentry)
delete  from ct_spc_accountbalancebill where fdescription = '银企生成' and fid not in (select fparentid from ct_spc_accountbalancebillentry)



--查询重复条目
select *  FROM  ct_spc_accountbalancebill where fnumber in  (SELECT fnumber FROM ct_spc_accountbalancebill where fdescription = '无流水填充' group by fnumber having count(fnumber) > 1) order by fnumber 


--删除不勾选银行账户的对账调整单单头
delete from ct_spc_accountbalancebill where cfaccount not in (SELECT FBANKACCOUNTNUMBER  FROM  T_BD_ACCOUNTBANKS  where cfisbankaccountbill = 1)

银行对账表相关sql

upd1ate   ct_spc_accountbalancebill set fbizdate =  to_date(TO_CHAR(fbizdate,'YYYY-MM-DD'))   where  fdescription = '无流水填充'




SELECT  to_date(TO_CHAR(fbizdate,'YYYY-MM-DD'))  FROM ct_spc_accountbalancebill  where  fdescription = '无流水填充'




SELECT * from ct_spc_accountbalancebill where fdescription is null
 where fnumber in  (SELECT fnumber FROM ct_spc_accountbalancebill where fdescription = '无流水填充' group by fnumber having count(fnumber) > 1) order by fnumber 



SELECT * FROM ct_spc_accountbalancebillentry where fparentid not in (select fid from ct_spc_accountbalancebillentry ) 

left join ct_spc_bankaccountbill





SELECT
	sum(bill.FACTRECAMT) AS yinqiamt,
	accountbank.FBANKACCOUNTNUMBER,
	bill.FBIZDATE,
	bill.FCOMPANYID
FROM
	t_cas_receivingbill bill
INNER JOIN T_BD_ACCOUNTBANKS accountbank ON bill.FPAYEEACCOUNTBANKID = accountbank.FID
LEFT JOIN ct_spc_accountbalancebill accountbalance ON accountbalance.CFAccount = accountbank.FBANKACCOUNTNUMBER
AND accountbalance.fbizdate = bill.FBIZDATE
WHERE
	bill.FBILLSTATUS = '14' 
--and bill.FBIZDATE = to_date ('2020-04-30 00:00:00')
AND bill.FBIZDATE >= to_date ('2020-01-01 00:00:00')
--AND accountbalance.cfaccount = '2011028019200102102'
 and accountbalance.fid is null
  and accountbank.cfisBankAccountBill = 1    
GROUP BY
	accountbank.FBANKACCOUNTNUMBER,
	bill.FBIZDATE,
	bill.FCOMPANYID

2.Sql经验
1日期型注意毫秒尾差!

3.Calendar
Calendar curDay = Calendar.getInstance();
curDay.setTime(new Date());
curDay.set(Calendar.MONTH, 0);
curDay.set(Calendar.DAY_OF_MONTH, 1);
curDay.set(Calendar.HOUR_OF_DAY, 0);
curDay.set(Calendar.MINUTE, 0);
curDay.set(Calendar.SECOND, 0);
curDay.set(Calendar.MILLISECOND, 0);
while(!new Date().before(curDay.getTime())){}

EAS快捷键

BOS开发平台常用快捷键
ctrl+shift+R 在工作空间查找资源
ctrl+L 查找行号
ctrl+shift+D 调试时求值
ctrl+shift+T 查找 java 文件
alt+shift+s 覆盖实现方法

EAS常用快捷键
ctrl+E 在 EAS 出错界面查看出错原因
ctrl+shift+A在预算控制策略界面进行单据预算扣减返还操作(不能与其他快捷键冲突,如:钉钉截图默认快捷键)
alt+shift+D打开页面布局查看器
ctrl+shift+c 获取分录行的id
ctrl+alt+[ 获取任意界面操作的信息

业务快捷键

1、功能键:CTRL+SHIFT+F12
界面:在预算方案序时簿界面,路径为:【管理会计】-【预算管理】-【预算设置】-
【预算方案】
作用:强制更新下发模板(注意:下发前,请锁定模板内单元格)
2、功能键:CTRL+SHIFT+Q
界面:在预算方案序时簿界面,路径为:【管理会计】-【预算管理】-【基础资料】-
【预算要素】
作用:数据库查询分析器
3、功能键:CTRL+SHIFT+Q
界面:在基础资料币别界面,路径为:【基础数据管理】-【辅助资料】-【币别】
作用:数据库查询分析器
4、功能键:CTRL+SHIFT+Q
界面:企业组织架构树界面,路径为:【基础数据管理】-【组织架构】-【企业组织架
构树】
作用:强制审核组织架构树
5、功能键:CTRL+ALT+逗号
界面:在任何报表、报表模板界面
作用:显示报表单元格,公式等统计情况
6、功能键:CTRL+Shift+F6
界面:总账期末结账界面,路径为:【财务会计】-【总账】-【期末处理】-【期末结
账】
作用:即时核销历史数据升级
7、功能键:CTRL+Shift+F7
界面:路径为:【财务会计】-【总账】-【期末处理】-【期末结账】
作用:更新凭证辅助账打印名称、科目余额表(明细账)的核算项目展示名称
8、功能键:CTRL+Shift+F8
界面:路径为:【财务会计】-【总账】-【期末处理】-【期末结账】
作用:清除辅助账横表引用。注:在删除基础资料时如果提示资料被引用,且检查相关
单据都删除了,可以在这里处理
9、功能键:CTRL+SHIFT+F9
界面:路径为:【财务会计】-【总账】-【期末处理】-【期末结账】
作用:更新科目发生额(密码:kingdeeeas 升级后密码:gowithwind)
10、功能键:CTRL+SHIFT+F10
界面:路径为:【财务会计】-【总账】-【期末处理】-【期末结账】
作用:辅助账计量单位余额升级。
11、功能键:CTRL+SHIFT+F11
界面:路径为:【财务会计】-【总账】-【期末处理】-【期末结账】
作用:数据库查询分析器
12、功能键:CTRL+ALT+S
界面:路径为:【财务会计】-【总账】-【现金流量】-【现金流量表】
作用:快速找到现金流量指定不正确的凭证
13、功能键:F12 或者 F11或者 F10
界面:路径为:【系统平台】-【系统配置】-【参数设置】
作用:EAS参数的自定义添加、查询、清除等,谨慎使用F10与F11。
14、功能键:ALT+I
界面:路径为:【库存业务管理】-【库存管理】-【库存查询】-【即时库存查询】
作用:可以重算库存
15、功能键:Ctrl+Shift+Alt+U
界面:路径为:【EAS主界面】
作用:EAS调色板
16、功能键:CTRL+SHIFT+R
界面:路径为:【财务会计】-【合并报表】-【报表接收】
作用:报表接收界面中选中问题报表,快捷键ctrl+shift+R→信息提示“您将启动数据修复功能,数据修复将同步报表和合并报表系统的报表数据,请确认是否继续” →信息提示“恭喜您,数据修复成功!”。此时,报表编制界面的报表会变成未提交状态。

猜你喜欢

转载自blog.csdn.net/gsh6022/article/details/107835951