我感觉有必要分享一下,历时2周搁置的功能
应该有很多小伙伴都在找的问题 祝你们好运
关键代码
集团id一定要填 , 两周的时间就是栽在这id上
try {BaseDAO bd = new BaseDAO();nc.vo.so.m4331.entity.DeliveryHVO deliveryHVO=new nc.vo.so.m4331.entity.DeliveryHVO();//fstatusflag //1=自由,2=审批通过,3=冻结,4=关闭,7=审批中,8=审批不通过,5=失效,//获取销售发货单(4331) 进行审批 产生 销售出库单 (4C)deliveryHVO = (nc.vo.so.m4331.entity.DeliveryHVO) bd.executeQuery("select * from jpncdb1.so_delivery where dr=0 and vbillcode ='"+vsourcebillcode2+"'", new BeanProcessor(nc.vo.so.m4331.entity.DeliveryHVO.class));if (deliveryHVO != null){String so_delivery_pk=deliveryHVO.getAttributeValue("cdeliveryid").toString();//主键SuperVO[] deliveryBVO = HYPubBO_Client.queryByCondition(DeliveryBVO.class, " cdeliveryid = '"+so_delivery_pk+"'");// 30 4331 4C//String flag2 = PfUtilTools.approveSilently("4331",so_delivery_pk, "Y", "批准","hcj",null);IplatFormEntry iIplatFormEntry = (IplatFormEntry) NCLocator.getInstance().lookup(IplatFormEntry.class.getName());//这是集团ID 一般每个表都有 随便找 pk_group 字段InvocationInfoProxy.getInstance().setGroupId("00013910000000000N4S"); //这个字段很重要AggregatedValueObject deliveryVO= new nc.vo.so.m4331.entity.DeliveryVO();deliveryVO.setParentVO(deliveryHVO);deliveryVO.setChildrenVO(deliveryBVO);HashMap map = new HashMap();map.put("notechecked", "notechecked");// 审批动作 ,审批单据类型 , null ,billvo,null, 环境 ,Object processAction = iIplatFormEntry.processAction("APPROVE", "4331", null, deliveryVO,null, map);}} catch (Exception e1) {e1.printStackTrace();}
package nc.impl.jpncinterface;import java.awt.event.ActionEvent;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Pattern;import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.framework.common.NCLocator;
import nc.bs.ic.general.businessevent.ICGeneralCommonEvent;
import nc.bs.pub.pf.PfUtilTools;
import nc.impl.pubapp.pattern.data.bill.BillQuery;
import nc.itf.uap.pf.IPFBusiAction;
import nc.itf.uap.pf.IplatFormEntry;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.jdbc.framework.processor.BeanProcessor;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.md.persist.framework.IMDPersistenceQueryService;
import nc.ui.so.m30.billui.action.SaleOrderMESApproveAction;
import nc.ui.so.m4331.billui.action.DeliveryApproveAction;
import nc.ui.trade.business.HYPubBO_Client;
import nc.vo.ic.m4c.entity.SaleOutBodyVO;
import nc.vo.ic.m4c.entity.SaleOutHeadVO;
import nc.vo.pu.m21.entity.OrderItemVO;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.SuperVO;
import nc.vo.pub.pf.workflow.IPFActionName;
import nc.vo.rmex.rmupload.deliverybill.DeliveryBillHVO;
import nc.vo.so.m4331.entity.DeliveryBVO;
import nc.vo.so.m4331.entity.DeliveryVO;import org.apache.commons.lang3.StringUtils;import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;public class GetIcSaleout {//库存销售出库单public String getExecute(String operation,String orderform){String resultstr=null; if (operation.equals("Insert")){//插入if(isJsonObject(orderform)){//验证入参resultstr = insert(operation, orderform);}else{JSONObject backinfojson=new JSONObject();backinfojson.put("$successful", "N");backinfojson.put("sendresult", "JSON格式错误");resultstr=backinfojson.toString();}}else if (operation.equals("Update")){//修改resultstr=update(operation, orderform);}else if (operation.equals("Delete")){//删除resultstr=delete(operation, orderform);}else if (operation.equals("Search")){//查询resultstr = search(operation, orderform);}else {JSONObject backinfojson=new JSONObject();backinfojson.put("$successful", "N");backinfojson.put("sendresult", "未开放!");resultstr=backinfojson.toString();}return resultstr;}/*** 插入* @param operation* @param orderform* @return*/public String insert(String operation,String orderform){JSONObject orderjson = JSON.parseObject(orderform);StringBuffer xml_sb=new StringBuffer();//String vbillcode = orderjson.getString("vbillcode");//单String vsourcebillcode2 = orderjson.getString("vsourcebillcode");//销售发货单号/** -- 订单类型select * from jpncdb1.bd_billtype where billtypename like '%整车销售%' and parentbilltype = '4C'-- 销售发货单 单据号审批 产生销售出库单* *///String flag1 = PfUtilTools.approveSilently("交易类型编码或单据类型",主表主键, "是否通过", 审批批语, "",用户组, "动作");try {BaseDAO bd = new BaseDAO();nc.vo.so.m4331.entity.DeliveryHVO deliveryHVO=new nc.vo.so.m4331.entity.DeliveryHVO();//nc.vo.so.m4331.entity.DeliveryBVO deliveryBVO[]=null;//List<DeliveryBVO> deliveryBVO=new ArrayList<DeliveryBVO>();//fstatusflag //1=自由,2=审批通过,3=冻结,4=关闭,7=审批中,8=审批不通过,5=失效,//获取销售发货单(4331) 进行审批 产生 销售出库单 (4C)deliveryHVO = (nc.vo.so.m4331.entity.DeliveryHVO) bd.executeQuery("select * from jpncdb1.so_delivery where dr=0 and vbillcode ='"+vsourcebillcode2+"'", new BeanProcessor(nc.vo.so.m4331.entity.DeliveryHVO.class));if (deliveryHVO != null){String so_delivery_pk=deliveryHVO.getAttributeValue("cdeliveryid").toString();//主键//deliveryBVO[0] = (nc.vo.so.m4331.entity.DeliveryBVO) bd.executeQuery("select * from jpncdb1.so_delivery_b where dr=0 and cdeliveryid ='"+so_delivery_pk+"'", new BeanProcessor(nc.vo.so.m4331.entity.DeliveryBVO.class));SuperVO[] deliveryBVO = HYPubBO_Client.queryByCondition(DeliveryBVO.class, " cdeliveryid = '"+so_delivery_pk+"'");//deliveryBVO=(List<DeliveryBVO>) bd.executeQuery("select * from jpncdb1.so_delivery_b where dr=0 and cdeliveryid ='"+so_delivery_pk+"'", new BeanListProcessor(DeliveryBVO.class));String[] users = {"hcj"};// 30 4331 4C//String flag2 = PfUtilTools.approveSilently("4331",so_delivery_pk, "Y", "批准","hcj",null);//String flag2 = PfUtilTools.approveSilently("4C-Cxx-001",so_delivery_pk, "Y", "", "APPROVE",null);//String flag2 = PfUtilTools.approveSilently("4331",so_delivery_pk,null, null, "APPROVE",null);//System.out.println(flag2);//IplatFormEntry iIplatFormEntry = NCLocator.getInstance().lookup(IplatFormEntry.class);IplatFormEntry iIplatFormEntry = (IplatFormEntry) NCLocator.getInstance().lookup(IplatFormEntry.class.getName());InvocationInfoProxy.getInstance().setGroupId("00013910000000000N4S");AggregatedValueObject deliveryVO= new nc.vo.so.m4331.entity.DeliveryVO();//deliveryVO//nc.vo.so.m4331.entity.DeliveryVOdeliveryVO.setParentVO(deliveryHVO);deliveryVO.setChildrenVO(deliveryBVO);HashMap map = new HashMap();map.put("notechecked", "notechecked");Object processAction = iIplatFormEntry.processAction("APPROVE", "4331", null, deliveryVO,null, map);System.out.println(processAction);//流程平台动作处理 服务接口//destBill是aggvo/*BillQuery<DeliveryBillHVO> billquery = new BillQuery(DeliveryBillHVO.class);DeliveryBillHVO[] aggvo=billquery.query(new String[] {so_delivery_pk});*//*IMDPersistenceQueryService service=NCLocator.getInstance().lookup(IMDPersistenceQueryService.class);QueryCondition queryCondition=new QueryCondition(src_class);queryCondition.addCondition(Restrictions.and(Restrictions.eq("vbillcode", billcode), Restrictions.eq("dr", 0)));service.queryBillOfVOByCond(queryCondition, false);*///DeliveryBillHVO[] obj= (DeliveryBillHVO[]) ifbaction.processAction("WRITE", "4331", null, aggvo, null, null);//Object retObj = new PfUtilBO().processAction("APPROVE", "4331", "2005-05-30 12:23:44", null, billVo, userObj );}} catch (Exception e1) {e1.printStackTrace();}String resultstr2 = ""; JSONObject backinfojson2=new JSONObject();backinfojson2.put("$successful", "Y");backinfojson2.put("sendresult", "");resultstr2=backinfojson2.toString();boolean flag = true;if(flag){return resultstr2;}String pk_org = orderjson.getString("pk_orgcode"); //库存组织 10202 pk_orgcodeString vtrantypecode = orderjson.getString("ctrantypecode"); //出入库类型编码 4C-Cxx-001 ctrantypecodeString cwarehouseid = orderjson.getString("cwarehousecode"); //仓库 X06 cwarehousecodeString cwhsmanagerid = orderjson.getString("cwhsmanagercode"); //库管员 08708 cwhsmanagercodeString cbizid = orderjson.getString("cbizcode"); //业务员 0110 cbizcodeString cdptvid = orderjson.getString("cdptcode"); //部门 "" cdptcodeString ccustomerid = orderjson.getString("ccustomercode"); //订单客户 070204 ccustomercode//String ntotalnum = orderjson.getString("ntotalnum"); //总数量会自动计算String cfanaceorgoid = orderjson.getString("cfanaceorgcode"); //结算财务组织 100 cfanaceorgcodeString cbiztype = orderjson.getString("cbiztype"); //业务流程 Cxx-001String dbilldate = orderjson.getString("dbilldate"); //单据日期 2021-09-07 08:33:49String trafficorgoid = orderjson.getString("trafficorgoid"); //物流组织 101String freplenishflag = orderjson.getString("freplenishflag");// 销售退货 NString boutretflag = orderjson.getString("boutretflag"); //销售退回 NString fbillflag = orderjson.getString("fbillflag"); //单据状态 2String vnote = orderjson.getString("vnote"); //备注String vdef2 = orderjson.getString("vdef2"); //表头自定义项2 02String creator = orderjson.getString("creator"); //创建人 hcjString billmaker = orderjson.getString("billmaker"); //制单人 hcjString csaleorgoid = orderjson.getString("csaleorgoid"); //销售组织 101String creceivfinorgoid = orderjson.getString("creceivfinorgoid"); //应收财务组织 100String ctrantypeid = orderjson.getString("ctrantypeid"); //出入库类型 4C-Cxx-001String creationtime = getDateStr(new Date(),"yyyy-MM-dd HH:mm:ss"); //制单日期//子表JSONArray body = (JSONArray) orderjson.get("body");StringBuffer body_sb=new StringBuffer();for (int i = 0;i<body.size();i++){JSONObject tmpb = body.getJSONObject(i);String crowno = tmpb.getString("crowno"); // 行号10 crownoString cmaterialoid = tmpb.getString("cmaterialoid"); //物料编码 91812160String cunitid = tmpb.getString("cunitid"); // 主单位 012String vfree1 = tmpb.getString("vfree1"); //自由辅助属性1 10014910000000002J0Q 颜色 0002 String nshouldnum = tmpb.getString("nshouldnum"); //应发主数量 5 String nnum = tmpb.getString("nnum"); //实发主数量 5 String price = tmpb.getString("price");// 单价 1000//String money = tmpb.getString("money"); //金额 5000 String dbizdate = tmpb.getString("dbizdate");//出库日期 2021-10-09 10:12:22String cinvoicecustid = tmpb.getString("cinvoicecustid"); //开票客户 350135 String csourcebillhid = tmpb.getString("csourcebillhid"); //来源单据表头主键 1001AZ10000001C3AK7JString csourcebillbid = tmpb.getString("csourcebillbid"); //来源单据表体主键 1001AZ10000001C3AK7KString csourcetype = tmpb.getString("csourcetype"); //来源单据类型 4331String csourcetranstype = tmpb.getString("csourcetranstype"); //来源交易类型 4331-Cxx-001String vsourcebillcode = tmpb.getString("vsourcebillcode"); //来源单据号 GFH210900002String vsourcerowno = tmpb.getString("vsourcerowno"); //来源单据行号 10String casscustid = tmpb.getString("casscustid"); //客户 350135String cfirsttype = tmpb.getString("cfirsttype"); //源头单据类型 30String cfirsttranstype = tmpb.getString("cfirsttranstype"); //源头交易类型 30String cfirstbillhid = tmpb.getString("cfirstbillhid"); //源头单据号pk //1001AZ10000001C3AK6UString cfirstbillbid = tmpb.getString("cfirstbillbid"); //源头单据行号pk //1001AZ10000001C3AK6ZString vfirstbillcode = tmpb.getString("vfirstbillcode"); //源头单据号 GXD210900006String vfirstrowno = tmpb.getString("vfirstrowno"); //源头单据行号 10String vnotebody = tmpb.getString("vnotebody"); //行备注 String flargess = tmpb.getString("flargess"); //赠品 NString bsourcelargess = tmpb.getString("bsourcelargess"); //上游赠品行 N String bonroadflag = tmpb.getString("bonroadflag"); //在途 NString cbodytranstypecode = tmpb.getString("cbodytranstypecode"); //出入库类型 4C-Cxx-001String cbodywarehouseid = tmpb.getString("cbodywarehouseid"); //库存仓库 X06//String pk_org = tmpb.getString("pk_org"); //库存组织 10202String ddeliverdate = tmpb.getString("ddeliverdate"); //要求收货日期 2021-09-07 08:33:49String norignetprice = tmpb.getString("norignetprice"); //主无税净价 1000String norigtaxnetprice = tmpb.getString("norigtaxnetprice"); // 主含税净价 1000String csourcebilldate = tmpb.getString("csourcebilldate"); //来源单据日期 2021-09-07 08:33:49String cfirstbilldate = tmpb.getString("cfirstbilldate"); //源头单据日期 2021-09-07 08:33:49//总价//金额= 数量*单价BigDecimal bd_num = new BigDecimal(nnum);//数量BigDecimal bd_price = new BigDecimal(price).setScale(3, RoundingMode.HALF_UP);//单价BigDecimal bd_total = bd_num.multiply(bd_price);//总价BaseDAO bd_color = new BaseDAO();String pk_defdoc = "";try {//颜色代码查询pk_defdoc = (String) bd_color.executeQuery("SELECT pk_defdoc FROM bd_defdoc WHERE pk_defdoclist = '10014910000000002GJJ' and code = '"+vfree1+"'", new ColumnProcessor());} catch (DAOException e) {e.printStackTrace();}StringBuffer body_sb2 = new StringBuffer();JSONArray body2 = (JSONArray) tmpb.get("body");for (int j = 0;j<body2.size();j++){JSONObject tmpb2= body2.getJSONObject(j);//String nnum_2 = tmpb2.getString("nnum");String nnum_2 = nnum; //主数量 2 body_sb2.append(SetIcSaleoutXml.setPoOrderBody2(nnum_2));}body_sb.append(SetIcSaleoutXml.setPoOrderBody(body_sb2.toString(), crowno, cmaterialoid, cunitid, vfree1, nshouldnum, nnum, price, bd_total.toString(), dbizdate, cinvoicecustid, csourcebillhid, csourcebillbid, csourcetype, csourcetranstype, vsourcebillcode, vsourcerowno, casscustid, cfirsttype, cfirsttranstype, cfirstbillhid,cfirstbillbid, vfirstbillcode, vfirstrowno, vnotebody, flargess, bsourcelargess, bonroadflag, cbodytranstypecode, cbodywarehouseid, pk_org, ddeliverdate, norignetprice, norigtaxnetprice, csourcebilldate, cfirstbilldate));}xml_sb = SetIcSaleoutXml.setPoOrderHead(body_sb.toString(), "", "", cbiztype, dbilldate, vtrantypecode, pk_org, cwarehouseid, trafficorgoid,cwhsmanagerid, cbizid, ccustomerid, freplenishflag, boutretflag, fbillflag, vnote, vdef2, creator, billmaker, creationtime, cdptvid, csaleorgoid, cfanaceorgoid, creceivfinorgoid, ctrantypeid);//GetXChangeService gtxchangeservice=new GetXChangeService();Object ovbillcode = "";JSONObject backinfojson=gtxchangeservice.getXChangeservice(xml_sb.toString());if(backinfojson.getString("$successful").equals("Y")){String pk=backinfojson.getJSONObject("sendresult").getString("content");BaseDAO bd = new BaseDAO();try {//获取插入的订单单号 ovbillcode = bd.executeQuery("select vbillcode from ic_saleout_h where cgeneralhid ='"+pk+"'", new ColumnProcessor());backinfojson.put("$vbillcode", ovbillcode);} catch (Exception e) {e.printStackTrace();}}else if(backinfojson.getString("$successful").equals("N")) {backinfojson.put("$vbillcode",ovbillcode);}return backinfojson.toJSONString();}/*** 修改* @param operation* @param orderform* @return*/public String update(String operation,String orderform){JSONObject orderjson = JSON.parseObject(orderform);String vbillcode = orderjson.getString("vbillcode");//单据号 String pk = "";JSONObject backinfojson=new JSONObject();if (StringUtils.isBlank(vbillcode)){backinfojson.put("sendresult", "vbillcode为空!");backinfojson.put("$successful", "N");}else{BaseDAO bd = new BaseDAO();SaleOutHeadVO saleOutHeadVO=new SaleOutHeadVO();try {saleOutHeadVO = (SaleOutHeadVO) bd.executeQuery("select * from ic_saleout_h where dr=0 and fbillflag <> 1 and vbillcode ='"+vbillcode+"'", new BeanProcessor(SaleOutHeadVO.class));} catch (Exception e1) {e1.printStackTrace();}if (saleOutHeadVO != null){pk=saleOutHeadVO.getAttributeValue("cgeneralhid").toString();if(StringUtils.isBlank(pk)){backinfojson.put("sendresult", "查询不到单据!");backinfojson.put("$successful", "N");}else{StringBuffer xml_sb=new StringBuffer();//String vbillcode = orderjson.getString("vbillcode");//单String pk_org = orderjson.getString("pk_orgcode"); //库存组织 10202 pk_orgcodeString vtrantypecode = orderjson.getString("ctrantypecode"); //出入库类型编码 4C-Cxx-001 ctrantypecodeString cwarehouseid = orderjson.getString("cwarehousecode"); //仓库 X06 cwarehousecodeString cwhsmanagerid = orderjson.getString("cwhsmanagercode"); //库管员 08708 cwhsmanagercodeString cbizid = orderjson.getString("cbizcode"); //业务员 0110 cbizcodeString cdptvid = orderjson.getString("cdptcode"); //部门 "" cdptcodeString ccustomerid = orderjson.getString("ccustomercode"); //订单客户 070204 ccustomercode//String ntotalnum = orderjson.getString("ntotalnum"); //总数量会自动计算String cfanaceorgoid = orderjson.getString("cfanaceorgcode"); //结算财务组织 100 cfanaceorgcodeString cbiztype = orderjson.getString("cbiztype"); //业务流程 Cxx-001String dbilldate = orderjson.getString("dbilldate"); //单据日期 2021-09-07 08:33:49String trafficorgoid = orderjson.getString("trafficorgoid"); //物流组织 101String freplenishflag = orderjson.getString("freplenishflag");// 销售退货 NString boutretflag = orderjson.getString("boutretflag"); //销售退回 NString fbillflag = orderjson.getString("fbillflag"); //单据状态 2String vnote = orderjson.getString("vnote"); //备注String vdef2 = orderjson.getString("vdef2"); //表头自定义项2 02String creator = orderjson.getString("creator"); //创建人 hcjString billmaker = orderjson.getString("billmaker"); //制单人 hcjString csaleorgoid = orderjson.getString("csaleorgoid"); //销售组织 101String creceivfinorgoid = orderjson.getString("creceivfinorgoid"); //应收财务组织 100String ctrantypeid = orderjson.getString("ctrantypeid"); //出入库类型 4C-Cxx-001String creationtime = getDateStr(new Date(),"yyyy-MM-dd HH:mm:ss"); //制单日期//子表JSONArray body = (JSONArray) orderjson.get("body");StringBuffer body_sb=new StringBuffer();for (int i = 0;i<body.size();i++){JSONObject tmpb = body.getJSONObject(i);String crowno = tmpb.getString("crowno"); // 行号10 crownoString cmaterialoid = tmpb.getString("cmaterialoid"); //物料编码 91812160String cunitid = tmpb.getString("cunitid"); // 主单位 012String vfree1 = tmpb.getString("vfree1"); //自由辅助属性1 10014910000000002J0Q 颜色 0002 String nshouldnum = tmpb.getString("nshouldnum"); //应发主数量 5 String nnum = tmpb.getString("nnum"); //实发主数量 5 String price = tmpb.getString("price");// 单价 1000//String money = tmpb.getString("money"); //金额 5000 String dbizdate = tmpb.getString("dbizdate");//出库日期 2021-10-09 10:12:22String cinvoicecustid = tmpb.getString("cinvoicecustid"); //开票客户 350135 String csourcebillhid = tmpb.getString("csourcebillhid"); //来源单据表头主键 1001AZ10000001C3AK7JString csourcebillbid = tmpb.getString("csourcebillbid"); //来源单据表体主键 1001AZ10000001C3AK7KString csourcetype = tmpb.getString("csourcetype"); //来源单据类型 4331String csourcetranstype = tmpb.getString("csourcetranstype"); //来源交易类型 4331-Cxx-001String vsourcebillcode = tmpb.getString("vsourcebillcode"); //来源单据号 GFH210900002String vsourcerowno = tmpb.getString("vsourcerowno"); //来源单据行号 10String casscustid = tmpb.getString("casscustid"); //客户 350135String cfirsttype = tmpb.getString("cfirsttype"); //源头单据类型 30String cfirsttranstype = tmpb.getString("cfirsttranstype"); //源头交易类型 30String cfirstbillhid = tmpb.getString("cfirstbillhid"); //源头单据号pk //1001AZ10000001C3AK6UString cfirstbillbid = tmpb.getString("cfirstbillbid"); //源头单据行号pk //1001AZ10000001C3AK6ZString vfirstbillcode = tmpb.getString("vfirstbillcode"); //源头单据号 GXD210900006String vfirstrowno = tmpb.getString("vfirstrowno"); //源头单据行号 10String vnotebody = tmpb.getString("vnotebody"); //行备注 String flargess = tmpb.getString("flargess"); //赠品 NString bsourcelargess = tmpb.getString("bsourcelargess"); //上游赠品行 N String bonroadflag = tmpb.getString("bonroadflag"); //在途 NString cbodytranstypecode = tmpb.getString("cbodytranstypecode"); //出入库类型 4C-Cxx-001String cbodywarehouseid = tmpb.getString("cbodywarehouseid"); //库存仓库 X06//String pk_org = tmpb.getString("pk_org"); //库存组织 10202String ddeliverdate = tmpb.getString("ddeliverdate"); //要求收货日期 2021-09-07 08:33:49String norignetprice = tmpb.getString("norignetprice"); //主无税净价 1000String norigtaxnetprice = tmpb.getString("norigtaxnetprice"); // 主含税净价 1000String csourcebilldate = tmpb.getString("csourcebilldate"); //来源单据日期 2021-09-07 08:33:49String cfirstbilldate = tmpb.getString("cfirstbilldate"); //源头单据日期 2021-09-07 08:33:49//总价//金额= 数量*单价BigDecimal bd_num = new BigDecimal(nnum);//数量BigDecimal bd_price = new BigDecimal(price).setScale(3, RoundingMode.HALF_UP);//单价BigDecimal bd_total = bd_num.multiply(bd_price);//总价BaseDAO bd_color = new BaseDAO();String pk_defdoc = "";try {//颜色代码查询pk_defdoc = (String) bd_color.executeQuery("SELECT pk_defdoc FROM bd_defdoc WHERE pk_defdoclist = '10014910000000002GJJ' and code = '"+vfree1+"'", new ColumnProcessor());} catch (DAOException e) {e.printStackTrace();}StringBuffer body_sb2 = new StringBuffer();JSONArray body2 = (JSONArray) tmpb.get("body");for (int j = 0;j<body2.size();j++){JSONObject tmpb2= body2.getJSONObject(j);//String nnum_2 = tmpb2.getString("nnum");String nnum_2 = nnum; //主数量 2 body_sb2.append(SetIcSaleoutXml.setPoOrderBody2(nnum_2));}body_sb.append(SetIcSaleoutXml.setPoOrderBody(body_sb2.toString(), crowno, cmaterialoid, cunitid, vfree1, nshouldnum, nnum, price, bd_total.toString(), dbizdate, cinvoicecustid, csourcebillhid, csourcebillbid, csourcetype, csourcetranstype, vsourcebillcode, vsourcerowno, casscustid, cfirsttype, cfirsttranstype, cfirstbillhid,cfirstbillbid, vfirstbillcode, vfirstrowno, vnotebody, flargess, bsourcelargess, bonroadflag, cbodytranstypecode, cbodywarehouseid, pk_org, ddeliverdate, norignetprice, norigtaxnetprice, csourcebilldate, cfirstbilldate));}xml_sb = SetIcSaleoutXml.setPoOrderHead(body_sb.toString(), pk,vbillcode , cbiztype, dbilldate, vtrantypecode, pk_org, cwarehouseid, trafficorgoid,cwhsmanagerid, cbizid, ccustomerid, freplenishflag, boutretflag, fbillflag, vnote, vdef2, creator, billmaker, creationtime, cdptvid, csaleorgoid, cfanaceorgoid, creceivfinorgoid, ctrantypeid);//GetXChangeService gtxchangeservice=new GetXChangeService();backinfojson=gtxchangeservice.getXChangeservice(xml_sb.toString());backinfojson.put("$vbillcode", vbillcode);if(backinfojson.getString("$successful").equals("Y")){String oldpk=backinfojson.getJSONObject("sendresult").getString("bdocid");try {bd.deleteByClause(SaleOutHeadVO.class, "cgeneralhid='"+oldpk+"'");bd.deleteByClause(SaleOutBodyVO.class, "cgeneralhid='"+oldpk+"'");} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}String newpk=backinfojson.getJSONObject("sendresult").getString("content");try {String sql="update ic_saleout_h set vbillcode='"+vbillcode+"' where cgeneralhid='"+newpk+"'";bd.executeUpdate(sql);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}}}else{backinfojson.put("sendresult", "查询不到单据!");backinfojson.put("$successful", "N");}}return backinfojson.toJSONString();}/*** 删除* @param operation* @param orderform* @return*/public String delete(String operation,String orderform){JSONObject orderjson=JSON.parseObject(orderform);String vbillcode=orderjson.getString("vbillcode");String pk=null;JSONObject backinfojson=new JSONObject();BaseDAO bd = new BaseDAO();if (vbillcode == null || "".equals(vbillcode)){backinfojson.put("sendresult", "vbillcode为空!");backinfojson.put("$successful", "N");}else{SaleOutHeadVO saleOutHeadVO = new SaleOutHeadVO();try {String sql="select * from ic_saleout_h where vbillcode = '"+vbillcode+"' and dr=0 and fbillflag <> 1 ";saleOutHeadVO = (SaleOutHeadVO) bd.executeQuery(sql, new BeanProcessor(SaleOutHeadVO.class));} catch (Exception e1) {e1.printStackTrace();}if (saleOutHeadVO != null){pk=saleOutHeadVO.getAttributeValue("cgeneralhid").toString();if(pk == null || "".equals(pk)){backinfojson.put("sendresult", "查询不到单据!");backinfojson.put("$successful", "N");}else{//单据状态if(saleOutHeadVO.getAttributeValue("fbillflag").toString().equals("2") || saleOutHeadVO.getAttributeValue("fbillflag").toString().equals("6")){//orderHeaderVO.setAttributeValue("dr", "1");saleOutHeadVO.setFbillflag(1);try {bd.updateVO(saleOutHeadVO);} catch (Exception e) {e.printStackTrace();}List<SaleOutBodyVO> orderItemVOList=new ArrayList<SaleOutBodyVO>();try {String sql="select * from ic_generalout_b where cgeneralhid = '"+pk+"' and dr=0 and fbillflag <> 1 ";orderItemVOList=(List<SaleOutBodyVO>) bd.executeQuery(sql, new BeanListProcessor(SaleOutBodyVO.class));} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}for (int i=0;i<orderItemVOList.size();i++){orderItemVOList.get(i).setAttributeValue("dr", "1");}try {bd.updateVOList(orderItemVOList);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}backinfojson.put("$successful", "Y");backinfojson.put("sendresult", "单据删除成功!");}else{backinfojson.put("$successful", "N");backinfojson.put("sendresult", "单据状态不允许删除!");}}}}return backinfojson.toString();}/*** 查询* @param operation* @param orderform* @return*/public String search(String operation,String orderform){JSONObject backinfojson=new JSONObject();backinfojson.put("$successful", "N");backinfojson.put("sendresult", "未开放!");return backinfojson.toString();}/*** 判断字符串是否为JsonObject {@link org.json.JSONObject}* @param jsonStr {@link java.lang.String}* @return boolean*/public static boolean isJsonObject(final String jsonStr) {if (StringUtils.isBlank(jsonStr)) return false;return Pattern.matches("^\\{.*\\}$", jsonStr.trim());}/*** 日期转换为字符串* @param date 日期* @param format 日期格式* @return 字符串*/public static String getDateStr(Date date,String format) {if (null == date) {return null;}SimpleDateFormat sdf = new SimpleDateFormat(format);return sdf.format(date);}}