Kaynağa Gözat

物料接口新增批次号管理,自动生成自定义档案,计量单位按名称取值

pancy 1 yıl önce
ebeveyn
işleme
233ae42334

+ 102 - 5
mmpac/mmpac/src/private/u8c/impl/mmpac/mmpac/InvAddImpl.java

@@ -19,8 +19,10 @@ import nc.bs.framework.adaptor.IHttpServletAdaptor;
 import nc.bs.framework.common.InvocationInfoProxy;
 import nc.bs.framework.common.NCLocator;
 import nc.itf.uap.IVOPersistence;
+import nc.itf.uap.bd.def.IDefdoc;
 import nc.itf.uap.bd.inv.IInventoryAssign;
 import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.vo.bd.def.DefdocVO;
 import nc.vo.bd.invdoc.InvbasdocVO;
 import nc.vo.bd.invdoc.InvmandocVO;
 import nc.vo.pub.BusinessException;
@@ -41,12 +43,29 @@ public class InvAddImpl extends BaseServlet implements IHttpServletAdaptor{
 	IVOPersistence ivo = NCLocator.getInstance().lookup(IVOPersistence.class);
 	IInventoryAssign iassign = NCLocator.getInstance().lookup(IInventoryAssign.class);
 	UserTransaction trans;
+	String color = "";//颜色
+	String colordeflist = "";//颜色对应自定义档案列表主键
+	String alloy = "";//合金
+	String alloydeflist = "";//合金对应自定义档案列表主键
+	String sizing = "";//定尺
+	String sizingdeflist = "";//定尺对应自定义档案列表主键
+	String standard = "";//标准
+	String standarddeflist = "";//标准对应自定义档案列表主键
+	IDefdoc idef = NCLocator.getInstance().lookup(IDefdoc.class);
 	
 	@Override
 	public void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
 		try {
 			trans = NCLocator.getInstance().lookup(UserTransaction.class);
 			trans.begin();//开启事务
+			color = GetBaseDAOUtil.getdefdef("YS(颜色)").getPk_defdef();
+			colordeflist = GetBaseDAOUtil.getdefdef("YS(颜色)").getPk_defdoclist();
+			alloy = GetBaseDAOUtil.getdefdef("HI(合金)").getPk_defdef();
+			alloydeflist = GetBaseDAOUtil.getdefdef("HI(合金)").getPk_defdoclist();
+			sizing = GetBaseDAOUtil.getdefdef("DC(定尺)").getPk_defdef();
+			sizingdeflist = GetBaseDAOUtil.getdefdef("DC(定尺)").getPk_defdoclist();
+			standard = GetBaseDAOUtil.getdefdef("BZ(标准)").getPk_defdef();
+			standarddeflist = GetBaseDAOUtil.getdefdef("BZ(标准)").getPk_defdoclist();
 			String createStr = buildJson(req, resp, this.getClass().getName());
 			JSONObject json = JSON.parseObject(createStr);
 			//接口返回结果
@@ -102,7 +121,7 @@ public class InvAddImpl extends BaseServlet implements IHttpServletAdaptor{
 				//存货分类
 				String invCl = GetBaseDAOUtil.getInvClid(bodyObject.getString("invCl"));
 				//主计量单位
-				String invMeas = GetBaseDAOUtil.getMeasid(bodyObject.getString("invMeas"));
+				String invMeas = GetBaseDAOUtil.getMeasidByName(bodyObject.getString("invMeas"));
 				//税目
 				String invTaxitems = GetBaseDAOUtil.gettaxitemid(bodyObject.getString("invTaxitems"));
 				//图号
@@ -115,6 +134,43 @@ public class InvAddImpl extends BaseServlet implements IHttpServletAdaptor{
 				String width = bodyObject.getString("width");
 				//备注
 				String memo = bodyObject.getString("memo");
+				//批次管理
+				String wholemanaflag = bodyObject.getString("wholemanaflag");
+				//颜色
+				Object ys = bodyObject.getString("ys");
+				//合金
+				Object hj = bodyObject.getString("hj");
+				//定尺
+				Object dc = bodyObject.getString("dc");
+				//标准
+				Object bz = bodyObject.getString("bz");
+				
+				if(!ys.equals("")&&ys != null) {
+					String yspk = GetBaseDAOUtil.getdefdocid(colordeflist, ys.toString());
+					if(yspk.equals("")) {
+						genDocVO(pk_corp, ys.toString());
+					}
+				}
+				if(!hj.equals("")&&hj != null) {
+					String hjpk = GetBaseDAOUtil.getdefdocid(alloydeflist, hj.toString());
+					if(hjpk.equals("")) {
+						genDocVO(pk_corp, hj.toString());
+					}
+				}
+				if(!dc.equals("")&&dc != null) {
+					String dcpk = GetBaseDAOUtil.getdefdocid(sizingdeflist, dc.toString());
+					if(dcpk.equals("")) {
+						genDocVO(pk_corp, dc.toString());
+					}
+				}
+				if(!bz.equals("")&&bz != null) {
+					String bzpk = GetBaseDAOUtil.getdefdocid(standarddeflist, bz.toString());
+					if(bzpk.equals("")) {
+						genDocVO(pk_corp, bz.toString());
+					}
+				}
+				
+				
 				String pk_inv = "";
 				InvbasdocVO invbasVo = GetBaseDAOUtil.getInvVO(invCode);
 				if(invbasVo != null) {
@@ -134,6 +190,18 @@ public class InvAddImpl extends BaseServlet implements IHttpServletAdaptor{
 					invbasVo.setMemo(memo);
 					invbasVo.setCreator("demo");
 					invbasVo.setSealflag(UFBoolean.FALSE);
+					if(!ys.equals("")) {
+						invbasVo.setFree1(color);
+					}
+					if(!hj.equals("")) {
+						invbasVo.setFree2(alloy);
+					}
+					if(!dc.equals("")) {
+						invbasVo.setFree3(sizing);
+					}
+					if(!bz.equals("")) {
+						invbasVo.setFree4(standard);
+					}
 					ivo.updateVO(invbasVo);
 				}
 				else {
@@ -171,12 +239,24 @@ public class InvAddImpl extends BaseServlet implements IHttpServletAdaptor{
 					invbasVo.setDr(0);
 					invbasVo.setCreator("demo");
 					invbasVo.setSealflag(UFBoolean.FALSE);
+					if(!ys.equals("")) {
+						invbasVo.setFree1(color);
+					}
+					if(!hj.equals("")) {
+						invbasVo.setFree2(alloy);
+					}
+					if(!dc.equals("")) {
+						invbasVo.setFree3(sizing);
+					}
+					if(!bz.equals("")) {
+						invbasVo.setFree4(standard);
+					}
 					pk_inv = ivo.insertVO(invbasVo);
 				}
 				//查看当前存货是否有对应的存货管理档案
 				String pk_invman = IsExist(pk_inv);
 				if(pk_invman.equals("")) {
-					pk_invman = saveInvman(invbasVo,pk_inv);
+					pk_invman = saveInvman(invbasVo,pk_inv,wholemanaflag);
 				}
 				
 				List<String> listpk = new ArrayList<String>();
@@ -216,6 +296,17 @@ public class InvAddImpl extends BaseServlet implements IHttpServletAdaptor{
 		}
 	}
 
+	//生成自定义档案
+	private void genDocVO(String pk_corp, String docname) throws BusinessException {
+		DefdocVO docvo = new DefdocVO();
+		docvo.setDoccode(docname);
+		docvo.setDocname(docname);
+		docvo.setDocsystype(1);
+		docvo.setPk_corp(pk_corp);
+		docvo.setPk_defdoclist(colordeflist);
+		String respk = idef.insert(docvo);
+	}
+
 	/*
 	 * 非空判断
 	 */
@@ -239,10 +330,11 @@ public class InvAddImpl extends BaseServlet implements IHttpServletAdaptor{
 		String invCl = "invCl";//存货分类
 		String invMeas = "invMeas";//主计量单位
 		String invTaxitems = "invTaxitems";//税目
+		String wholemanaflag = "wholemanaflag";
  
 		for(int i = 0; i < oprepObjectBs.size(); i++) {
 			JSONObject oprepJsonObjectB = oprepObjectBs.getJSONObject(i);
-			String[] HeadKey = {pk_corp,invCode,invName,invCl,invMeas,invTaxitems};
+			String[] HeadKey = {pk_corp,invCode,invName,invCl,invMeas,invTaxitems,wholemanaflag};
 			int num = i+1;
 			
 			mags.append("第"+num+"块:{");
@@ -282,7 +374,7 @@ public class InvAddImpl extends BaseServlet implements IHttpServletAdaptor{
 	 * @return
 	 * @throws BusinessException
 	 */
-	private String saveInvman(InvbasdocVO invbasVo, String pk_inv) throws BusinessException {
+	private String saveInvman(InvbasdocVO invbasVo, String pk_inv,String wholemanaflag) throws BusinessException {
 		InvmandocVO invmanVO = new InvmandocVO();
 		
 		invmanVO.setPk_invbasdoc(pk_inv);
@@ -332,7 +424,12 @@ public class InvAddImpl extends BaseServlet implements IHttpServletAdaptor{
 		invmanVO.setConsumesettleflag(UFBoolean.FALSE);
 		invmanVO.setCreatetime(new UFDateTime());
 		invmanVO.setCreator("demo");
-		
+		if(wholemanaflag.equals("Y")) {
+			invmanVO.setWholemanaflag(UFBoolean.TRUE);
+		}
+		else {
+			invmanVO.setWholemanaflag(UFBoolean.FALSE);
+		}
 		//保存管理档案
 		String pk_invman = dao.insertVO(invmanVO);
 		

+ 26 - 2
mmpac/mmpac/src/public/u8c/bs/servlet/service/GetBaseDAOUtil.java

@@ -1,10 +1,14 @@
 package u8c.bs.servlet.service;
 
+import java.util.List;
+
 import nc.bs.framework.common.NCLocator;
 import nc.itf.uap.IUAPQueryBS;
 import nc.jdbc.framework.processor.BeanProcessor;
+import nc.jdbc.framework.processor.ColumnListProcessor;
 import nc.jdbc.framework.processor.ColumnProcessor;
 import nc.vo.bd.b09.CumandocVO;
+import nc.vo.bd.def.DefdefVO;
 import nc.vo.bd.invdoc.InvbasdocVO;
 import nc.vo.bd.invdoc.InvmandocVO;
 import nc.vo.pub.BusinessException;
@@ -164,7 +168,7 @@ public class GetBaseDAOUtil {
         return pk_invcl;
     }
     
-    //计量单位主键
+    //税目主键
     public static String gettaxitemid(String invTaxitems) throws Exception {
         String sql = "select pk_taxitems from bd_taxitems where isnull(dr,0) = 0 and taxcode = '"+invTaxitems+"'";
         String pk_taxitems = (String) iuap.executeQuery(sql, new ColumnProcessor());
@@ -174,7 +178,7 @@ public class GetBaseDAOUtil {
         return pk_taxitems;
     }
     
-    //税目主键
+    //根据编码获取计量单位主键
     public static String getMeasid(String invMeas) throws Exception {
         String sql = "select pk_measdoc from bd_measdoc where isnull(dr,0) = 0 and shortname = '"+invMeas+"'";
         String pk_measdoc = (String) iuap.executeQuery(sql, new ColumnProcessor());
@@ -309,4 +313,24 @@ public class GetBaseDAOUtil {
         }
         return orderInVO;
     }
+    
+    //查询用户定义项
+    public static DefdefVO getdefdef(String defname) throws Exception {
+    	String qrysql = "select * from bd_defdef where defname = '"+defname+"'";
+    	DefdefVO res = (DefdefVO) iuap.executeQuery(qrysql, new BeanProcessor(DefdefVO.class));
+    	if(res == null) {
+    		return null;
+    	}
+    	return res;
+    }
+    
+    //查询自定义档案主键
+    public static String getdefdocid(String pk_defdoclist,String docname) throws Exception{
+    	String qrysql = "select pk_defdoc from bd_defdoc where pk_defdoclist = '"+pk_defdoclist+"' and docname = '"+docname+"'";
+    	String res = (String) iuap.executeQuery(qrysql, new ColumnProcessor());
+    	if(res == null) {
+    		return "";
+    	}
+    	return res;
+    }
 }