Selaa lähdekoodia

材料采购接口加物料验证

liyr 11 kuukautta sitten
vanhempi
commit
6f5b1963c5
1 muutettua tiedostoa jossa 34 lisäystä ja 10 poistoa
  1. 34 10
      xc/cg/src/private/u8c/impl/DemandAddImpl.java

+ 34 - 10
xc/cg/src/private/u8c/impl/DemandAddImpl.java

@@ -17,7 +17,9 @@ import nc.bs.framework.adaptor.IHttpServletAdaptor;
 import nc.bs.framework.common.NCLocator;
 import nc.itf.uap.IUAPQueryBS;
 import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.vo.pub.BusinessException;
 import nc.vo.pub.lang.UFDate;
+import nc.vo.pub.lang.UFDouble;
 import nc.vo.trade.pub.IBillStatus;
 import u8c.bs.servlet.service.BaseServlet;
 import u8c.bs.servlet.service.GetBaseDAOUtil;
@@ -33,12 +35,15 @@ public class DemandAddImpl extends BaseServlet implements IHttpServletAdaptor{
 	@Override
 	public void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
 		try {
+			String createStr = buildJson(req, resp, this.getClass().getName());
+			JSONObject json = JSON.parseObject(createStr);
 			//接口返回结果
 			JSONObject returnobj = new JSONObject();
 			//正常返回json
 			JSONArray result = new JSONArray();
 			//报错返回json
 			JSONArray errMessage = new JSONArray();
+			
 			String token =req.getParameter("token");
 			if(!(token!=null && !token.equals("")&&("07a81a68-c60c-4ee4-83dc-25aa51a51497").equals(token))){
 				errMessage.add(formatRSJsonData("失败","请确认通讯密码是否正确!",""));
@@ -51,8 +56,7 @@ public class DemandAddImpl extends BaseServlet implements IHttpServletAdaptor{
 			}
 			trans = NCLocator.getInstance().lookup(UserTransaction.class);
 			trans.begin(); //开启事务
-			String createStr = buildJson(req, resp, this.getClass().getName());
-			JSONObject json = JSON.parseObject(createStr);
+		
 			String checkresult = checkJson(json);
 			if(checkresult != null){
 				errMessage.add(formatRSJsonData("失败",checkresult,""));
@@ -70,7 +74,7 @@ public class DemandAddImpl extends BaseServlet implements IHttpServletAdaptor{
 				String vbillcode = bodyObject.getString("vbillcode");//单据号
 				String pk_demandOld = getVbillcode(vbillcode);
 				if(!StringUtils.isEmpty(pk_demandOld)) {
-					errMessage.add(formatRSJsonData("失败","单据号"+ vbillcode +"已存在","").toString());
+					errMessage.add(formatRSJsonData("失败","单据号"+ vbillcode +"已存在",""));
 					returnobj.put("info", "失败");
 					returnobj.put("errMessage", "单据号"+ vbillcode +"已存在");
 					returnobj.put("result", errMessage);
@@ -81,7 +85,7 @@ public class DemandAddImpl extends BaseServlet implements IHttpServletAdaptor{
 				String dbilldate = bodyObject.getString("dbilldate");//单据日期
 				String billmaker = GetBaseDAOUtil.getUserid(bodyObject.getString("billmaker"));//制单人
 				if(billmaker.equals("")) {
-					errMessage.add(formatRSJsonData("失败","制单人"+bodyObject.getString("billmaker")+"未查到,请检查","").toString());
+					errMessage.add(formatRSJsonData("失败","制单人"+bodyObject.getString("billmaker")+"未查到,请检查",""));
 					returnobj.put("info", "失败");
 					returnobj.put("errMessage", "制单人"+bodyObject.getString("billmaker")+"未查到,请检查");
 					returnobj.put("result", errMessage);
@@ -96,11 +100,13 @@ public class DemandAddImpl extends BaseServlet implements IHttpServletAdaptor{
 				//表头赋值
 				headvo.setPk_corp(pk_corp);
 				headvo.setVbillcode(vbillcode);
-				headvo.setDbilldate(new UFDate(dbilldate));
+				headvo.setDbilldate(new UFDate(dbilldate));//单据日期
+				headvo.setMakedate(new UFDate(dbilldate));//制单日期
 				headvo.setBillmaker(billmaker);
-				headvo.setWorkmanid(workmanid);
+				headvo.setWorkmanid(workmanid);//业务员
 				headvo.setPlandeptid(plandeptid);
-				headvo.setVnote(vnote);
+				headvo.setVnote(vnote);//备注
+				headvo.setVdef30(bodyObject.getString("vdef30"));//业务类型
 				headvo.setBillstatus(IBillStatus.FREE);
 				String pk_demand = dao.insertVO(headvo);
 				//表体赋值
@@ -114,7 +120,7 @@ public class DemandAddImpl extends BaseServlet implements IHttpServletAdaptor{
 						String prjtypecode = GetBaseDAOUtil.getprjtypecode(prjcode);//项目分类编码
 						String prjtypename = GetBaseDAOUtil.getprjtypename(prjcode);//项目分类名称
 						String vbatchcode = injsobj.getString("vbatchcode");//批次
-						String cmaterialcode = injsobj.getString("cmaterialcode");//存货编码
+						String cmaterialcode = SqlexecuteQuery("invcode","bd_invbasdoc","invcode",injsobj.getString("cmaterialcode"));//存货编码
 						String cmaterialname = GetBaseDAOUtil.getinvname(cmaterialcode);//存货名称
 						String spec = GetBaseDAOUtil.getinvspec(cmaterialcode);//规格
 						String model = GetBaseDAOUtil.getinvtype(cmaterialcode);//型号
@@ -134,6 +140,7 @@ public class DemandAddImpl extends BaseServlet implements IHttpServletAdaptor{
 						bodyvo.setWidth(width);
 						bodyvo.setHeight(height);
 						bodyvo.setUnitid(unitid);
+						bodyvo.setNum(new UFDouble(injsobj.getString("num")));//数量
 						bodyvo.setPk_demand(pk_demand);
 						dao.insertVO(bodyvo);
 					}
@@ -154,8 +161,7 @@ public class DemandAddImpl extends BaseServlet implements IHttpServletAdaptor{
 			} 
 			JSONArray errMessage = new JSONArray();
 			JSONObject returnobj = new JSONObject();
-			errMessage.add(formatRSJsonData("失败",
-					e.getMessage(),"").toString());
+			errMessage.add(formatRSJsonData("失败",e.getMessage(),""));
 			returnobj.put("info", "失败");
 			returnobj.put("errMessage", e.getMessage());
 			returnobj.put("result", errMessage);
@@ -176,6 +182,24 @@ public class DemandAddImpl extends BaseServlet implements IHttpServletAdaptor{
         return pk_demand;
     }
     
+    
+	/*
+	 * 数据库查询
+	 */
+	private String SqlexecuteQuery(String out,String table,String key,String value) throws Exception {
+		String sql = "select "+out+" from "+table+" where "+key+" = '"+value+"' and isnull(dr,0) = 0";	
+		Object object;
+		try {
+			object =  new BaseDAO().executeQuery(sql, new ColumnProcessor());
+			if (object==null) {
+				throw new Exception("未查询到数据!请检查编码"+value+"是否正确!");
+			}	
+			return object.toString();
+		} catch (BusinessException e) {
+			e.printStackTrace();
+			return e.getMessage();
+		}
+	}
 	
 	
 	/*