zthwr před 10 měsíci
rodič
revize
cb5309a4c0

+ 65 - 3
xc/cg/src/private/u8c/bs/mytest/bp/SpecialDataRule.java

@@ -1,5 +1,6 @@
 package u8c.bs.mytest.bp;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import nc.bs.framework.common.NCLocator;
@@ -10,7 +11,9 @@ import nc.jdbc.framework.processor.MapProcessor;
 import nc.vo.bd.def.DefdocVO;
 import nc.vo.pub.BusinessException;
 import nc.vo.pub.CircularlyAccessibleValueObject;
+import nc.vo.pub.lang.UFDate;
 import nc.vo.pub.lang.UFDouble;
+import u8c.bs.upifsp.pub.UpifsTool;
 import u8c.pubitf.rule.IRule;
 import u8c.vo.AggDemandVO;
 import u8c.vo.DemandBVO;
@@ -44,12 +47,32 @@ public class SpecialDataRule implements IRule<AggDemandVO> {
 				demandBVO.setSpec(invbasdocMap.get("invspec"));
 				//型号
 				demandBVO.setModel(invbasdocMap.get("invtype"));
+//				//米重
+//				demandBVO.setWeight(invbasdocMap.get("def1"));
+//				//装饰面周长
+//				demandBVO.setRound(invbasdocMap.get("def2"));
 				//米重
-				demandBVO.setWeight(invbasdocMap.get("def1"));
+				demandBVO.setWeight(invbasdocMap.get("def2"));
 				//装饰面周长
-				demandBVO.setRound(invbasdocMap.get("def2"));
+				demandBVO.setRound(invbasdocMap.get("def3"));
+				//窗号
+				demandBVO.setVdef21(invbasdocMap.get("def1"));
+				//专用区
+			//	demandBVO.setVdef22(invbasdocMap.get("def4"));
+				demandBVO.setVdef22(getzyqpk("专用区",invbasdocMap.get("def4")));
+				//待定
+				demandBVO.setVdef23(invbasdocMap.get("def5"));
+				
 				//计量单位
 				demandBVO.setUnitid(invbasdocMap.get("measname"));
+				
+				
+				if(demandBVO.getNum() == null && !demandBVO.getCmaterialcode().startsWith("MA") ) {
+					throw new BusinessException("除了型材(MA开头),主数量必须填写");
+				}
+				
+			
+				
 				if(invbasdocMap.get("measnames") != null) {
 					//辅单位
 					demandBVO.setCastunitid(invbasdocMap.get("measnames"));
@@ -60,9 +83,13 @@ public class SpecialDataRule implements IRule<AggDemandVO> {
 					if(demandBVO.getNastnum() == null) {
 						throw new BusinessException("存货:"+demandBVO.getCmaterialcode()+"有辅计量单位,辅数量不能为空");
 					}
+					//MA开头的物料不传主数量所有换算率不需要计算
+					if(number != null && !demandBVO.getCmaterialcode().startsWith("MA")) {
 					//换算率
 					UFDouble result = new UFDouble(number.div(nastnum).toString(),2);
 					demandBVO.setVdef13(result.toString());
+				   }	
+					
 				}else {
 					if(demandBVO.getNastnum() != null) {
 						//存货不管启没启动辅单位,辅数量都会填,没有启动的就不读取辅数量
@@ -100,6 +127,8 @@ public class SpecialDataRule implements IRule<AggDemandVO> {
     	sql.append(" bd_invbasdoc.def1 as def1,");
     	sql.append(" bd_invbasdoc.def2 as def2,");
     	sql.append(" bd_invbasdoc.def3 as def3,");
+      	sql.append(" bd_invbasdoc.def4 as def4,");
+    	sql.append(" bd_invbasdoc.def5 as def5,");
     	sql.append(" bd_measdoc.measname as measname,");
     	sql.append(" bd_measdocs.measname as measnames");
     	sql.append(" from");
@@ -136,8 +165,21 @@ public class SpecialDataRule implements IRule<AggDemandVO> {
         	DefdocVO defdocVO = new DefdocVO();
         	//公司
         	defdocVO.setPk_corp("0001");
+        	
+        	//档案编码
+        	UFDate date = new UFDate();
+        	//YSDC20231219000000
+        	HashMap<String, String> billcode_map = UpifsTool
+					.GreatVbillcode("doccode", "YSDC", date,
+							"bd_defdoc",pk_defdoclist);
+        	String billcode_s = billcode_map.get("billcode_s");// 单据号前段
+			String billcode_e = billcode_map.get("billcode_e");// 单据号流水号
+			Integer billcode_tj = new Integer(billcode_e);
+			billcode_tj=billcode_tj+1;
+			String billcode =billcode_s+UpifsTool.ChangeIntToStr(billcode_tj);
+			
         	//档案编码
-        	defdocVO.setDoccode(docname);
+        	defdocVO.setDoccode(billcode);
         	//档案名称
         	defdocVO.setDocname(docname);
         	//档案系统属性
@@ -147,5 +189,25 @@ public class SpecialDataRule implements IRule<AggDemandVO> {
         	iDefdoc.saveVOs(pk_defdoclist, new DefdocVO[] {defdocVO});
         }
     }
+    
+    
+     private String getzyqpk(String doclistname,String pk_defdoc) throws BusinessException {
+    	
+    	if(null==pk_defdoc || "".equals(pk_defdoc)) {
+    		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 docname  from bd_defdoc where pk_defdoclist = '"+pk_defdoclist.toString()+"' and pk_defdoc ='"+pk_defdoc+"'";
+        String docname = (String) iuap.executeQuery(sql1, new ColumnProcessor());
+        
+		return docname;
+    	
+    }
 
 }