Explorar o código

销售退货接口初始化

18870042648 %!s(int64=2) %!d(string=hai) anos
pai
achega
823238c157

+ 4 - 0
ypff/META-INF/service.upm

@@ -18,5 +18,9 @@
             <interface>nc.bs.framework.adaptor.IHttpServletAdaptor</interface>
             <implementation>nc.bs.yp.impl.OprepAddImpl</implementation>
         </component>
+        <component accessProtected="false" name="Saleorder" remote="true" singleton="true" tx="CMT">
+            <interface>nc.bs.framework.adaptor.IHttpServletAdaptor</interface>
+            <implementation>nc.bs.yp.impl.SaleorderOutboundImpl</implementation>
+        </component>
     </public>
 </module>

+ 1 - 0
ypff/ypff/classes/.gitignore

@@ -0,0 +1 @@
+/nc/

+ 0 - 1
ypff/ypff/src/private/nc/bs/yp/impl/PomUpdateStatusImpl.java

@@ -24,7 +24,6 @@ import nc.log.NcLog;
 import nc.md.persist.framework.IMDPersistenceQueryService;
 import nc.vo.mmpac.pickm.entity.AggPickmVO;
 import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
-import nc.yp.dao.PomStatusMaintain;
 import net.sf.json.JSONObject;
 
 /**

+ 176 - 0
ypff/ypff/src/private/nc/bs/yp/impl/SaleorderOutboundImpl.java

@@ -0,0 +1,176 @@
+package nc.bs.yp.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import nc.bs.dao.BaseDAO;
+import nc.bs.dao.DAOException;
+import nc.bs.framework.adaptor.IHttpServletAdaptor;
+import nc.bs.framework.common.InvocationInfoProxy;
+import nc.bs.framework.common.NCLocator;
+import nc.bs.framework.server.ISecurityTokenCallback;
+import nc.bs.pub.pf.PfUtilTools;
+import nc.bs.servlet.service.BaseServlet;
+import nc.itf.ic.m4c.self.ISaleOutMaintain;
+import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.log.NcLog;
+import nc.md.persist.framework.IMDPersistenceQueryService;
+import nc.vo.ic.m4c.entity.SaleOutVO;
+import nc.vo.pub.BusinessException;
+import nc.vo.so.m4331.entity.DeliveryVO;
+import net.sf.json.JSONObject;
+
+/**
+ * 销售退货
+ * @author LP
+ *
+ */
+@SuppressWarnings("restriction")
+public class SaleorderOutboundImpl extends BaseServlet implements IHttpServletAdaptor {
+	
+	private static final String TURE = "0";
+	private static final String FALSE = "1";
+	private IMDPersistenceQueryService qryService = NCLocator.getInstance().lookup(IMDPersistenceQueryService.class);
+	private BaseDAO dao = new BaseDAO();
+	private JSONObject p_data = null;
+
+	@Override
+	public void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+		
+		NCLocator.getInstance().lookup(ISecurityTokenCallback.class).token("NCSystem".getBytes(),"pfxx".getBytes());
+        InvocationInfoProxy.getInstance().setUserDataSource("syptest210103");
+		
+        String vbillcode = "";
+        String errorMessgae = "";
+        JSONObject logObject = new JSONObject();
+        logObject.accumulate("InterName","销售退货");
+		String json = buildJson(req, resp, this.getClass().getName());
+		PrintWriter out = resp.getWriter();
+		
+			try {
+			
+			p_data = JSONObject.fromObject(json);//获取报文
+			
+			logObject.accumulate("InputData", p_data);
+			
+			vbillcode = p_data.getString("vbillcode");//获取流程生产订单单号
+			
+			checkJson();//非空判断
+			
+			DeliveryVO deliveryVO = getDeliveryVO(vbillcode);//获取发货单AggVO
+			
+			InvocationInfoProxy.getInstance().setGroupId(SqlexecuteQuery("pk_group", "org_group", "code", p_data.getString("group")));
+			InvocationInfoProxy.getInstance().setUserId(SqlexecuteQuery("cuserid", "sm_user", "user_code", p_data.getString("creator")));
+			
+			SaleOutVO sOutVO = (SaleOutVO) PfUtilTools.runChangeData("4331", "4C", deliveryVO);
+			
+			setSaleOutVO(sOutVO);
+			
+			out.print(formatRSJsonData(TURE, p_data.getString("vbillcode"), "成功"));
+			logObject.accumulate("OutData", formatRSJsonData(TURE, p_data.getString("vbillcode"), "成功").toString());
+			
+		} catch (Exception e) {
+			
+			String error = e.getMessage()==null?e.toString():e.getMessage().toString();
+			out.print(formatRSJsonData(FALSE, vbillcode, error));
+			logObject.accumulate("OutData",formatRSJsonData(FALSE, vbillcode, error).toString());
+			errorMessgae = StackTrace(e);
+			
+		}finally {
+			NcLog.info(logObject.toString()+"\r"+errorMessgae);
+			out.flush();
+			out.close();
+		}
+		
+		
+	}
+	
+	/*
+	 * 保存销售出库
+	 */
+	private void setSaleOutVO(SaleOutVO sOutVO) throws BusinessException {
+		
+		sOutVO.getParentVO().setCwarehouseid(SqlexecuteQuery("pk_stordoc", "bd_stordoc", "code", p_data.getString("cwarehouseid")));
+		
+		NCLocator.getInstance().lookup(ISaleOutMaintain.class).insert(new SaleOutVO[] {sOutVO});
+		
+	}
+	
+	
+	/*
+	 * 非空判断
+	 */
+	private void checkJson() throws Exception {
+		
+		StringBuffer mags = new StringBuffer();
+		
+		String vbillcode = "vbillcode";//销售订单单号
+		String group = "group";//集团编码
+		String creator = "creator";//创建人
+		String cwarehouseid = "cwarehouseid";//仓库
+ 
+		String[] HeadKey = {vbillcode,group,creator,cwarehouseid};
+		
+		for (String as : HeadKey) {
+
+			if (p_data.getString(as).isEmpty()) {
+				mags.append("'" + as + "'");
+			}
+		}
+		
+		if (mags.length()!=0) {
+			throw new Exception("以下字段不可为空:"+mags);
+		}
+	}
+	
+	/*
+	 * 获取销售订单AggVO
+	 */
+	@SuppressWarnings("unchecked")
+	private DeliveryVO getDeliveryVO(String vbillcode) throws Exception {
+		
+		ArrayList<DeliveryVO> DeliveryVOs = (ArrayList<DeliveryVO>) 
+				qryService.queryBillOfVOByCond(DeliveryVO.class,"vbillcode = '"+vbillcode+"'",true,false);
+		
+		if (DeliveryVOs == null || DeliveryVOs.size() == 0) {
+			throw new Exception("根据单据号'"+vbillcode+"'未找到发货单,请检查!");
+		}else {
+			DeliveryVO deliveryVO = (DeliveryVO) DeliveryVOs.get(0).clone();
+			return deliveryVO;
+		}
+	}
+	
+	/*
+	 * 异常信息明细
+	 */
+	private String StackTrace(Exception e) {
+	    StringWriter sw = new StringWriter();
+	    PrintWriter pw = new PrintWriter(sw);
+	    e.printStackTrace(pw);
+	    return sw.toString();
+	}
+	
+	/*
+	 * 数据库查询
+	 */
+	private String SqlexecuteQuery(String out,String table,String key,String value) throws DAOException {
+		
+		String sql = "select "+out+" from "+table+" where "+key+" = '"+value+"' and nvl(dr,0)=0";
+		
+		Object object = dao.executeQuery(sql, new ColumnProcessor());
+		
+		if (object==null) {
+			throw new DAOException("未查询到数据!请检查编码"+value+"是否正确!");
+		}
+		
+		return object.toString();
+		
+	}
+
+}