栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

NC销售订单

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

NC销售订单

package nc.ui.so.m30.billui.action;

import java.awt.event.ActionEvent;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import nc.desktop.ui.Workbench;
import nc.desktop.ui.WorkbenchEnvironment;
import nc.itf.pubapp.pub.exception.IResumeException;
import nc.pubitf.credit.accountcheck.IAccountCheckMessageService;
import nc.pubitf.credit.creditcheck.ICreditCheckMessageService;
import nc.ui.iufo.dao.DAOAction_Client;
import nc.ui.pub.beans.MessageDialog;
import nc.ui.pubapp.pub.common.context.PFlowContext;
import nc.ui.pubapp.pub.locator.NCUILocator;
import nc.ui.pubapp.uif2app.AppUiState;
import nc.ui.pubapp.uif2app.model.BillManageModel;
import nc.ui.so.m30.billui.view.SaleOrderBillForm;
import nc.ui.so.pub.keyvalue.CardKeyValue;
import nc.ui.trade.business.HYPubBO_Client;
import nc.uif.pub.exception.UifException;
import nc.vo.bd.defdoc.DefdocVO;
import nc.vo.bd.material.MaterialVO;
import nc.vo.bd.material.measdoc.MeasdocVO;
import nc.vo.bd.stordoc.StordocVO;
import nc.vo.credit.exception.OverPeriodDayCheckException;
import nc.vo.credit.exception.OverPeriodInnerDayCheckException;
import nc.vo.credit.exception.OverPeriodMoneyCheckException;
import nc.vo.org.FactoryVO;
import nc.vo.org.SalesOrgVO;
import nc.vo.org.StockOrgVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVO;
import nc.vo.pub.billtype.BilltypeVO;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.pubapp.pflow.PfUserObject;
import nc.vo.pubapp.res.NCModule;
import nc.vo.scmpub.res.BusinessCheck;
import nc.vo.so.m30.entity.SaleOrderVO;
import nc.vo.so.m4331.entity.DeliveryBVO;
import nc.vo.so.m4331.entity.DeliveryHVO;
import nc.vo.so.pub.enumeration.BillStatus;
//审批
public class SaleOrderMESApproveAction extends nc.ui.pubapp.uif2app.actions.pflow.ApprovescriptAction
{
	
	protected boolean isActionEnable()
	  {
	    Object[] seldatas = model.getSelectedOperaDatas();
	    
	    if ((model.getAppUiState() == AppUiState.NOT_EDIT) && (null != seldatas) && (seldatas.length > 1))
	    {
	      
		return true;
	    }
	    Object selectedData = model.getSelectedData();
	    Integer status = null;
	    if ((null != selectedData) && ((selectedData instanceof SaleOrderVO))) {
	      SaleOrderVO selorder = (SaleOrderVO)selectedData;
	      status = selorder.getParentVO().getFstatusflag();
	    }
	    boolean isEnable = (model.getAppUiState() == AppUiState.NOT_EDIT) && (selectedData != null) && ((BillStatus.FREE.equalsValue(status)) || (BillStatus.AUDITING.equalsValue(status)));
	    
	
	
		
	
	
	    return isEnable;
	  }

	
	private static Date str2Date(String str, String format) {
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		Date date = null;
		try {
			date = sdf.parse(str);
			return date;
		} catch (java.text.ParseException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	
	

private static String date2Str(Date date, String format) {
	SimpleDateFormat sdf = new SimpleDateFormat(format);
	
	if (null == date) {
		return null;
	}
	return sdf.format(date);
}

	
  	@Override
  	public void actionPerformed(ActionEvent e) {
	
		super.actionPerformed(e);
	    Object selectedData = model.getSelectedData();
	    Integer status = null;
	    if ((null != selectedData) && ((selectedData instanceof SaleOrderVO))) {
	      SaleOrderVO selorder = (SaleOrderVO)selectedData;
	      status = selorder.getParentVO().getFstatusflag();
	    }
	    boolean isEnable = (model.getAppUiState() == AppUiState.NOT_EDIT) && (selectedData != null) && ((BillStatus.FREE.equalsValue(status)) || (BillStatus.AUDITING.equalsValue(status)));
	
		if (isEnable){
			MessageDialog.showOkCancelDlg(null, "log", "不执行mes接口");
		}else{
			
			SaleOrderBillForm billform = (SaleOrderBillForm)editor;
		    CardKeyValue keyValue = new CardKeyValue(billform.getBillCardPanel());
		    String hID = keyValue.getHeadStringValue("csaleorderid");//主键
		    String vbillcode = keyValue.getHeadStringValue("vbillcode");//销售发货单-来源单据号
		    
		    StringBuffer sbSql = new StringBuffer("select t.* from jpncdb1.so_delivery_b t where t.csrcid  =  '"+hID+"'");
		    //sbSql.append("");
			//DAOAction_Client.load(DeliveryBVO.class, "jpncdb1", "");
		    try {
		    	//销售发货表体
		    	//MessageDialog.showOkCancelDlg(null, "hID值", hID+"");
				SuperVO[] deliveryBVOs = HYPubBO_Client.queryByCondition(DeliveryBVO.class,  " csrcid = '"+hID+"'");
				//MessageDialog.showOkCancelDlg(null, "deliveryBVOs[0]值", deliveryBVOs[0].toString()+"");
				if(deliveryBVOs.length > 0){
					
					
					//select t.cdeliveryid,t.*  from jpncdb1.so_delivery t where t.cdeliveryid =  '1001AZ10000001C3AO9V'
					SuperVO[] deliveryHVOs = HYPubBO_Client.queryByCondition(DeliveryHVO.class, " cdeliveryid =  '"+deliveryBVOs[0].getAttributevalue("cdeliveryid")+"'");
					//销售发货表头
					SuperVO deliveryHVO = deliveryHVOs[0];
					
					//头
					JSonObject hjson = new JSonObject();
					
					SuperVO trantype = HYPubBO_Client.queryByPrimaryKey(BilltypeVO.class,deliveryHVO.getAttributevalue("ctrantypeid").toString());
					String vtrantypecode=trantype.getAttributevalue("pk_billtypecode").toString();
					String vtrantypename=trantype.getAttributevalue("billtypename").toString();
				    
					
					SuperVO salesorg = null;
					if(deliveryHVO.getAttributevalue("csenddeptvid") != null){
						salesorg = HYPubBO_Client.queryByPrimaryKey(SalesOrgVO.class,deliveryHVO.getAttributevalue("csenddeptvid") == null?"": deliveryHVO.getAttributevalue("csenddeptvid").toString());
					}
					String csenddeptcode =  "";
					if(salesorg != null){
						csenddeptcode = salesorg.getAttributevalue("name").toString();
					}
					
					
					String dbilldate = deliveryHVO.getAttributevalue("dbilldate").toString();
				    if(StringUtils.isNotBlank(dbilldate)){
				    	dbilldate = date2Str(str2Date(dbilldate, "yyyy-MM-dd"), "yyyy/MM/dd");
				    }
				    
					hjson.put("vbillcode", deliveryHVO.getAttributevalue("vbillcode").toString());//销售发货单号
				    hjson.put("ctrantypecode",vtrantypecode);//发货类型
				    //hjson.put("vtrantypename",vtrantypename);//
				    
				    hjson.put("csenddeptcode",csenddeptcode);//发货部门
				    hjson.put("fstatusflag",deliveryHVO.getAttributevalue("fstatusflag").toString());//单据状态
				    hjson.put("dbilldate",dbilldate);//单据日期
				    hjson.put("vnote",deliveryHVO.getAttributevalue("vnote") == null?"": deliveryHVO.getAttributevalue("vnote").toString());//备注 赠品
				    hjson.put("vdef1",deliveryHVO.getAttributevalue("vdef1") == null?"": deliveryHVO.getAttributevalue("vdef1").toString());//自定义项1 
				    
				    //体
				    JSonArray bjsonarr = new JSonArray();
				    for (SuperVO superVO : deliveryBVOs) {
				    	String dsenddate = superVO.getAttributevalue("dsenddate").toString(); //发货日期
				    	if(StringUtils.isNotBlank(dsenddate)){
				    		dsenddate = date2Str(str2Date(dsenddate, "yyyy-MM-dd"), "yyyy/MM/dd");
					    }
				    	SuperVO material = null;
				    	SuperVO defdoc = null;
				    	SuperVO measdoc = null;
				    	SuperVO factory = null;
				    	SuperVO stockorg = null;
				    	SuperVO stordoc = null;
				    	SuperVO cust = null;
				    	
				    	try {
							material = HYPubBO_Client.queryByPrimaryKey(MaterialVO.class,superVO.getAttributevalue("cmaterialid").toString());//物料
							if(superVO.getAttributevalue("vfree1") != null){
								defdoc = HYPubBO_Client.queryByPrimaryKey(DefdocVO.class, superVO.getAttributevalue("vfree1").toString());//颜色
							}
							measdoc = HYPubBO_Client.queryByPrimaryKey(MeasdocVO.class, superVO.getAttributevalue("castunitid").toString());//计量单位
							stockorg = HYPubBO_Client.queryByPrimaryKey(StockOrgVO.class, superVO.getAttributevalue("csendstockorgid").toString());//发货库存组织
							//factory = HYPubBO_Client.queryByPrimaryKey(FactoryVO.class, cfactoryid);//工厂
							//stordoc = HYPubBO_Client.queryByPrimaryKey(StordocVO.class, csendstordocid);//发货仓库
							cust = HYPubBO_Client.queryByPrimaryKey(nc.vo.bd.cust.CustomerVO.class, superVO.getAttributevalue("cordercustid").toString());//客户
							
							
							
						} catch (UifException e1) {
							e1.printStackTrace();
						}
				    	String materialcode=material.getAttributevalue("code").toString();
				    	String materialname=material.getAttributevalue("name").toString();
				    	String materialspec=material.getAttributevalue("materialspec") == null ? "":material.getAttributevalue("materialspec").toString();
				    	String materialversion=material.getAttributevalue("version") == null ? "":material.getAttributevalue("version").toString();//物料版本号
				    	
				    	String defdocname = "";//颜色名称
				    	String defdoccode = "";//颜色code
				    	if(defdoc != null){
				    		defdocname = defdoc.getAttributevalue("name").toString();//颜色名称
				    		defdoccode=defdoc.getAttributevalue("code").toString();//颜色code
				    	}
				    	
				    	String cunitname=measdoc.getAttributevalue("name").toString();
				    	String cunitcode=measdoc.getAttributevalue("code").toString();
				    	String csendstockorgcode=stockorg.getAttributevalue("code").toString();
				    	String csendstockorgname=stockorg.getAttributevalue("name").toString();
				    	String cordercustcode = cust.getAttributevalue("code").toString();
				    	String cordercustname = cust.getAttributevalue("name").toString();
				    	
				    	
				    	JSonObject bjson = new JSonObject();
				    	bjson.put("vbillcode", deliveryHVO.getAttributevalue("vbillcode").toString());
				    	bjson.put("crowno",  superVO.getAttributevalue("crowno").toString());
				    	bjson.put("materialcode", materialcode);//物料编码
				    	bjson.put("materialspec", materialspec);//规格型号
				    	bjson.put("materialversion", materialversion);//版本
				    	
				    	bjson.put("defdocname", defdocname);//颜色
				    	bjson.put("defdoccode", defdoccode);//颜色code
				    	bjson.put("nastnum", String.valueOf(superVO.getAttributevalue("nastnum").toString()));//数量
				    	bjson.put("castunitcode", cunitcode);//单位编码
				    	bjson.put("castunitname", cunitname);//单位名称
				    	bjson.put("frownote", superVO.getAttributevalue("frownote ") ==null? "":superVO.getAttributevalue("frownote ").toString() );//航备注
				    	bjson.put("csendstockorgcode", csendstockorgname);
				    	//bjson.put("csendstockorgcode", csendstockorgcode);
				    	bjson.put("blargessflag", superVO.getAttributevalue("blargessflag").toString());//曾平
				    	bjson.put("vbdef11", superVO.getAttributevalue("vbdef11").toString());//是否上牌
				    	bjson.put("vbdef12", superVO.getAttributevalue("vbdef12").toString());//是否特价
				    	bjson.put("dsenddate", dsenddate);
				    	bjson.put("vsrccode", superVO.getAttributevalue("vsrccode") == null? "":superVO.getAttributevalue("vsrccode").toString());//来源单据号
				    	bjson.put("vsrcrowno", superVO.getAttributevalue("vsrcrowno") == null? "":superVO.getAttributevalue("vsrcrowno").toString());//来源单据行号 
				    	bjson.put("ntotaloutnum", Integer.parseInt(superVO.getAttributevalue("ntotaloutnum") == null? "0":superVO.getAttributevalue("ntotaloutnum").toString()));//累计出库数量 
				    	bjson.put("cordercustcode", cordercustcode);//客户code
				    	//bjson.put("cordercustcode", cordercustname);//客户code
				    	
				    	bjsonarr.add(bjson);
				    	
					}
				    
				    hjson.put("body", bjsonarr);
				    MessageDialog.showOkCancelDlg(null, "MES接口入参JSON", hjson.toString()); 
					
				    
				  //开始调用MES接口
				    String url="http://192.168.1.205/jpmes/api/so/ship/SoShipService";
				    Service service=new Service();
				    Call call = null;
					
					try {
						call = (Call)service.createCall();
					} catch (ServiceException e2) {
						// TODO Auto-generated catch block
						e2.printStackTrace();
					}
				
					try {
						call.setTargetEndpointAddress(new java.net.URL(url));
					} catch (MalformedURLException e2) {
						// TODO Auto-generated catch block
						e2.printStackTrace();
					}
					
				    call.setOperationName(new QName("http://service.interfaces.mes.pos.com/", "insertOrUpdate"));
				    
				    call.addParameter("arg0", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
				    call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
				    String result=null;
				    
					try {
						result=(String)call.invoke(new Object[]{hjson.toString()});
					} catch (RemoteException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
					
				    MessageDialog.showOkCancelDlg(null, "MES接口结果返回", result);
				    StringBuffer sbupdate = new StringBuffer();
				    String sql = "";
				    sql = " update tmp_bt set id =id+1;";
					sbupdate.append(sql);
					DAOAction_Client.execUpdate(sql, "jpncdb1");
					
				}else{
					//MessageDialog.showOkCancelDlg(null, "提示", "没有发货单!");
				}
			    
			} catch (UifException e1) {
				e1.printStackTrace();
			}
		    
		}
	}

  protected boolean isResume(IResumeException resumeInfo)
  {
    boolean isCCResume = false;
    

    isCCResume = processCreditCheck(resumeInfo);
    

    boolean isCOPMCResume = false;
    isCOPMCResume = processCreditOverPeriodMoneyCheck(resumeInfo);
    

    boolean isCOPDCResume = false;
    isCOPDCResume = processCreditOverPeriodDayCheck(resumeInfo);
    

    boolean isCOPIDCResume = false;
    isCOPIDCResume = processCreditOverPeriodInnerDayCheck(resumeInfo);
    
    return (isCCResume) && (isCOPMCResume) && (isCOPDCResume) && (isCOPIDCResume);
  }
  



  private boolean processCreditOverPeriodMoneyCheck(IResumeException resumeInfo)
  {
    boolean isResume = true;
    if (BusinessCheck.CreditOverPeriodMoneyCheck.getCheckCode().equals(resumeInfo.getBusiExceptionType()))
    {
      IAccountCheckMessageService service = (IAccountCheckMessageService)NCUILocator.getInstance().lookup(IAccountCheckMessageService.class, NCModule.CREDIT);
      
      try
      {
        isResume = service.showMessage(WorkbenchEnvironment.getInstance().getWorkbench().getParent(), ((OverPeriodMoneyCheckException)resumeInfo).getHintMessage());

      }
      catch (BusinessException e)
      {

        ExceptionUtils.wrappException(e);
      }
      

      PfUserObject userObj = getFlowContext().getUserObj();
      if (userObj == null) {
        userObj = new PfUserObject();
      }
      userObj.getBusinessCheckMap().put(BusinessCheck.CreditOverPeriodMoneyCheck.getCheckCode(), Boolean.valueOf(!isResume));
      
      getFlowContext().setUserObj(userObj);
    }
    return isResume;
  }
  







  private boolean processCreditOverPeriodInnerDayCheck(IResumeException resumeInfo)
  {
    boolean isResume = true;
    if (BusinessCheck.CreditOverPeriodInnerDayCheck.getCheckCode().equals(resumeInfo.getBusiExceptionType()))
    {
      IAccountCheckMessageService service = (IAccountCheckMessageService)NCUILocator.getInstance().lookup(IAccountCheckMessageService.class, NCModule.CREDIT);
      
      try
      {
        isResume = service.showMessage(WorkbenchEnvironment.getInstance().getWorkbench().getParent(), ((OverPeriodInnerDayCheckException)resumeInfo).getHintMessage());


      }
      catch (BusinessException e)
      {

        ExceptionUtils.wrappException(e);
      }
      

      PfUserObject userObj = getFlowContext().getUserObj();
      if (userObj == null) {
        userObj = new PfUserObject();
      }
      userObj.getBusinessCheckMap().put(BusinessCheck.CreditOverPeriodInnerDayCheck.getCheckCode(), Boolean.valueOf(!isResume));
      

      getFlowContext().setUserObj(userObj);
    }
    return isResume;
  }
  






  private boolean processCreditOverPeriodDayCheck(IResumeException resumeInfo)
  {
    boolean isResume = true;
    if (BusinessCheck.CreditOverPeriodDayCheck.getCheckCode().equals(resumeInfo.getBusiExceptionType()))
    {
      IAccountCheckMessageService service = (IAccountCheckMessageService)NCUILocator.getInstance().lookup(IAccountCheckMessageService.class, NCModule.CREDIT);
      
      try
      {
        isResume = service.showMessage(WorkbenchEnvironment.getInstance().getWorkbench().getParent(), ((OverPeriodDayCheckException)resumeInfo).getHintMessage());

      }
      catch (BusinessException e)
      {

        ExceptionUtils.wrappException(e);
      }
      

      PfUserObject userObj = getFlowContext().getUserObj();
      if (userObj == null) {
        userObj = new PfUserObject();
      }
      userObj.getBusinessCheckMap().put(BusinessCheck.CreditOverPeriodDayCheck.getCheckCode(), Boolean.valueOf(!isResume));
      
      getFlowContext().setUserObj(userObj);
    }
    return isResume;
  }
  
  private boolean processCreditCheck(IResumeException resumeInfo) {
    boolean isResume = true;
    
    if (BusinessCheck.CreditCheck.getCheckCode().equals(resumeInfo.getBusiExceptionType()))
    {
      ICreditCheckMessageService service = (ICreditCheckMessageService)NCUILocator.getInstance().lookup(ICreditCheckMessageService.class, NCModule.CREDIT);
      
      try
      {
        isResume = service.showMessage(WorkbenchEnvironment.getInstance().getWorkbench().getParent(), (nc.vo.credit.exception.CreditCheckException)resumeInfo);

      }
      catch (BusinessException e)
      {
        ExceptionUtils.wrappException(e);
      }
      
      PfUserObject userObj = getFlowContext().getUserObj();
      if (userObj == null) {
        userObj = new PfUserObject();
      }
      userObj.getBusinessCheckMap().put(BusinessCheck.CreditCheck.getCheckCode(), Boolean.valueOf(!isResume));
      
      getFlowContext().setUserObj(userObj);
    }
    return isResume;
  }
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/297737.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号