Explorar el Código

请购单和MRP运算优化

zthwr hace 10 meses
padre
commit
bb31c52f3b

+ 129 - 22
mm/mm/src/client/u8c/ui/mm/action/PushParybillAction.java

@@ -11,6 +11,7 @@ import nc.itf.uap.IUAPQueryBS;
 import nc.itf.uap.IVOPersistence;
 import nc.itf.uap.pf.IplatFormEntry;
 import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.jdbc.framework.processor.MapProcessor;
 import nc.ui.hr.frame.FrameUI;
 import nc.ui.hr.frame.action.AbstractAction;
 import nc.ui.hr.frame.impl.MainBillMgrPanel;
@@ -30,6 +31,14 @@ import nc.vo.pub.lang.UFDouble;
 import u8c.ui.mm.panel.OperationMainPanel;
 import u8c.ui.mm.panel.OperationTestUI;
 
+/**
+ * 请购单
+ *@Description: TODO
+ *@Author: ZTH
+ *@Date:2023年12月22日 下午6:49:00
+ *@Version: V1.0
+ */
+
 public class PushParybillAction extends AbstractAction {
 
 	private IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
@@ -128,12 +137,31 @@ public class PushParybillAction extends AbstractAction {
 				header.setCaccountyear(String.valueOf(new UFDate().getYear()));// 年份
 				header.setIpraysource(5);// 请购来源
 				header.setIpraytype(2);// 请购类型 
-				//项目编码 pk_defdoc9
-				header.setAttributeValue("pk_defdoc9", headvo.getProjectid());
+//				//项目编码 pk_defdoc9
+//				header.setAttributeValue("pk_defdoc9", headvo.getProjectid());
+//				//项目名称pk_defdoc10
+//				header.setAttributeValue("pk_defdoc10", headvo.getProjectid());
+//				//加工单号pk_defdoc2
+//				header.setAttributeValue("pk_defdoc2", entry.getKey());
+				
+				
+				
+				Map<String,String> mapcodename=getprojectmap(headvo.getProjectid());
+//				//项目编码 
+//				header.setAttributeValue("vuserdef9",mapcodename.get("jobcode") );
+//				//项目编码 pk_defdoc9
+//				header.setAttributeValue("pk_defdoc9", headvo.getProjectid());
+				//项目名称
+				header.setAttributeValue("vdef10", mapcodename.get("jobname"));
 				//项目名称pk_defdoc10
-				header.setAttributeValue("pk_defdoc10", headvo.getProjectid());
-				//加工单号pk_defdoc2
-				header.setAttributeValue("pk_defdoc2", entry.getKey());
+				header.setAttributeValue("pk_defdoc10", headvo.getProjectid());				
+				//加工单号
+				header.setAttributeValue("vdef1", entry.getKey());
+				//业务类型
+				header.setAttributeValue("vdef7", headvo.getBusitype());
+				
+				header.setAttributeValue("pk_defdoc7",getpkdefdoc( headvo.getBusitype()));
+				
 				
 				List<OperationPurchaseVO> lispurvos=entry.getValue();
 				PraybillItemVO[] items = new PraybillItemVO[lispurvos.size()];
@@ -147,8 +175,12 @@ public class PushParybillAction extends AbstractAction {
 					praybillItemVO.setCmangid(getCmangchid(getCmangid(zbvo.getCmaterialcode()))); //存货编码
 					praybillItemVO.setCbaseid(getCmangid(zbvo.getCmaterialcode())); //存货基础ID 
 //					praybillItemVO.setNpraynum(new UFDouble(zbvo.getNum())); //数量
-					praybillItemVO.setNpraynum(new UFDouble(zbvo.getVdef26())); //数量
-					praybillItemVO.setNassistnum (zbvo.getNastnum());//辅计量数量
+					UFDouble num=new UFDouble(zbvo.getVdef26());
+					praybillItemVO.setNpraynum(num); //数量
+					UFDouble hsl=new UFDouble(zbvo.getVdef13());
+					praybillItemVO.setNexchangerate(hsl);//换算率
+					praybillItemVO.setCassistunit(getMeasidByNames(zbvo.getCastunitid()));//辅计量单位ID 
+					praybillItemVO.setNassistnum (num.div(hsl));//辅计量数量
 					String cprojectid = headvo.getProjectid();//项目id
 					praybillItemVO.setCprojectid(cprojectid);
 //					praybillItemVO.setCassistunit(demandBVO.getCastunitid());//辅助计量单位
@@ -158,22 +190,41 @@ public class PushParybillAction extends AbstractAction {
 					praybillItemVO.setDsuggestdate(new UFDate(ClientEnvironment.getInstance().getBusinessDate().toString()));
 //					praybillItemVO.setPk_purcorp(PubEnv.getCorpCode());
 					praybillItemVO.setPk_reqcorp(PubEnv.getCorpCode());
-					praybillItemVO.setAttributeValue("pk_defdoc1",zbvo.getVdef1() );//楼号楼层
-					praybillItemVO.setAttributeValue("pk_defdoc2", zbvo.getVdef2());//樘数(数量)
-					praybillItemVO.setAttributeValue("pk_defdoc3", zbvo.getVdef3());//框统计
-					praybillItemVO.setAttributeValue("pk_defdoc4", zbvo.getVdef4());//扇统计
-					praybillItemVO.setAttributeValue("pk_defdoc5", zbvo.getVdef5());//半成品分类
-					praybillItemVO.setAttributeValue("pk_defdoc6", zbvo.getVdef6());//面积
-					praybillItemVO.setAttributeValue("pk_defdoc7", zbvo.getVdef7());//切割长度
-					praybillItemVO.setAttributeValue("pk_defdoc8", zbvo.getVdef8());//切割角度左下
-					praybillItemVO.setAttributeValue("pk_defdoc9", zbvo.getVdef9());//切割角度右上
-					praybillItemVO.setAttributeValue("pk_defdoc10",zbvo.getVdef10());//备注
-					praybillItemVO.setAttributeValue("pk_defdoc11",zbvo.getWidth());//宽度
-					praybillItemVO.setAttributeValue("pk_defdoc12",zbvo.getHeight());//高度
-					praybillItemVO.setAttributeValue("pk_defdoc13",zbvo.getVdef11());//系列
-					praybillItemVO.setAttributeValue("pk_defdoc14",zbvo.getVdef12());//玻璃编号
+//					praybillItemVO.setAttributeValue("pk_defdoc1",zbvo.getVdef1() );//楼号楼层
+//					praybillItemVO.setAttributeValue("pk_defdoc2", zbvo.getVdef2());//樘数(数量)
+//					praybillItemVO.setAttributeValue("pk_defdoc3", zbvo.getVdef3());//框统计
+//					praybillItemVO.setAttributeValue("pk_defdoc4", zbvo.getVdef4());//扇统计
+//					praybillItemVO.setAttributeValue("pk_defdoc5", zbvo.getVdef5());//半成品分类
+//					praybillItemVO.setAttributeValue("pk_defdoc6", zbvo.getVdef6());//面积
+//					praybillItemVO.setAttributeValue("pk_defdoc7", zbvo.getVdef7());//切割长度
+//					praybillItemVO.setAttributeValue("pk_defdoc8", zbvo.getVdef8());//切割角度左下
+//					praybillItemVO.setAttributeValue("pk_defdoc9", zbvo.getVdef9());//切割角度右上
+//					praybillItemVO.setAttributeValue("pk_defdoc10",zbvo.getVdef10());//备注
+//					praybillItemVO.setAttributeValue("pk_defdoc11",zbvo.getWidth());//宽度
+//					praybillItemVO.setAttributeValue("pk_defdoc12",zbvo.getHeight());//高度
+//					praybillItemVO.setAttributeValue("pk_defdoc13",zbvo.getVdef11());//系列
+//					praybillItemVO.setAttributeValue("pk_defdoc14",zbvo.getVdef12());//玻璃编号
 					
-					praybillItemVO.setCassistunit(getMeasidByNames(zbvo.getCastunitid()));//辅计量单位ID 
+					praybillItemVO.setAttributeValue("vdef1",zbvo.getVdef1() );//楼号楼层
+					praybillItemVO.setAttributeValue("vdef2", zbvo.getVdef2());//樘数(数量)
+					praybillItemVO.setAttributeValue("vdef3", zbvo.getVdef3());//框统计
+					praybillItemVO.setAttributeValue("vdef4", zbvo.getVdef4());//扇统计
+					praybillItemVO.setAttributeValue("vdef5", zbvo.getVdef5());//半成品分类
+					praybillItemVO.setAttributeValue("vdef6", zbvo.getVdef6());//面积
+					praybillItemVO.setAttributeValue("vdef7", zbvo.getVdef7());//切割长度
+					praybillItemVO.setAttributeValue("vdef8", zbvo.getVdef8());//切割角度左下
+					praybillItemVO.setAttributeValue("vdef9", zbvo.getVdef9());//切割角度右上
+					praybillItemVO.setAttributeValue("vdef10",zbvo.getVdef10());//备注
+					praybillItemVO.setAttributeValue("vdef11",zbvo.getWidth());//宽度
+					praybillItemVO.setAttributeValue("vdef12",zbvo.getHeight());//高度
+					praybillItemVO.setAttributeValue("vdef13",zbvo.getVdef11());//系列
+					praybillItemVO.setAttributeValue("vdef14",zbvo.getVdef12());//玻璃编号
+					
+//					praybillItemVO.setAttributeValue("vdef15",vector.get()==null?null:vector.get().toString());//开票类型
+		//			praybillItemVO.setAttributeValue("vdef17",vector.get(18)==null?null:vector.get(18).toString());//窗号
+					praybillItemVO.setAttributeValue("vdef18",zbvo.getWeight());//米重
+					praybillItemVO.setAttributeValue("vdef19",zbvo.getRound());//装饰面周长
+		//			itemvo.setAttributeValue("vuserdef20",vector.get(5)==null?null:vector.get(5).toString());//专用区
 					
 					praybillItemVO.setVproducenum (zbvo.getVbatchcode());
 					praybillItemVO.setVfree1(zbvo.getColor());
@@ -235,6 +286,62 @@ public class PushParybillAction extends AbstractAction {
 	
 	
 	
+  //项目管理档案-编码和名称
+    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();
+		
+	}
+	
+	
+	/**
+	 * 查询现存量物料换算率
+	 * @param pk_corp
+	 * @param storcode
+	 * @param cinvbasid
+	 * @param vbatchcode
+	 * @param color    颜色
+	 * @param sizing   定尺
+	 * @param alloy    合金
+	 * @param standard 标准
+	 * @return
+	 * @throws Exception
+	 */
+   	public  Object  getHandNum(String pk_corp,String storcode,String cinvbasid,String vbatchcode, String color ,String sizing,String alloy,String standard)throws Exception {
+   		StringBuffer sql = new StringBuffer();
+   		sql.append("SELECT ");
+   		sql.append(" nonhandnum/nonhandastnum as hsl");
+   		sql.append(" FROM");
+   		sql.append(" ic_onhandnum");
+   		sql.append(" WHERE");
+   		sql.append(" pk_corp = '"+pk_corp+"'");
+   		sql.append(" AND cwarehouseid = ( SELECT pk_stordoc FROM bd_stordoc WHERE storcode = '"+storcode+"' and sealflag = 'N' and dr = 0)");
+   		sql.append(" AND cinvbasid = '"+cinvbasid+"' AND vfree1='"+color+"' AND vfree2='"+alloy+"' AND vfree3='"+sizing+"' AND vfree4='"+standard+"' ");
+   		if(vbatchcode != null) {
+   			sql.append(" AND vlot = '"+vbatchcode+"'");
+   		}
+   		return  iuap.executeQuery(sql.toString(), new ColumnProcessor());
+   	}
 	
 	
 	

+ 61 - 3
mm/mm/src/client/u8c/ui/mm/action/YsAction.java

@@ -40,6 +40,7 @@ import nc.vo.OperationSupplyVO;
 import nc.vo.OperationTransferVO;
 import nc.vo.OrderIssueUAPVO;
 import nc.vo.SafetystockVO;
+import nc.vo.bd.invdoc.InvbasdocVO;
 import nc.vo.ic.pub.bill.SpecialBillHeaderVO;
 import nc.vo.ic.pub.bill.SpecialBillItemVO;
 import nc.vo.ic.pub.bill.SpecialBillVO;
@@ -52,6 +53,7 @@ import nc.vo.pub.ValidationException;
 import nc.vo.pub.lang.UFDate;
 import nc.vo.pub.lang.UFDouble;
 import nc.vo.pubapp.pattern.pub.SqlBuilder;
+import u8c.bs.servlet.service.GetBaseDAOUtil;
 import u8c.ui.mm.panel.OperationTestUI;
 import u8c.vo.ExAggOrderMainVO;
 
@@ -314,7 +316,34 @@ public class YsAction extends YsQuseryAction{
 						}else if("demandtype".equals(name)) {
 							bancevo.setDemandtype(vo.getDemandtyoe());//需求类型
 						}else if("vdef28".equals(name)) {
-							bancevo.setVdef28(vo.getNum().toString());//采购主数量
+//							UFDouble doublenum=vo.getNum();
+//							if(null==doublenum && !vo.getCmaterialcode().startsWith("MA")) {
+//								throw new  ValidationException("存货编码:【"+vo.getCmaterialcode()+"】主数量不能为空!");
+//							}
+							if (vo.getCmaterialcode().startsWith("MA")) {
+								//只有辅数量
+								InvbasdocVO  invbasvo = GetBaseDAOUtil.getInvVO(vo.getCmaterialcode());
+							    String pk_invbasdoc = invbasvo.getPrimaryKey();
+								Object objbdef6 =getHandNum("1001", "工装", pk_invbasdoc, vo.getVbatchcode(), vo.getColor(), 
+							 			                vo.getSizing(), vo.getAlloy(), vo.getStandard());//现存量换算率  
+								
+							    if(null==objbdef6 || "".equals(objbdef6.toString())) {
+									//throw new  ValidationException("存货编码:【"+vo.getCmaterialcode()+"】现存量计算的换算率不能为空!请检查!");
+							    	bancevo.setVdef28(vo.getNastnum().toString());//采购主数量
+							    	bancevo.setNum(vo.getNastnum());
+							    	bancevo.setVdef13("1.00");//换算率
+								}else {
+									bancevo.setVdef28(vo.getNastnum().multiply(new UFDouble(objbdef6.toString()).setScale(2, UFDouble.ROUND_HALF_UP)).toString());//采购主数量
+									bancevo.setNum(vo.getNastnum().multiply(new UFDouble(objbdef6.toString()).setScale(2, UFDouble.ROUND_HALF_UP)));
+									bancevo.setVdef13(objbdef6.toString());//换算率
+								}
+							    
+							    
+							    
+							}else {
+								bancevo.setVdef28(vo.getNum().toString());//采购主数量
+							}
+							
 						}else {
 							bancevo.setAttributeValue(name, vo.getAttributeValue(name));
 						}
@@ -1025,8 +1054,8 @@ public class YsAction extends YsQuseryAction{
 						vo.setVdef18(cgdd.getVdef18());
 						vo.setVdef19(cgdd.getVdef19());
 						vo.setVdef20(cgdd.getVdef20());
-						vo.setVdef21(cgdd.getVdef21());
-						vo.setVdef22(cgdd.getVdef22());
+					//	vo.setVdef21(cgdd.getVdef21());//cgdd.getVdef21()===窗号
+					//	vo.setVdef22(cgdd.getVdef22());//cgdd.getVdef22()===专用区
 						vo.setVdef23(cgdd.getVdef23());
 						vo.setVdef24(cgdd.getVdef24());
 						vo.setVdef25(cgdd.getVdef25());
@@ -1587,5 +1616,34 @@ public class YsAction extends YsQuseryAction{
     	return res;
     }
     
+    /**
+	 * 查询现存量物料换算率
+	 * @param pk_corp
+	 * @param storcode
+	 * @param cinvbasid
+	 * @param vbatchcode
+	 * @param color    颜色
+	 * @param sizing   定尺
+	 * @param alloy    合金
+	 * @param standard 标准
+	 * @return
+	 * @throws Exception
+	 */
+   	public  Object  getHandNum(String pk_corp,String storcode,String cinvbasid,String vbatchcode, String color ,String sizing,String alloy,String standard)throws Exception {
+   		StringBuffer sql = new StringBuffer();
+   		sql.append("SELECT ");
+   		sql.append(" nonhandnum/nonhandastnum as hsl");
+   		sql.append(" FROM");
+   		sql.append(" ic_onhandnum");
+   		sql.append(" WHERE");
+   		sql.append(" pk_corp = '"+pk_corp+"'");
+   		sql.append(" AND cwarehouseid = ( SELECT pk_stordoc FROM bd_stordoc WHERE storcode = '"+storcode+"' and sealflag = 'N' and dr = 0)");
+   		sql.append(" AND cinvbasid = '"+cinvbasid+"' AND vfree1='"+color+"' AND vfree2='"+alloy+"' AND vfree3='"+sizing+"' AND vfree4='"+standard+"' ");
+   		if(vbatchcode != null) {
+   			sql.append(" AND vlot = '"+vbatchcode+"'");
+   		}
+   		return  iuap.executeQuery(sql.toString(), new ColumnProcessor());
+   	}
+    
 	
   }