2、NC65和NC63方法集(持续更新)

**

2、 NC65和NC63方法集(持续更新)

**
1、StringUtils 判断字符串是否为空

StringUtils.isNotEmpty(materialVOs[0].getPk_fac())

2、ArrayUtils 判断集合是否为空

   ArrayUtils.isNotEmpty(facVOs)

3、查询集团和组织、 部门、仓库、物料、人员等工具

UapBDQryUtil tool = new UapBDQryUtil();
String pk_group = tool.queryGroupPKByCode(wbsvo.getGroupcode());		
String pk_org = tool.queryOrgPKByGroupPKAndOrgCode(pk_group, wbsvo.getOrgcode());

4、数据库查询工具(查询一个数组)

 DataAccessUtils utils = new DataAccessUtils();
	    IRowSet rowset = utils.query(sql.toString());
	    String[] pk_checkbills = rowset.toOneDimensionStringArray();

5、审批刘字符串枚举

BillStatusEnum

6、数据库查询参数代入

String sql="select 1 from pub_workflownote a where a.billid=? and a.checkman=? and a.approvestatus=0";
			SQLParameter par=new SQLParameter();
			par.addParam(aggo.getParentVO().getPrimaryKey());
			par.addParam(AppContext.getInstance().getPkUser());
			
			IUAPQueryBS bs=NCLocator.getInstance().lookup(IUAPQueryBS.class);
			Object obj=bs.executeQuery(sql,par, new ColumnProcessor());

7、 IUAPQueryBS另一个用法

IUAPQueryBS qry=NCLocator.getInstance().lookup(IUAPQueryBS.class);

			@SuppressWarnings("unchecked")
			List deptvos = (List) qry.retrieveByClause(DeptVO.class,
					"pk_dept='" + pk_usedept +"' and DR = '0'");		

8、刷新另一种方法

 @SuppressWarnings("restriction")
private IModelDataManager dataManager;

	@SuppressWarnings("restriction")
	public IModelDataManager getDataManager() {
		return dataManager;
	}

	@SuppressWarnings("restriction")
	public void setDataManager(IModelDataManager dataManager) {
		this.dataManager = dataManager;
	}
Aggqc_checkbill_equip sdata =(Aggqc_checkbill_equip) getModel().getSelectedData();

		qc_checkbill_equip parentVO = sdata.getParentVO();
		Integer num=new Integer(parentVO.getDef1()) +1;
		parentVO.setDef1(num.toString());
		parentVO.setDr(0);
		HYPubBO_Client.update(parentVO);
		DefaultRefreshAction de=new DefaultRefreshAction();
		de.setDataManager(this.dataManager);
		de.doAction(e);

刷新系统单据:

 SettlementAggVO SettlementAggVO = (SettlementAggVO)selectedAggVOs[0];
	 SettlementHeadVO  parentVO = (SettlementHeadVO )SettlementAggVO.getParentVO();
	 parentVO.setDef1("1");
	 parentVO.setDef2("3");
	 parentVO.setDef3("2");
	 SettlementAggVO.setParentVO(parentVO);
	 getModel().directlyUpdate(SettlementAggVO);

9、发送邮件给员工 util类

PsndocAggVO[] selectedAggVOs = new PsndocAggVO[selectedObjs.length];

		try{
			for(int i=0;i  msgList = new SendMessageUtil().getPsnInitPasswdMsgVOs(selectedAggVOs);
			
			if(msgList!=null && msgList.size()>0){
				new SendMessageUtil().sendMessageByEmail(msgList.toArray(new MessageVO[msgList.size()]));
				MessageDialog.showHintDlg(new Container(), "密码发送", "批量发送员工初始化密码到员工邮箱成功!");
										
			}else{
				MessageDialog.showHintDlg(new Container(), "密码发送", "所选择人员没有初始化密码或者电子邮件为空,无法发送!");
			}
			
			
			
		}catch(Exception ex){
			ex.printStackTrace();
			MessageDialog.showErrorDlg(new Container(), "密码发送", "批量发送员工初始化密码到员工邮箱失败:"+ex.getMessage());
		}

10、发送短信给员工 util类

try{
			//获得短信用列表
			List msgList4SMS = new SendMessageUtil().getPsnInitPasswdMsgVOs4SMS(selectedAggVOs);
			
			if(msgList4SMS != null && msgList4SMS.size() > 0){//发送短信
				new SendMessageUtil().sendMessageWithOrg(msgList4SMS.toArray(new MessageVO[msgList4SMS.size()]), selectedAggVOs[0].getParentVO().getPk_org());
				MessageDialog.showHintDlg(new Container(), "密码发送", "批量发送员工初始化密码短信给员工成功!");
				return;	
			}else{
				MessageDialog.showHintDlg(new Container(), "密码发送", "所选择人员没有初始化密码或者手机号码为空,无法发送!");
				return;	
			}
			
		}catch(Exception ex){
			itf.writeLog(ex.getMessage());
			ex.printStackTrace();
			MessageDialog.showErrorDlg(new Container(), "密码发送", "批量发送员工初始化密码到手机失败:"+ex.getMessage());
			return;
		}

11、自定义附件管理(自定义大小)

IUAPQueryBS dao = (IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class);

		EquipVO aggvo = (EquipVO)getModel().getSelectedData();
		EquipHeadVO hvo = aggvo.getParentVO();
		String sql="select pk_checkstandard_equip from qc_standard_equip where wl='"+hvo.getPk_material()+"' and dr=0";
		String pk = (String)dao.executeQuery(sql, new ColumnProcessor());
		
		if(pk==null){
			MessageDialog.showErrorDlg(getModel().getContext().getEntranceUI(),
					"提示", "当前设备卡片中的设备还未进行质检!");
		}else{

			String finalchildpath = "检验单-设备";
			String userCode = WorkbenchEnvironment.getInstance().getLoginUser().getUser_code();

			String funcode = getModel().getContext().getNodeCode();
			String pk_group = getModel().getContext().getPk_group();
			FileManageUI ui = FileManageUIFactory.getFileManagePnl(pk,userCode, funcode, pk_group);

			String fullPath = pk+"/"+ finalchildpath;
			IFileSystemService service = (IFileSystemService) NCLocator
					.getInstance().lookup(IFileSystemService.class);//附件服务
			if (!(service.isExist(pk))) {
				service.createNewFileNode(pk, finalchildpath,
						WorkbenchEnvironment.getInstance().getLoginUser().getCuserid());
			}
			ui = FileManageUIFactory.getFileManagePnl(fullPath, userCode, funcode,pk_group);

			ui.setDeleteNodeEnable(false);//附件是否可以删除
			ui.setUploadFileEnable(false);//附件是否可以上传
			ui.setRenameNodeEnable(false);//文件夹是否可以重命名
			ui.setCreateNewFolderEnable(false);//是否可以添加文件夹
			ui.setEnabled(false);
			ui.setTreeEditable(false);
			ui.setTreeRootVisible(false);

			UIDialog dlg = new UIDialog(getModel().getContext().getEntranceUI(),
					NCLangRes4VoTransl.getNCLangRes().getStrByID("pubapp_0","0pubapp-0129"));

			dlg.getContentPane().setLayout(new BorderLayout());
			dlg.getContentPane().add(ui, "Center");
			dlg.setResizable(true);
			dlg.setSize(600, 400);
			dlg.showModal();

12、更新VO HYPubBO_Client

HYPubBO_Client.update(parentVO);//主表VO
HYPubBO_Client.updateAry(childvo[]);//子表VO

13、刷新
1.//模拟触发刷新按钮 相当于在界面上点击刷新按钮
//new一个按钮

nc.ui.pubapp.uif2app.actions.RefreshSingleAction refreshaction=new RefreshSingleAction();

//传数据给这个按钮

refreshaction.setModel(this.getModel());

//新增一个事件。。。模拟这个按钮事件

ActionEvent e1=new ActionEvent(refreshaction, 1001, "刷新");

//执行这个按钮的doAction方法,把这个模拟事件传进去

refreshaction.doAction(e1);

// 其他按钮也应该类似

14、工具类 发送通知消息和预警消息

工具类GsUtil

package com.hf.utils;

import nc.message.IMsgSender;
import nc.message.util.MessageSenderLoader;
import nc.message.vo.MessageVO;
import nc.message.vo.NCMessage;
import nc.vo.pub.BusinessException;
import nc.vo.pub.msg.UserNameObject;
import nc.vo.pubapp.AppContext;

public class GSrvUtil {
 
	/**
	 * 发送预警消息
	 * @version 创建时间:Jul 29, 2013 9:03:18 AM
	 * @param receiverPKs 接收用户PK
	 * @param title  标题
	 * @param context  内容
	 * @throws BusinessException
	 */
	public static void sendPrealert(String[] receiverPKs,String title,String context) throws BusinessException{
		sendMsg("",receiverPKs,title,context,null,null,"prealert");
	}
	/**
	 *  发送通知消息
	* @version 创建时间:Jul 29, 2013 9:03:57 AM
	* @param senderPK  发送的用户PK 可空
	* @param receiverPKs   接收用户PK
	* @param title  标题
	* @param context 内容
	* @throws BusinessException
	 */
	public static void sendNotice(String senderPK,String[] receiverPKs,String title,String context) throws BusinessException{
		sendMsg(senderPK,receiverPKs,title,context,null,null,"notice");
	}
  
	/**
	 *  发送通知消息并且可以打开单据
	* @param senderPK  发送的用户PK 可空
	* @param receiverPKs   接收用户PK
	* @param title  标题
	* @param context 内容
	* @throws BusinessException
	 */
  	public static void sendNotice(String senderPK,String[] receiverPKs,String title,String context,String detail,String pk_detail) throws BusinessException{
		sendMsg(senderPK,receiverPKs,title,context,detail,pk_detail,"pfbizmsg");
	}
  	
  	/**
	 *  发送通知消息并且可以打开薪资报表
	* @param senderPK  发送的用户PK 可空
	* @param receiverPKs   接收用户PK
	* @param title  标题
	* @param context 内容
	* @throws BusinessException
	 */
  	public static void sendNoticeOpenBB(String senderPK,String[] receiverPKs,String title,String context,String detail,String pk_detail) throws BusinessException{
		sendMsg(senderPK,receiverPKs,title,context,detail,pk_detail,"paydatamsg");
	}

	/**
	 *发送消息
	 *消息表:
	 *   select * from sm_msg_receiver order by ts desc;--消息接收人
		 select * from sm_msg_content order by ts desc;--消息正文
		 SELECT * FROM sm_msg_stypeprop order by ts desc;
		 SELECT * FROM sm_msg_stypebase WHERE active = 'Y';

	 * @param senderPK  发送的用户PK
	 * @param receiverPKs 接受用户pk
	 * @param title
	 * @param context
	 * @param msgsourcetype 消息类型:  notice 通知  prealert 预警
	 * @throws BusinessException
	 *
	 */
	public static void sendMsg(String senderPK,String[] receiverPKs,String title,String context,String detail,String pk_detail,String msgsourcetype) throws BusinessException{
	    if(receiverPKs==null||receiverPKs.length==0){
	    	return;
	    }	
		//接受者
		UserNameObject[] receivers = new UserNameObject[receiverPKs.length];
		for (int i = 0; i < receivers.length; i++) {
			UserNameObject user = new UserNameObject("");
			user.setUserPK(receiverPKs[i]);
			receivers[i]=user;
		}
		
   	for(int j=0;j"+e.getMessage(),e);
			}
   	}
	}
}

实现调用;

 billvos = (AggStapply[])ArrayClassConvertUtil.convert(getSelectData(getModel().getAggVOClass()), AggStapply.class);
			 if ((null != billvos) && (billvos.length > 0)){
				 IUAPQueryBS server = NCLocator.getInstance().lookup(IUAPQueryBS.class);
				 String pk_billtype = ((StapplyVO)billvos[0].getParentVO()).getPk_billtype();
				 if (pk_billtype.equals("6113")){
					 for(int i = 0; i < billvos.length;i++ ){
						 AggStapply billvo = billvos[i];
						 StapplyVO stapplyVO = (StapplyVO)billvo.getParentVO();
						 String oldpk_dept = stapplyVO.getOldpk_dept();
						 if(1 == stapplyVO.getApprove_state() && 2 == stapplyVO.getStapply_mode()){
							 String sql = "select cuserid from sm_user where pk_base_doc in (select znzg from hfhr_deptapprove_b where pk_deptdoc = '" + oldpk_dept + "' and nvl(dr,0) = 0) and nvl(dr,0) = 0";
							 String receiverPK = (String)server.executeQuery(sql, new ColumnProcessor());
							 String senderPK = stapplyVO.getCreator();
							 String sql2 = "select name from bd_psndoc where pk_psndoc ='" + stapplyVO.getPk_psndoc() + "' and nvl(dr,0) = 0";
							 String psnname = (String)server.executeQuery(sql2, new ColumnProcessor());
							 //通知消息标题
				             String title = psnname + "的调配单据已审批完成,请知悉";
				             //详细信息
				             String context = "";
				             //跳转的单据PK
				             String detail = "";
				             detail = stapplyVO.getPk_hi_stapply()+"@6113@"+stapplyVO.getBill_code();
				             String pk_detail = "";
				             pk_detail = stapplyVO.getPk_hi_stapply();
				             //发送通知消息并可以打开单据
				             GSrvUtil.sendNotice(senderPK, new String[]{receiverPK}, title, context, detail, pk_detail);
						 }
					 }
				 }
			 }

你可能感兴趣的:(NC,NC,NC65,NC63)