|
@@ -0,0 +1,128 @@
|
|
|
+package nc.bs.yp.impl;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.PrintWriter;
|
|
|
+import java.io.StringWriter;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.servlet.ServletException;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+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.servlet.service.BaseServlet;
|
|
|
+import nc.itf.so.m4331.IDeliveryAssitFunc;
|
|
|
+import nc.itf.uap.IUAPQueryBS;
|
|
|
+import nc.jdbc.framework.processor.ColumnProcessor;
|
|
|
+import nc.log.NcLog;
|
|
|
+import nc.md.persist.framework.IMDPersistenceQueryService;
|
|
|
+import nc.vo.pub.BusinessException;
|
|
|
+import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
|
|
+import nc.vo.pubapp.pattern.model.transfer.bill.ClientBillCombinServer;
|
|
|
+import nc.vo.so.m4331.entity.DeliveryVO;
|
|
|
+import nc.vo.so.pub.SOParameterVO;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+
|
|
|
+public class DeliveryCloseImpl extends BaseServlet implements IHttpServletAdaptor{
|
|
|
+
|
|
|
+ IUAPQueryBS iuap= (IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
|
|
|
+ IMDPersistenceQueryService service = NCLocator.getInstance().lookup(IMDPersistenceQueryService.class);
|
|
|
+ String pk_group = "";
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ pk_group = this.qryGroup();
|
|
|
+ InvocationInfoProxy.getInstance().setGroupId(pk_group);
|
|
|
+ NCLocator.getInstance().lookup(ISecurityTokenCallback.class).token("NCSystem".getBytes(),"pfxx".getBytes());
|
|
|
+ String createStr = buildJson(req, resp, this.getClass().getName());
|
|
|
+ JSONObject json = JSONObject.fromObject(createStr);
|
|
|
+ String vbillcode = "";
|
|
|
+ Object cdeliveryid = null;
|
|
|
+ PrintWriter out = resp.getWriter();
|
|
|
+ vbillcode = json.getString("vbillcode");
|
|
|
+ try {
|
|
|
+ checkJson(json);
|
|
|
+ String qrysql = "select cdeliveryid from so_delivery where nvl(dr,0)=0 and vbillcode = '"+vbillcode+"'";
|
|
|
+ cdeliveryid = iuap.executeQuery(qrysql, new ColumnProcessor());
|
|
|
+ if(cdeliveryid != null) {
|
|
|
+ DeliveryVO deliveryvo = (DeliveryVO) service.queryBillOfNCObjectByPK(DeliveryVO.class,cdeliveryid.toString()).getContainmentObject();
|
|
|
+ DeliveryVO[] bills = new DeliveryVO[1];
|
|
|
+ bills[0] = deliveryvo;
|
|
|
+ DeliveryVO[] ret = null;
|
|
|
+ ret = this.getServcie().closeDelivery(bills);
|
|
|
+ vbillcode = ret[0].getParentVO().getVbillcode();
|
|
|
+ resp.getWriter().write(formatRSJsonData("成功",
|
|
|
+ vbillcode,"").toString());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ resp.getWriter().write(formatRSJsonData("失败",
|
|
|
+ vbillcode,"查不到该发货单").toString());
|
|
|
+ NcLog.info("查不到该发货单:"+vbillcode);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ resp.getWriter().write(formatRSJsonData("失败",
|
|
|
+ vbillcode,e.getMessage().toString()).toString());
|
|
|
+ StringWriter stringWriter = new StringWriter();
|
|
|
+ e.printStackTrace(new PrintWriter(stringWriter));
|
|
|
+ //获取详细信息
|
|
|
+ String msg=stringWriter.getBuffer().toString();
|
|
|
+ NcLog.info("接口返回值提示:"+msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private IDeliveryAssitFunc getServcie() {
|
|
|
+ return NCLocator.getInstance().lookup(IDeliveryAssitFunc.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 非空判断
|
|
|
+ * @param json
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private void checkJson(JSONObject json) throws Exception {
|
|
|
+
|
|
|
+ StringBuffer mags = new StringBuffer();
|
|
|
+ Boolean empty = true;
|
|
|
+
|
|
|
+ String vbillcode = "vbillcode";//单据号
|
|
|
+
|
|
|
+ String[] HeadKey = {vbillcode};
|
|
|
+
|
|
|
+ for (String as : HeadKey) {
|
|
|
+
|
|
|
+ if (json.getString(as).isEmpty()) {
|
|
|
+ empty = false;
|
|
|
+ mags.append("'" + as + "'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty) {
|
|
|
+ throw new Exception("以下字段不可为空:"+mags);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取集团id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String qryGroup() {
|
|
|
+ String qrysql = "select pk_group from org_group where nvl(dr,0)=0 and rownum = 1";
|
|
|
+ String pk_group;
|
|
|
+ try {
|
|
|
+ pk_group = (String) iuap.executeQuery(qrysql, new ColumnProcessor());
|
|
|
+ return pk_group;
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|