Browse Source

导入优化

zthwr 1 năm trước cách đây
mục cha
commit
629bc45766

+ 158 - 0
mmpac/mmpac/src/public/u8c/bs/upifsp/pub/UpifsTool.java

@@ -0,0 +1,158 @@
+package u8c.bs.upifsp.pub;
+
+import java.util.HashMap;
+
+import nc.bs.logging.Logger;
+import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.vo.fa.base.LockCtl;
+import nc.vo.pub.BusinessException;
+import nc.vo.pub.lang.UFDate;
+
+public class UpifsTool {
+
+	// add by wya 生成时间
+	public static String GreatDate(Integer year, Integer month, Integer day) {
+		String ret_s = null;
+
+		String year_s = year.toString();
+
+		String month_s = "";
+		if (month < 10) {
+			month_s = "0" + month.toString();
+		} else {
+			month_s = month.toString();
+		}
+		String day_s = "";
+		if (day < 10) {
+			day_s = "0" + day.toString();
+		} else {
+			day_s = day.toString();
+		}
+		ret_s = year_s + "-" + month_s + "-" + day_s;
+
+		return ret_s;
+
+	}
+
+
+	// 生成编号 billcode_s 单据号前段 billcode_e 单据号流水号
+	public static HashMap<String, String> GreatVbillcode(String zdname,
+			String billtype, UFDate nowdate, String tablename,String pk_defdoclist)
+			throws BusinessException {
+
+		try {
+			HashMap<String, String> ret_s = new HashMap<String, String>();
+			Integer month = nowdate.getMonth();
+			Integer day = nowdate.getDay();
+			String month_s = "";
+			String day_s = "";
+			if (month < 10) {
+				month_s = "0" + month.toString();
+			} else {
+				month_s = month.toString();
+			}
+
+			if (day < 10) {
+				day_s = "0" + day.toString();
+			} else {
+				day_s = day.toString();
+			}
+			String billcode_s = billtype + nowdate.getYear() + month_s + day_s;
+
+			String sql_max = "select max(" + zdname + ") from  " + tablename
+					+ " where isnull(dr,0)=0 and  pk_defdoclist in (select pk_defdoclist from bd_defdoclist where doclistcode in ('DC(定尺)','YS(颜色)'))";
+			Object max_o = UpifspProxy.getIUAPQueryBS().executeQuery(sql_max,
+					new ColumnProcessor());
+			if (max_o != null) {
+
+				String billcode_e = max_o.toString().substring(12, 18);
+
+				ret_s.put("billcode_s", billcode_s);
+				ret_s.put("billcode_e", billcode_e);
+
+			} else {
+				ret_s.put("billcode_s", billcode_s);
+				ret_s.put("billcode_e", "000000");
+			}
+
+			return ret_s;
+		} catch (Exception e) {
+			// TODO: handle exception
+			throw new BusinessException(e);
+		}
+
+	}
+
+	//单据流水号转String
+	public static String ChangeIntToStr(Integer value) throws BusinessException {
+		try {
+
+			String ret_s = "";
+			String value_s = value.toString();
+			if (value_s.length() < 6) {
+				for (int i = value_s.length(); i < 6; i++) {
+					value_s = "0" + value_s;
+				}
+			}
+			return value_s;
+		} catch (Exception e) {
+			// TODO: handle exception
+			throw new BusinessException(e);
+		}
+	}
+
+
+
+
+	/**
+	 * <p>
+	 * 加锁
+	 * </p>
+	 * 
+	 * @param pk
+	 * @param userId
+	 * @return
+	 */
+	public static String lockTable(String pk, String userId, String tablename) {
+		/** 加锁 **/
+		/* isLockedCard=true 表示加锁成功 , false表示该记录已被别人锁定 */
+		String res = "";
+		int lockedCount = 0;
+		while (true) {
+			boolean isLockedCard = LockCtl.lockPk(pk, userId, tablename);
+			if (isLockedCard) {
+				Logger.debug("用户[" + userId + "]锁定表[" + tablename + "]锁成功");
+				break;
+			}
+			if (lockedCount > 3) {// 重试三次
+				res = "该凭证正在被他人使用,请稍候再试";
+				Logger.debug("该凭证正在被他人使用,请稍候再试");
+				break;
+			}
+			Logger.debug("用户[" + userId + "]等待申请业务锁...");
+			try {
+				Thread.sleep(2000);
+			} catch (InterruptedException e) {
+			}
+			lockedCount++;
+		}
+		return res;
+	}
+
+	/**
+	 * <p>
+	 * 解锁
+	 * </p>
+	 * 
+	 * @return
+	 */
+	public static void freeLock(String pk, String userId, String tablename) {
+		/** 解锁 **/
+		LockCtl.freePk(pk, userId, tablename);
+		Logger.debug("释放业务锁成功");
+	}
+
+
+
+
+}

+ 83 - 0
mmpac/mmpac/src/public/u8c/bs/upifsp/pub/UpifspProxy.java

@@ -0,0 +1,83 @@
+package u8c.bs.upifsp.pub;
+import nc.bs.framework.common.NCLocator;
+import nc.bs.framework.naming.Context;
+import nc.itf.ic.service.IICPub_InvOnHandDMO;
+import nc.itf.uap.IUAPQueryBS;
+import nc.itf.uap.IVOPersistence;
+import nc.itf.uap.rbac.function.IFuncPower;
+import nc.itf.uif.pub.IUifService;
+
+/**
+ * @author answer 2007-8-9
+ * @类型名 : PSProxy
+ * @功能 : 模块代理类
+ * @版本 : v1.0
+ */
+public class UpifspProxy {
+
+	public UpifspProxy() {
+		// TODO 自动生成构造函数存根
+	}
+
+	/*
+	 * *描述:得到locator 参数: 返回:Context 创建时间:2007-2-14 10:31:48
+	 */
+	private static Context getLocator() {
+		return NCLocator.getInstance();
+	}
+	
+
+	/**
+	 * <H3>方法作用</H3>TODO<BR>
+	 * 
+	 * @return
+	 */
+	public static IUAPQueryBS getIUAPQueryBS(){
+		try{ 
+	 		return (IUAPQueryBS) getLocator().lookup(IUAPQueryBS.class.getName());  
+	 	}catch(Exception e){ 
+	 		e.printStackTrace(); 
+	 		return null; 
+	 	}
+	}
+	/**
+	 * <H3>方法作用</H3>TODO<BR>
+	 * 
+	 * @return
+	 */
+	public static IUifService getIUifService(){
+		try{ 
+	 		return (IUifService) getLocator().lookup(IUifService.class.getName());  
+	 	}catch(Exception e){ 
+	 		e.printStackTrace(); 
+	 		return null; 
+	 	}
+	}
+	
+	public static IICPub_InvOnHandDMO getInvOnHandItf(String iftName)
+	{
+		try{ 
+	 		return (IICPub_InvOnHandDMO) getLocator().lookup(iftName);  
+	 	}catch(Exception e){ 
+	 		e.printStackTrace(); 
+	 		return null; 
+	 	}
+	}
+	
+	public static IVOPersistence getIVOPersistence(){
+		try{ 
+	 		return (IVOPersistence) getLocator().lookup(IVOPersistence.class.getName());  
+	 	}catch(Exception e){ 
+	 		e.printStackTrace(); 
+	 		return null; 
+	 	}
+	}
+	public static IFuncPower getIFuncPower(){
+		try{ 
+	 		return (IFuncPower) getLocator().lookup(IFuncPower.class.getName());  
+	 	}catch(Exception e){ 
+	 		e.printStackTrace(); 
+	 		return null; 
+	 	}
+	}
+}