فهرست منبع

材料请购单生成请购单实现类

zthwr 10 ماه پیش
والد
کامیت
f247f3dc8b
1فایلهای تغییر یافته به همراه279 افزوده شده و 43 حذف شده
  1. 279 43
      xc/cg/src/private/u8c/impl/DemandPurchaseRequisitionImpl.java

+ 279 - 43
xc/cg/src/private/u8c/impl/DemandPurchaseRequisitionImpl.java

@@ -2,59 +2,43 @@ package u8c.impl;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import nc.bs.framework.common.NCLocator;
+import nc.hr.utils.PubEnv;
 import nc.itf.uap.IUAPQueryBS;
 import nc.itf.uap.pf.IplatFormEntry;
 import nc.jdbc.framework.processor.ColumnProcessor;
-import nc.ui.pub.beans.MessageDialog;
-import nc.vo.hr.tools.pub.HRAggVO;
+import nc.jdbc.framework.processor.MapProcessor;
+import nc.ui.pub.ClientEnvironment;
 import nc.vo.pr.pray.PraybillHeaderVO;
 import nc.vo.pr.pray.PraybillItemVO;
 import nc.vo.pr.pray.PraybillVO;
 import nc.vo.pub.BusinessException;
-import nc.vo.pub.CircularlyAccessibleValueObject;
-import nc.vo.pub.lang.UFBoolean;
 import nc.vo.pub.lang.UFDate;
+import nc.vo.pub.lang.UFDouble;
 import u8c.bs.servlet.service.GetBaseDAOUtil;
 import u8c.itf.po.IDemandPurchaseRequisition;
-import u8c.ui.mytest.panel.DemandTestUI;
 import u8c.vo.DemandBVO;
 import u8c.vo.DemandVO;
 
 public class DemandPurchaseRequisitionImpl implements IDemandPurchaseRequisition {
 	
-	private IUAPQueryBS iuap = NCLocator.getInstance().lookup(IUAPQueryBS.class);
-//	DemandTestUI frameUI = null;
-	
+	private static IUAPQueryBS iuap = NCLocator.getInstance().lookup(IUAPQueryBS.class);
 	/**
 	 * 根据材料采购单生成请购单
 	 * @param s
 	 * @throws Exception 
 	 */
 	@Override
-	//HRAggVO s
 	public void addPraybillVO(DemandVO demandVO, List<DemandBVO> demandBVOs) throws Exception {
-		
-//		DemandVO DemandBVO
-		
-//		DemandVO demandVO = (DemandVO) s.getParentVO();//
-//		CircularlyAccessibleValueObject[] demandBVOList =  s.getAllChildrenVO();//
-//		List<DemandBVO> demandBVOs = new ArrayList();
-//		for(CircularlyAccessibleValueObject vo : demandBVOList) {
-//			if(vo instanceof DemandBVO) {
-//				demandBVOs.add((DemandBVO)vo);
-//			}
-//		}
-//		if(demandBVOs.size()==0) {
-//			throw new BusinessException("当前材料采购单没有数据,请先添加数据");
-//		}
 		PraybillHeaderVO header = new PraybillHeaderVO();
 		header.setPk_corp(demandVO.getPk_corp());//公司
-		header.setDpraydate(demandVO.getDbilldate());//单据日期-->请购日期
+		UFDate ufDate = new UFDate();
+		UFDate dbilldate = PubEnv.getLoginDate();
+		header.setDpraydate(dbilldate);//单据日期-->请购日期
 		header.setIpraysource(5);//请购来源
 		header.setIpraytype(2);//请购类型
-		header.isDirecttransit(new UFBoolean(true));// -->是否直运???
 		header.setIbillstatus(0);//单据状态
 		header.setCpraypsn(demandVO.getWorkmanid());//请购人id-->业务员
 		header.setCdeptid(demandVO.getPlandeptid());//请购部门id-->计划部门
@@ -62,29 +46,166 @@ public class DemandPurchaseRequisitionImpl implements IDemandPurchaseRequisition
 		header.setDr(0);
 		header.setCaccountyear(String.valueOf(new UFDate().getYear()));//年份
 		header.setCoperator(demandVO.getBillmaker());//制单人-》制单人
+		header.setNversion(1);
+//		header.setVdef9(getprojectcode(demandVO.getProjectid()));//项目编码 
+//		header.setVdef10(getprojectname(demandVO.getProjectid()));// 项目名称 vdef10
+		
+		Map<String,String> mapcodename=getprojectmap(demandVO.getProjectid());
+		
+		//项目名称
+		header.setAttributeValue("vdef10", mapcodename.get("jobname"));
+		//项目名称pk_defdoc10
+		header.setAttributeValue("pk_defdoc10", demandVO.getProjectid());				
+		//加工单号
+		header.setAttributeValue("vdef1", demandVO.getVdef1());
+		//业务类型
+		header.setAttributeValue("vdef7", demandVO.getVdef30());
+		
+		header.setAttributeValue("pk_defdoc7",getpkdefdoc(demandVO.getVdef30()));
+		
+		header.setVmemo("MRP运算清单");// 备注
+		
+		
 		PraybillItemVO[] items = new PraybillItemVO[demandBVOs.size()];
+//		for (int i = 0; i < demandBVOs.size(); i++) {
+//			DemandBVO demandBVO = demandBVOs.get(i);
+//			PraybillItemVO praybillItemVO = new PraybillItemVO();
+//			praybillItemVO.setPk_corp(demandVO.getPk_corp()); // 公司
+//			praybillItemVO.setRowno((i+1)*10+"");//行号(单据模板里面是crowno,但是对象中只有Rowno)
+//			
+//			praybillItemVO.setCmangid(getCmangchid(getCmangid(demandBVO.getCmaterialcode()))); //存货编码
+//			praybillItemVO.setCbaseid(getCmangid(demandBVO.getCmaterialcode()));// 存货基本档案主键
+//			praybillItemVO.setAttributeValue("cinventorycode", demandBVO.getCmaterialcode());// 存货编码
+//			praybillItemVO.setAttributeValue("cinventoryname", getCmangName(demandBVO.getCmaterialcode()));//存货名称 cinventoryname
+//			praybillItemVO.setAttributeValue("cprojectname", getprojectname(demandVO.getProjectid()));//项目
+//			//praybillItemVO.setCmangid(getCmangid(demandBVO.getCmaterialcode())); //Cmaterialcode是材料请购单的存货编码
+//			praybillItemVO.setAttributeValue("pk_reqcorp", "1001");//需求公司
+//			praybillItemVO.setNpraynum(demandBVO.getNum()); //主数量-》数量
+//			praybillItemVO.setDdemanddate(ufDate);//-->需求日期 ???
+//			praybillItemVO.setAttributeValue("dsuggestdate", ufDate);//建议订货日期
+//			praybillItemVO.setAttributeValue("naccumulatenum", demandBVO.getNum());//累计订单数量
+//			String cprojectid = "";//项目id
+//			if(demandBVO.getPrjcode().startsWith("1001")) {
+//				cprojectid = demandBVO.getPrjcode();
+//			}else {
+//				cprojectid = GetBaseDAOUtil.getprojectid(demandBVO.getPrjcode());
+//			}
+//			praybillItemVO.setCprojectid(cprojectid);
+//			praybillItemVO.setNassistnum(new UFDouble(demandBVO.getNastnum()));//辅计量数量
+//			praybillItemVO.setVproducenum(demandBVO.getVbatchcode());//批次号
+//			praybillItemVO.setNexchangerate(new UFDouble(demandBVO.getVdef13()));//换算率 
+//			//praybillItemVO.setVfree("");//自由项 vfree
+//			praybillItemVO.setAttributeValue("cinventoryunit", null);//计量单位 cinventoryunit
+//			praybillItemVO.setVfree1(demandBVO.getColor());	//颜色
+//			praybillItemVO.setVfree2(demandBVO.getAlloy());//合金
+//			praybillItemVO.setVfree3(demandBVO.getSizing());//定尺
+//			praybillItemVO.setVfree4(demandBVO.getStandard());//标准
+//			praybillItemVO.setAttributeValue("pk_defdoc1",demandBVO.getVdef1() );//楼号楼层
+//			praybillItemVO.setAttributeValue("pk_defdoc2", demandBVO.getVdef2());//樘数(数量)
+//			praybillItemVO.setAttributeValue("pk_defdoc3", demandBVO.getVdef3());//框统计
+//			praybillItemVO.setAttributeValue("pk_defdoc4", demandBVO.getVdef4());//扇统计
+//			praybillItemVO.setAttributeValue("pk_defdoc5", demandBVO.getVdef5());//半成品分类
+//			praybillItemVO.setAttributeValue("pk_defdoc6", demandBVO.getVdef6());//面积
+//			praybillItemVO.setAttributeValue("pk_defdoc7", demandBVO.getVdef7());//切割长度
+//			praybillItemVO.setAttributeValue("pk_defdoc8", demandBVO.getVdef8());//切割角度左下
+//			praybillItemVO.setAttributeValue("pk_defdoc9", demandBVO.getVdef9());//切割角度右上
+//			praybillItemVO.setAttributeValue("pk_defdoc10",demandBVO.getVdef10());//备注
+//			praybillItemVO.setAttributeValue("pk_defdoc11",demandBVO.getWidth());//宽度
+//			praybillItemVO.setAttributeValue("pk_defdoc12",demandBVO.getHeight());//高度
+//			praybillItemVO.setAttributeValue("pk_defdoc13",demandBVO.getVdef11());//系列
+//			praybillItemVO.setAttributeValue("pk_defdoc14",demandBVO.getVdef12());//玻璃编号
+//			praybillItemVO.setCassistunit(getMeasidByNames(demandBVO.getCastunitid()));//辅计量单位ID 
+//			//praybillItemVO.setCassistunit(demandBVO.getCastunitid());//辅助计量单位
+//			//开票类型 销售出库 销售发票 vdef15
+// 			//praybillItemVO.setVdef15("");
+// 			//窗号vdef17
+// 			//praybillItemVO.setVdef17("");
+// 			//米重vdef18
+//			praybillItemVO.setVdef18(demandBVO.getWeight());
+// 			//装饰面周长vdef19
+//			praybillItemVO.setVdef19(demandBVO.getRound());
+// 			//专用区vdef20
+// 			//praybillItemVO.setVdef20("");
+//			items[i] = praybillItemVO;
+//		}
+		
 		for (int i = 0; i < demandBVOs.size(); i++) {
 			DemandBVO demandBVO = demandBVOs.get(i);
 			PraybillItemVO praybillItemVO = new PraybillItemVO();
 			praybillItemVO.setPk_corp(demandVO.getPk_corp()); // 公司
-			// 表体赋值
 			praybillItemVO.setRowno((i+1)*10+"");//行号(单据模板里面是crowno,但是对象中只有Rowno)
-			praybillItemVO.setCmangid(getCmangid(demandBVO.getCmaterialcode())); //存货编码-》存货编码
+			
+			praybillItemVO.setCmangid(getCmangchid(getCmangid(demandBVO.getCmaterialcode()))); //存货编码
+			praybillItemVO.setCbaseid(getCmangid(demandBVO.getCmaterialcode()));// 存货基本档案主键
+
+			praybillItemVO.setPk_corp(PubEnv.getCorpCode()); // 公司
+			praybillItemVO.setPk_purcorp (PubEnv.getCorpCode());//采购公司
+			
+			
 			praybillItemVO.setNpraynum(demandBVO.getNum()); //主数量-》数量
-			praybillItemVO.setDdemanddate(new UFDate());//-->需求日期 ???
-			String cprojectid = "";//项目id
-			if(demandBVO.getPrjcode().startsWith("1001")) {
-				cprojectid = demandBVO.getPrjcode();
-			}
-			else {
-				cprojectid = GetBaseDAOUtil.getprojectid(demandBVO.getPrjcode());
-			}
-			praybillItemVO.setCprojectid(cprojectid);
-//			praybillItemVO.setCassistunit(demandBVO.getCastunitid());//辅助计量单位
-//			praybillItemVO.setNassistnum(new UFDouble(demandBVO.getNastnum()));//辅计量数量
-//			praybillItemVO.setVproducenum(demandBVO.getVbatchcode());//批次号
+
+			UFDouble hsl=new UFDouble(demandBVO.getVdef13());
+			praybillItemVO.setNexchangerate(hsl);//换算率
+			
+			praybillItemVO.setCassistunit(getMeasidByNames(demandBVO.getCastunitid()));//辅计量单位ID 
+			
+			praybillItemVO.setNassistnum(new UFDouble(demandBVO.getNastnum()));//辅计量数量
+			
+//			String cprojectid = "";//项目id
+//			if(demandBVO.getPrjcode().startsWith("1001")) {
+//				cprojectid = demandBVO.getPrjcode();
+//			}else {
+//				cprojectid = GetBaseDAOUtil.getprojectid(demandBVO.getPrjcode());
+//			}
+//			praybillItemVO.setCprojectid(cprojectid);
+			
+			praybillItemVO.setCprojectid(demandVO.getProjectid());
+		
+			praybillItemVO.setVproducenum(demandBVO.getVbatchcode());//批次号
+			
+			praybillItemVO.setDdemanddate(dbilldate);
+			praybillItemVO.setDsuggestdate(dbilldate);
+
+			praybillItemVO.setPk_reqcorp(PubEnv.getCorpCode());
+			praybillItemVO.setVfree1(demandBVO.getColor());	//颜色
+			praybillItemVO.setVfree2(demandBVO.getAlloy());//合金
+			praybillItemVO.setVfree3(demandBVO.getSizing());//定尺
+			praybillItemVO.setVfree4(demandBVO.getStandard());//标准
+			
+			praybillItemVO.setAttributeValue("vdef1",demandBVO.getVdef1() );//楼号楼层
+			praybillItemVO.setAttributeValue("vdef2", demandBVO.getVdef2());//樘数(数量)
+			praybillItemVO.setAttributeValue("vdef3", demandBVO.getVdef3());//框统计
+			praybillItemVO.setAttributeValue("vdef4", demandBVO.getVdef4());//扇统计
+			praybillItemVO.setAttributeValue("vdef5", demandBVO.getVdef5());//半成品分类
+			praybillItemVO.setAttributeValue("vdef6", demandBVO.getVdef6());//面积
+			praybillItemVO.setAttributeValue("vdef7", demandBVO.getVdef7());//切割长度
+			praybillItemVO.setAttributeValue("vdef8", demandBVO.getVdef8());//切割角度左下
+			praybillItemVO.setAttributeValue("vdef9", demandBVO.getVdef9());//切割角度右上
+			praybillItemVO.setAttributeValue("vdef10",demandBVO.getVdef10());//备注
+			praybillItemVO.setAttributeValue("vdef11",demandBVO.getWidth());//宽度
+			praybillItemVO.setAttributeValue("vdef12",demandBVO.getHeight());//高度
+			praybillItemVO.setAttributeValue("vdef13",demandBVO.getVdef11());//系列
+			praybillItemVO.setAttributeValue("vdef14",demandBVO.getVdef12());//玻璃编号
+			
+//			praybillItemVO.setAttributeValue("vdef15",vector.get()==null?null:vector.get().toString());//开票类型
+			praybillItemVO.setAttributeValue("vdef17",demandBVO.getVdef21());//窗号
+			praybillItemVO.setAttributeValue("vdef18",demandBVO.getWeight());//米重
+			praybillItemVO.setAttributeValue("vdef19",demandBVO.getRound());//装饰面周长
+			praybillItemVO.setAttributeValue("vuserdef20",demandBVO.getVdef22());//专用区
+			praybillItemVO.setAttributeValue("pk_defdoc20",getzyqpk("专用区",demandBVO.getVdef22()==null?null:demandBVO.getVdef22().toString()));//专用区
+			
+			praybillItemVO.setCsourcebillid(demandBVO.getPk_demand());//来源单据ID 
+			praybillItemVO.setCsourcebillrowid(demandBVO.getPk_demand_b());//来源单据行ID 
+			praybillItemVO.setCupsourcebillid(demandBVO.getPk_demand());//上层来源单据ID 
+			praybillItemVO.setCupsourcebillrowid(demandBVO.getPk_demand_b());//上层来源单据行ID 
+			
+			
 			items[i] = praybillItemVO;
 		}
+		
+	
+		
+		
 		PraybillVO vo = new PraybillVO();
 		vo.setParentVO(header);
 		vo.setChildrenVO(items);
@@ -92,10 +213,6 @@ public class DemandPurchaseRequisitionImpl implements IDemandPurchaseRequisition
 		praybillVOs[0] = vo;
 		IplatFormEntry iIplatFormEntry = (IplatFormEntry)NCLocator.getInstance().lookup(IplatFormEntry.class.getName());
 		ArrayList retObj = (ArrayList) iIplatFormEntry.processAction("SAVEBASE", "20", vo.getHeadVO().getDpraydate().toString(), null, vo, null, null);
-//		MessageDialog.showHintDlg(frameUI, "成功", "请购单新增成功");
-//		IPrayBillMaintainAPI prayBillMaintainAPI = NCLocator.getInstance().lookup(IPrayBillMaintainAPI.class);
-//		prayBillMaintainAPI.insert(praybillVOs);
-
 	}
 
 	/**
@@ -113,5 +230,124 @@ public class DemandPurchaseRequisitionImpl implements IDemandPurchaseRequisition
 		}
 		return cmangid;
 	}
+	
+	/**
+	 * 根据物料code查询名称
+	 * @param code
+	 * @return
+	 * @throws BusinessException
+	 */
+	public String getCmangName(String code) throws BusinessException {
+		String invname = null;
+		String sql = " select invname from bd_invbasdoc" + " where invcode  ='" + code + "' and dr =0 ";
+		invname = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (invname == null) {
+			throw new BusinessException("根据物料code查询名称,U8C物料code不存在:" + code);
+		}
+		return invname;
+	}
+	
+	/**
+	 * 根据项目id查询项目名称
+	 * @param code
+	 * @return
+	 * @throws BusinessException
+	 */
+	//项目名称
+    public static String getprojectname(String prjcode) throws Exception {
+    	String jobname = null;
+        String sql = "select jobname from bd_jobbasfil where pk_jobbasfil ='"+prjcode+"' and isnull(dr,0) = 0";
+        jobname = (String) iuap.executeQuery(sql, new ColumnProcessor());
+        if (jobname == null) {
+            return "";
+        }
+        return jobname;
+    }
+    
+    /**
+	 * 根据项目id查询项目名称
+	 * @param code
+	 * @return
+	 * @throws BusinessException
+	 */
+	//项目名称
+    public static String getprojectcode(String prjcode) throws Exception {
+    	String jobcode = null;
+        String sql = "select jobcode from bd_jobbasfil where pk_jobbasfil ='"+prjcode+"' and isnull(dr,0) = 0";
+        jobcode = (String) iuap.executeQuery(sql, new ColumnProcessor());
+        if (jobcode == null) {
+            return "";
+        }
+        return jobcode;
+    }
+    
+    /**
+	 * 存货管理档案
+	 * @param code
+	 * @return
+	 * @throws BusinessException
+	 */
+public String getCmangchid(String pk_invbasdoc) throws BusinessException {
+	String cmangid = null;
+	String sql = " select pk_invmandoc from bd_invmandoc" + " where pk_invbasdoc  ='" + pk_invbasdoc + "' and dr =0 ";
+	cmangid = (String) iuap.executeQuery(sql, new ColumnProcessor());
+	if (cmangid == null) {
+		throw new BusinessException("U8C物料code不存在:" + pk_invbasdoc);
+	}
+	return cmangid;
+}
+
+//根据计量单位名称获取主键
+public  String getMeasidByNames(String measname) throws Exception {
+    String sql = "select pk_measdoc from bd_measdoc where isnull(dr,0) = 0 and measname = '"+measname+"'";
+    return (String) iuap.executeQuery(sql, new ColumnProcessor());
+}
+
+
+//项目管理档案-编码和名称
+public  Map<String,String> getprojectmap(String pk_jobmngfil ) throws Exception {
+    String sql = "select jobcode,jobname  from   bd_jobbasfil where  "
+    		+ "pk_jobbasfil = (select pk_jobbasfil from bd_jobmngfil where pk_jobmngfil ='"+pk_jobmngfil+"' and dr = 0) "
+    		+ "and dr=0";
+    Map<String,String> map = (Map<String, String>) iuap.executeQuery(sql, new MapProcessor());
+    if (map == null || map.size()==0) {
+    	throw new Exception("项目管理档案"+pk_jobmngfil+"未查到,请检查"); 
+    }
+    return map;
+}
+
+//业务类型自定义档案查询
+private String getpkdefdoc(String docname ) throws Exception {
+  String sql="select pk_defdoc from bd_defdoc  where pk_defdoclist = "
+  		+ "(select pk_defdoclist from bd_defdef where defname = '业务类型' and dr=0 ) and dr=0 "
+  		+ "and docname='"+docname+"'";
+  
+  Object pkdefdoc =  iuap.executeQuery(sql, new ColumnProcessor());
+  if(pkdefdoc == null ||  "".equals(pkdefdoc)) {
+		throw new Exception("业务类型【"+docname+"】未查到,请检查");
+	  }
+
+  return pkdefdoc.toString();
+	
+}
+
+private String getzyqpk(String doclistname,String docname) throws BusinessException {
+	
+	if(null==docname || "".equals(docname)) {
+		return "";
+	}
+	
+	//取到自定义档案列表主键
+	String sql = "select pk_defdoclist from bd_defdoclist where doclistname = '"+doclistname+"'";
+	Object pk_defdoclist = iuap.executeQuery(sql, new ColumnProcessor());
+	if(pk_defdoclist == null) {
+		throw new BusinessException("以下档案在U8cloud系统中根据公司或者账簿信息找不到,请检查!详细信息:1、档案类型:自定义档案列表,档案名称:"+doclistname);
+	}
+    String sql1 = "select pk_defdoc  from bd_defdoc where pk_defdoclist = '"+pk_defdoclist.toString()+"' and docname ='"+docname+"'";
+    String pk_defdoc = (String) iuap.executeQuery(sql1, new ColumnProcessor());
+    
+	return pk_defdoc;
+	
+}
 
 }