|
|
@@ -1,904 +0,0 @@
|
|
|
-/**
|
|
|
- *
|
|
|
- */
|
|
|
-package beans.uploaderpdata;
|
|
|
-
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
-import org.apache.log4j.Logger;
|
|
|
-import org.dom4j.Document;
|
|
|
-import org.dom4j.DocumentHelper;
|
|
|
-
|
|
|
-import beans.brand.Brand;
|
|
|
-import beans.uploaderpdata.erpservice.ChangeSalesOrderDataEsoRequestChangeSalesOrderDataEsoRequest;
|
|
|
-import beans.uploaderpdata.erpservice.ChangeSalesOrderDataEsoResponseChangeSalesOrderDataEsoResponse;
|
|
|
-import beans.uploaderpdata.erpservice.CreateMiscIssueDataESORequestCreateMiscIssueDataESORequest;
|
|
|
-import beans.uploaderpdata.erpservice.CreateMiscIssueDataESOResponseCreateMiscIssueDataESOResponse;
|
|
|
-import beans.uploaderpdata.erpservice.CreateSalesOrderDataESORequestCreateSalesOrderDataESORequest;
|
|
|
-import beans.uploaderpdata.erpservice.CreateSalesOrderDataESOResponseCreateSalesOrderDataESOResponse;
|
|
|
-import beans.uploaderpdata.erpservice.CreateSalesReturnEsoRequestCreateSalesReturnEsoRequest;
|
|
|
-import beans.uploaderpdata.erpservice.CreateSalesReturnEsoResponseCreateSalesReturnEsoResponse;
|
|
|
-import beans.uploaderpdata.erpservice.CreateShippingNoticeESORequestCreateShippingNoticeESORequest;
|
|
|
-import beans.uploaderpdata.erpservice.CreateShippingNoticeESOResponseCreateShippingNoticeESOResponse;
|
|
|
-import beans.uploaderpdata.erpservice.TIPTOPServiceGateWay;
|
|
|
-import beans.uploaderpdata.erpservice.TIPTOPServiceGateWayPortType;
|
|
|
-import common.BaseClass;
|
|
|
-import common.Controller;
|
|
|
-import common.YosException;
|
|
|
-import common.data.Row;
|
|
|
-import common.data.Rows;
|
|
|
-import common.data.RowsMap;
|
|
|
-import common.data.SQLFactory;
|
|
|
-
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author Administrator
|
|
|
- *
|
|
|
- */
|
|
|
-public class UploadDataToERP_TZ extends BaseClass {
|
|
|
- private static final String SITEID = "IDCZJ10";
|
|
|
- private static Logger logger = Logger.getLogger(UploadDataToERP_TZ.class);
|
|
|
-
|
|
|
- /**
|
|
|
- * 订单上传erp服务
|
|
|
- */
|
|
|
- public static boolean uploadSaorder_post(Controller controller, long uniqueIDValue) throws YosException {
|
|
|
- boolean issucess = false;
|
|
|
- Rows saorderRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t2.projectname,t3.address,t3.phonenumber,t3.name,t3.province,t3.city,t3.county,t4.`name` salername,t4.hrcode,t5.agentnum,t6.erpagentnum,t8.erpagentnum payentcode,t9.erpagentnum recentcode from sa_order t1 left join sa_project t2 on t1.sa_projectid=t2.sa_projectid and t1.siteid=t2.siteid left join sys_enterprise_contacts t3 on t1.rec_contactsid=t3.contactsid and t1.siteid=t3.siteid left join sys_hr t4 on t1.saler_hrid=t4.hrid and t1.siteid=t4.siteid left join sa_agents t5 on t1.sys_enterpriseid=t5.sys_enterpriseid and t1.siteid=t5.siteid left join sys_dataextend t6 on t6.ownertable='sys_enterprise' and t6.ownerid=t5.sys_enterpriseid and t6.siteid=t5.siteid left join sys_enterprise t7 on t7.sys_enterpriseid=t1.pay_enterpriseid and t7.siteid=t1.siteid left join sys_dataextend t8 on t8.ownertable='sys_enterprise' and t8.ownerid=t7.sys_enterpriseid and t8.siteid=t7.siteid left join sys_dataextend t9 on t9.ownertable='sys_enterprise' and t9.ownerid=t3.sys_enterpriseid and t9.siteid=t3.siteid where t1.checkdate is not null and t1.sa_orderid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "'");
|
|
|
- Rows saorderdetailRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t3.erpitemno,t2.standards from sa_orderitems t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid left join plm_itemextend t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where t1.sa_orderid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "' order by t1.rowno");
|
|
|
-
|
|
|
- ArrayList<Long> ids = saorderdetailRows.toArrayList("itemid", new ArrayList<>());
|
|
|
- // 商品领域
|
|
|
- RowsMap tradefieldRowsMap = beans.Item.Item.getTradefieldRowsMap(controller, ids);
|
|
|
- // 品牌
|
|
|
- RowsMap brandRowsMap = Brand.getBrandRowsMap(controller, ids);
|
|
|
- if (saorderRows.isEmpty()) {
|
|
|
- return issucess;
|
|
|
- }
|
|
|
-
|
|
|
- String fsonum = saorderRows.get(0).getString("sonum");
|
|
|
- String fsaler = saorderRows.get(0).getString("salername");
|
|
|
- String hrcode = saorderRows.get(0).getString("hrcode");
|
|
|
- String checkdate = getDate_Str1(saorderRows.get(0).getDate("checkdate"));
|
|
|
- String fagentnum = saorderRows.get(0).getString("agentnum");
|
|
|
- String fcontact = saorderRows.get(0).getString("name");
|
|
|
- String fphonenumber = saorderRows.get(0).getString("phonenumber");
|
|
|
- String faddress = saorderRows.get(0).getString("address");
|
|
|
- String fnotes = saorderRows.get(0).getString("remarks");
|
|
|
- String ftype = saorderRows.get(0).getString("type");
|
|
|
- String fsaletype = saorderRows.get(0).getString("saletype");
|
|
|
- String fprojectname = saorderRows.get(0).getString("projectnote");
|
|
|
- String freviewtype = saorderRows.get(0).getString("reviewtype");
|
|
|
- String fpayagentnum = saorderRows.get(0).getString("payentcode");
|
|
|
- String frecagentnum = saorderRows.get(0).getString("recentcode");
|
|
|
- if ("项目订单".equals(ftype)) {
|
|
|
- fprojectname = saorderRows.get(0).getString("projectname");
|
|
|
- }
|
|
|
-
|
|
|
- String ferptype = "ZSO1";
|
|
|
-// switch (ftype) {
|
|
|
-// case "标准订单": {
|
|
|
-// ftype = "PSO1";
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// default:
|
|
|
-// break;
|
|
|
-// }
|
|
|
-
|
|
|
- if (!StringUtils.isBlank(saorderRows.get(0).getString("erpagentnum"))) {
|
|
|
- fagentnum = saorderRows.get(0).getString("erpagentnum");
|
|
|
- }
|
|
|
-
|
|
|
- StringBuffer xmlbuffer = new StringBuffer();
|
|
|
- xmlbuffer.append("<Request>");
|
|
|
- xmlbuffer.append("<Access>");
|
|
|
- xmlbuffer.append("<Authentication user=\"tiptop\" password=\"\"/>");
|
|
|
- xmlbuffer.append("<Connection application=\"ESO\" source=\"192.168.10.115\"/>");
|
|
|
- xmlbuffer.append("<Organization name=\"" + SITEID + "\"/>");
|
|
|
- xmlbuffer.append("<Locale language=\"zh_cn\"/>");
|
|
|
- xmlbuffer.append("</Access>");
|
|
|
- xmlbuffer.append("<RequestContent>");
|
|
|
- xmlbuffer.append("<Document>");
|
|
|
- xmlbuffer.append("<RecordSet id=\"1\">");
|
|
|
- xmlbuffer.append("<Master name=\"oea_file\">");
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"oea00\" value=\"\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"oea01\" value=\"" + ferptype + "\"/>");// 单别
|
|
|
- xmlbuffer.append("<Field name=\"oea02\" value=\"" + checkdate + "\"/>");// 单据日期
|
|
|
- xmlbuffer.append("<Field name=\"oea03\" value=\"" + fpayagentnum + "\"/>");// 付款客户编号
|
|
|
- xmlbuffer.append("<Field name=\"oea04\" value=\"" + frecagentnum + "\"/>");// 收货客户编号
|
|
|
- xmlbuffer.append("<Field name=\"oea10\" value=\"" + fsonum + "\"/>");// 订单编号
|
|
|
- xmlbuffer.append("<Field name=\"oea14\" value=\"" + hrcode.toLowerCase() + "\"/>");// 业务员
|
|
|
- xmlbuffer.append("<Field name=\"oap041\" value=\"" + fcontact + ";" + fphonenumber + ";" + faddress + "\"/>");// 地址
|
|
|
- xmlbuffer.append("<Field name=\"oap042\" value=\"" + saorderRows.get(0).getString("province") + "->"
|
|
|
- + saorderRows.get(0).getString("city") + "->" + saorderRows.get(0).getString("county") + "\"/>");// 省市县
|
|
|
- xmlbuffer.append("<Field name=\"oap044\" value=\"" + fprojectname + "\"/>");// 项目
|
|
|
- xmlbuffer.append("<Field name=\"oeaud01\" value=\"" + fnotes + "\"/>");// 备注
|
|
|
- xmlbuffer.append("<Field name=\"oea25\" value=\"" + fsaletype + "\"/>");// 销售分类
|
|
|
- xmlbuffer.append("<Field name=\"oeaud10\" value=\"" + freviewtype + "\"/>");// 订单评审类型
|
|
|
-
|
|
|
- xmlbuffer.append("<Detail name=\"oeb_file\" node_id=\"1_1\">");
|
|
|
- if (!saorderdetailRows.isEmpty()) {
|
|
|
- for (Row row : saorderdetailRows) {
|
|
|
- String ferpitemno = row.getString("erpitemno");
|
|
|
- String fitemno = row.getString("itemno");
|
|
|
- double fqty = row.getDouble("qty");
|
|
|
- String fplandate = getDate_Str1(row.getDate("deliverydate"));
|
|
|
- String fdetailnotes = row.getString("remarks");
|
|
|
- double frateprice = row.getDouble("price");
|
|
|
- double frateamount = row.getDouble("amount");
|
|
|
- long frownum = row.getLong("rowno");
|
|
|
- String fproductstandard = row.getString("standards");
|
|
|
- String fieldname = "";
|
|
|
- String fbrand = "";
|
|
|
- if (!tradefieldRowsMap.get(row.getString("itemid")).isEmpty()) {
|
|
|
- fieldname = tradefieldRowsMap.get(row.getString("itemid")).get(0).getString("tradefield");
|
|
|
- }
|
|
|
- if (!brandRowsMap.get(row.getString("itemid")).isEmpty()) {
|
|
|
- fbrand = brandRowsMap.get(row.getString("itemid")).get(0).getString("brandname");
|
|
|
- }
|
|
|
-
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"oeb04\" value=\"" + ferpitemno + "\"/>");// 料号(ERP商品编号)
|
|
|
- xmlbuffer.append("<Field name=\"oeb11\" value=\"" + fitemno + "\"/>");// 客户产品编码(DRP商品编号)
|
|
|
- xmlbuffer.append("<Field name=\"oeb12\" value=\"" + fqty + "\"/>");// 数量
|
|
|
- xmlbuffer.append("<Field name=\"oeb15\" value=\"" + fplandate + "\"/>");// 交货日期
|
|
|
- xmlbuffer.append("<Field name=\"oeb13\" value=\"" + frateprice + "\"/>");// 单价
|
|
|
- xmlbuffer.append("<Field name=\"oeb14t\" value=\"" + frateamount + "\"/>");// 金额
|
|
|
- xmlbuffer.append("<Field name=\"oebud04\" value=\"" + fsonum + "\"/>");// 订单号
|
|
|
- xmlbuffer.append("<Field name=\"oebud05\" value=\"" + frownum + "\"/>");// 行号
|
|
|
- xmlbuffer.append("<Field name=\"oeb30\" value=\"\"/>");// 预计归还日期
|
|
|
- xmlbuffer.append("<Field name=\"oao06\" value=\"" + fieldname + "->" + fproductstandard + "->" + fbrand
|
|
|
- + "->" + fdetailnotes + "\"/>");
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- }
|
|
|
- }
|
|
|
- xmlbuffer.append("</Detail>");
|
|
|
-
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- xmlbuffer.append("</Master>");
|
|
|
- xmlbuffer.append("</RecordSet>");
|
|
|
- xmlbuffer.append("</Document>");
|
|
|
- xmlbuffer.append("</RequestContent>");
|
|
|
- xmlbuffer.append("</Request>");
|
|
|
- logger.info("订单上传请求" + fsonum + ":" + xmlbuffer.toString());
|
|
|
- try {
|
|
|
-
|
|
|
- TIPTOPServiceGateWay gateWay = new TIPTOPServiceGateWay();
|
|
|
- TIPTOPServiceGateWayPortType portType = gateWay.getTIPTOPServiceGateWayPortType();
|
|
|
-
|
|
|
- CreateSalesOrderDataESORequestCreateSalesOrderDataESORequest esoRequest = new CreateSalesOrderDataESORequestCreateSalesOrderDataESORequest();
|
|
|
- esoRequest.setRequest(xmlbuffer.toString());
|
|
|
- CreateSalesOrderDataESOResponseCreateSalesOrderDataESOResponse esoResponse = portType
|
|
|
- .createSalesOrderDataESO(esoRequest);
|
|
|
- String result = esoResponse.getResponse();
|
|
|
- logger.info("订单上传返回" + fsonum + ":" + result);
|
|
|
-
|
|
|
- Document document = DocumentHelper.parseText(result);
|
|
|
- issucess = saveLog(controller, "sa_order", uniqueIDValue, "订单上传", xmlbuffer.toString(), document);
|
|
|
- issucess = saveDataextend(controller, "sa_order", uniqueIDValue, document);
|
|
|
- } catch (Exception e) {
|
|
|
- logger.info("订单上传错误" + fsonum + ":" + e.getMessage());
|
|
|
-
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return issucess;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 订单变更上传erp服务
|
|
|
- */
|
|
|
- public static boolean uploadSaorderChange_post(Controller controller, long uniqueIDValue) throws YosException {
|
|
|
- boolean issucess = false;
|
|
|
- Rows orderitemsChangeRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t2.sonum,t7.hrcode from sa_orderitems_change t1 left join sa_order t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid left join sys_hr t7 on t7.siteid=t1.siteid and t1.createuserid=t7.userid where t1.sa_orderitems_changeid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "'");
|
|
|
- Rows orderitemsChangemxRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t.*,t3.erpitemno,t1.rowno from sa_orderitems_changemx t left join sa_orderitems t1 on t.sa_orderitemsid=t1.sa_orderitemsid and t.siteid=t1.siteid left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid left join plm_itemextend t3 on t.itemid=t3.itemid and t.siteid=t3.siteid where t.sa_orderitems_changeid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "' order by t1.rowno");
|
|
|
-
|
|
|
- if (orderitemsChangeRows.isEmpty()) {
|
|
|
- return issucess;
|
|
|
- }
|
|
|
-
|
|
|
- Rows erpupdatelogRows = controller.dbConnect
|
|
|
- .runSqlQuery("select * from sys_dataextend where ownertable='sa_order' and ownerid="
|
|
|
- + orderitemsChangeRows.get(0).getLong("sa_orderid") + " order by changedate desc");
|
|
|
- if (erpupdatelogRows.isEmpty()) {
|
|
|
- return issucess;
|
|
|
- }
|
|
|
- String fsonum = orderitemsChangeRows.get(0).getString("sonum");
|
|
|
- String changeby = orderitemsChangeRows.get(0).getString("hrcode").toLowerCase();
|
|
|
- String fdate = getDate_Str1(orderitemsChangeRows.get(0).getDate("createdate"));
|
|
|
- boolean isjiean = orderitemsChangeRows.get(0).getString("remarks").equals("订单结案变更");
|
|
|
- String ferpbillno = erpupdatelogRows.get(0).getString("erpbillno");
|
|
|
-
|
|
|
- StringBuffer xmlbuffer = new StringBuffer();
|
|
|
- xmlbuffer.append("<Request>");
|
|
|
- xmlbuffer.append("<Access>");
|
|
|
- xmlbuffer.append("<Authentication user=\"tiptop\" password=\"\"/>");
|
|
|
- xmlbuffer.append("<Connection application=\"ESO\" source=\"192.168.10.115\"/>");
|
|
|
- xmlbuffer.append("<Organization name=\"" + SITEID + "\"/>");
|
|
|
- xmlbuffer.append("<Locale language=\"zh_cn\"/>");
|
|
|
- xmlbuffer.append("</Access>");
|
|
|
- xmlbuffer.append("<RequestContent>");
|
|
|
- xmlbuffer.append("<Document>");
|
|
|
- xmlbuffer.append("<RecordSet id=\"1\">");
|
|
|
- xmlbuffer.append("<Master name=\"oep_file\">");
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"oep01\" value=\"" + ferpbillno + "\"/>");// 订单编号
|
|
|
- xmlbuffer.append("<Field name=\"oep04\" value=\"" + fdate + "\"/>");// 单据日期
|
|
|
- xmlbuffer.append("<Field name=\"oep12\" value=\"" + changeby + "\"/>");// 变更人员
|
|
|
- xmlbuffer.append("<Field name=\"oep13\" value=\"" + "37" + "\"/>");// 理由码代码
|
|
|
-
|
|
|
- xmlbuffer.append("<Detail name=\"oeq_file\" node_id=\"1_1\">");
|
|
|
-
|
|
|
- for (Row row : orderitemsChangemxRows) {
|
|
|
- int frownum = row.getInteger("rowno");
|
|
|
- BigDecimal fqty = row.getBigDecimal("newvalue");
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"oeq03\" value=\"" + frownum + "\"/>");// 行号
|
|
|
- xmlbuffer.append("<Field name=\"oeq12a\" value=\"" + fqty + "\"/>");// 变更后数量
|
|
|
- xmlbuffer.append("<Field name=\"oeq13a\" value=\"" + "" + "\"/>");// 变更后单价
|
|
|
- xmlbuffer.append("<Field name=\"oeq15a\" value=\"" + "" + "\"/>");// 变更后交货日期
|
|
|
- xmlbuffer.append("<Field name=\"oeq50\" value=\"" + "" + "\"/>");// 备注
|
|
|
- xmlbuffer.append("<Field name=\"oequd06\" value=\"" + (isjiean ? "Y" : "N") + "\"/>");// 是否结案
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- }
|
|
|
- xmlbuffer.append("</Detail>");
|
|
|
-
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- xmlbuffer.append("</Master>");
|
|
|
- xmlbuffer.append("</RecordSet>");
|
|
|
- xmlbuffer.append("</Document>");
|
|
|
- xmlbuffer.append("</RequestContent>");
|
|
|
- xmlbuffer.append("</Request>");
|
|
|
- logger.info("订单变更上传请求" + fsonum + ":" + xmlbuffer.toString());
|
|
|
- try {
|
|
|
- TIPTOPServiceGateWay gateWay = new TIPTOPServiceGateWay();
|
|
|
- TIPTOPServiceGateWayPortType portType = gateWay.getTIPTOPServiceGateWayPortType();
|
|
|
-
|
|
|
- ChangeSalesOrderDataEsoRequestChangeSalesOrderDataEsoRequest esoRequest = new ChangeSalesOrderDataEsoRequestChangeSalesOrderDataEsoRequest();
|
|
|
- esoRequest.setRequest(xmlbuffer.toString());
|
|
|
- ChangeSalesOrderDataEsoResponseChangeSalesOrderDataEsoResponse esoResponse = portType
|
|
|
- .changeSalesOrderDataEso(esoRequest);
|
|
|
- String result = esoResponse.getResponse();
|
|
|
- logger.info("订单变更上传返回" + fsonum + result);
|
|
|
-
|
|
|
- Document document = DocumentHelper.parseText(result);
|
|
|
- issucess = saveLog(controller, "sa_orderitems_change", uniqueIDValue, "订单变更", xmlbuffer.toString(),
|
|
|
- document);
|
|
|
- issucess = saveDataextend(controller, "sa_orderitems_change", uniqueIDValue, document);
|
|
|
- } catch (Exception e) {
|
|
|
- logger.info("订单上传错误" + fsonum + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return issucess;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 杂发单上传erp服务
|
|
|
- */
|
|
|
- public static boolean uploadSaorder_ZF_post(Controller controller, long uniqueIDValue) throws YosException {
|
|
|
- boolean issucess = false;
|
|
|
- Rows saorderRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t2.projectname,t3.address,t3.phonenumber,t3.name,t3.province,t3.city,t3.county,t4.`name` salername,t5.agentnum,t6.erpagentnum,t7.hrcode from sa_order t1 left join sa_project t2 on t1.sa_projectid=t2.sa_projectid and t1.siteid=t2.siteid left join sys_enterprise_contacts t3 on t1.rec_contactsid=t3.contactsid and t1.siteid=t3.siteid left join sys_hr t4 on t1.saler_hrid=t4.hrid and t1.siteid=t4.siteid left join sa_agents t5 on t1.sys_enterpriseid=t5.sys_enterpriseid and t1.siteid=t5.siteid left join sys_dataextend t6 on t6.ownertable='sys_enterprise' and t6.ownerid=t5.sys_enterpriseid and t6.siteid=t5.siteid left join sys_hr t7 on t7.siteid=t1.siteid and t1.changeuserid=t7.userid where t1.checkdate is not null and t1.sa_orderid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "'");
|
|
|
- Rows saorderdetailRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t3.erpitemno,t4.stockno from sa_orderitems t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid left join plm_itemextend t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid left join st_stock t4 on t1.stockid=t4.stockid and t1.siteid=t4.siteid where t1.sa_orderid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "' order by t1.rowno");
|
|
|
-
|
|
|
- if (saorderRows.isEmpty()) {
|
|
|
- return issucess;
|
|
|
- }
|
|
|
-
|
|
|
- String fsonum = saorderRows.get(0).getString("sonum");
|
|
|
- String checkdate = getDate_Str1(saorderRows.get(0).getDate("checkdate"));
|
|
|
- String fnotes = saorderRows.get(0).getString("remarks");
|
|
|
- String freviewtype = saorderRows.get(0).getString("reviewtype");
|
|
|
- StringBuffer xmlbuffer = new StringBuffer();
|
|
|
- xmlbuffer.append("<Request>");
|
|
|
- xmlbuffer.append("<Access>");
|
|
|
- xmlbuffer.append("<Authentication user=\"tiptop\" password=\"\"/>");
|
|
|
- xmlbuffer.append("<Connection application=\"ESO\" source=\"192.168.10.115\"/>");
|
|
|
- xmlbuffer.append("<Organization name=\"" + SITEID + "\"/>");
|
|
|
- xmlbuffer.append("<Locale language=\"zh_cn\"/>");
|
|
|
- xmlbuffer.append("</Access>");
|
|
|
- xmlbuffer.append("<RequestContent>");
|
|
|
- xmlbuffer.append("<Document>");
|
|
|
- xmlbuffer.append("<RecordSet id=\"1\">");
|
|
|
- xmlbuffer.append("<Master name=\"ina_file\">");
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"ina00\" value=\"1\"/>");// 单据类型
|
|
|
- xmlbuffer.append("<Field name=\"ina01\" value=\"ZWI1\"/>");// 单据编号
|
|
|
- xmlbuffer.append("<Field name=\"inaud06\" value=\"" + fsonum + "\"/>");// 单据编号
|
|
|
- xmlbuffer.append("<Field name=\"ina03\" value=\"" + checkdate + "\"/>");// 单据日期
|
|
|
- xmlbuffer.append("<Field name=\"ina07\" value=\"" + fnotes + "\"/>");// 备注
|
|
|
- xmlbuffer.append(
|
|
|
- "<Field name=\"ina11\" value=\"" + saorderRows.get(0).getString("hrcode").toLowerCase() + "\"/>");// 申请人
|
|
|
- // xmlbuffer.append("<Field name=\"ina04\" value=\"" + "J61000" + "\"/>");//申请部门
|
|
|
- xmlbuffer.append("<Field name=\"oeaud10\" value=\"" + freviewtype + "\"/>");// 订单评审类型
|
|
|
-
|
|
|
- xmlbuffer.append("<Detail name=\"inb_file\" node_id=\"1_1\">");
|
|
|
-
|
|
|
- if (!saorderdetailRows.isEmpty()) {
|
|
|
- for (Row row : saorderdetailRows) {
|
|
|
- String ferpitemno = row.getString("erpitemno");
|
|
|
- String warehouse = row.getString("stockno");
|
|
|
- String location = row.getString("position");
|
|
|
- String lot = row.getString("batchno");
|
|
|
- double fqty = row.getDouble("qty");
|
|
|
-
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"inb04\" value=\"" + ferpitemno + "\"/>");// 料号(ERP商品编号)
|
|
|
- xmlbuffer.append("<Field name=\"inb05\" value=\"" + warehouse + "\"/>");// 仓库
|
|
|
- xmlbuffer.append("<Field name=\"inb06\" value=\"" + location + "\"/>");// 库位
|
|
|
- xmlbuffer.append("<Field name=\"inb07\" value=\"" + lot + "\"/>");// 批号
|
|
|
- xmlbuffer.append("<Field name=\"inb09\" value=\"" + fqty + "\"/>");// 异动数量
|
|
|
- xmlbuffer.append("<Field name=\"inb15\" value=\"" + "A070" + "\"/>");// 理由码
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- }
|
|
|
- }
|
|
|
- xmlbuffer.append("</Detail>");
|
|
|
-
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- xmlbuffer.append("</Master>");
|
|
|
- xmlbuffer.append("</RecordSet>");
|
|
|
- xmlbuffer.append("</Document>");
|
|
|
- xmlbuffer.append("</RequestContent>");
|
|
|
- xmlbuffer.append("</Request>");
|
|
|
- logger.info("杂发单上传请求" + fsonum + xmlbuffer.toString());
|
|
|
- try {
|
|
|
- TIPTOPServiceGateWay gateWay = new TIPTOPServiceGateWay();
|
|
|
- TIPTOPServiceGateWayPortType portType = gateWay.getTIPTOPServiceGateWayPortType();
|
|
|
-
|
|
|
- CreateMiscIssueDataESORequestCreateMiscIssueDataESORequest esoRequest = new CreateMiscIssueDataESORequestCreateMiscIssueDataESORequest();
|
|
|
- esoRequest.setRequest(xmlbuffer.toString());
|
|
|
- CreateMiscIssueDataESOResponseCreateMiscIssueDataESOResponse esoResponse = portType
|
|
|
- .createMiscIssueDataESO(esoRequest);
|
|
|
- String result = esoResponse.getResponse();
|
|
|
- logger.info("杂发单上传请求" + fsonum + result);
|
|
|
-
|
|
|
- Document document = DocumentHelper.parseText(result);
|
|
|
- issucess = saveLog(controller, "sa_order", uniqueIDValue, "样品订单", xmlbuffer.toString(), document);
|
|
|
- issucess = saveDataextend(controller, "sa_order", uniqueIDValue, document);
|
|
|
- } catch (Exception e) {
|
|
|
- logger.info("订单上传错误" + fsonum + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return issucess;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 借出单上传erp服务
|
|
|
- */
|
|
|
- public static boolean uploadBorrow_post(Controller controller, long uniqueIDValue) throws YosException {
|
|
|
- boolean issucess = false;
|
|
|
-
|
|
|
- Rows saorderRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t2.projectname,t3.address,t3.phonenumber,t3.name,t3.province,t3.city,t3.county,t4.`name` salername,t4.hrcode,t5.agentnum,t6.erpagentnum,t8.erpagentnum payentcode,t9.erpagentnum recentcode from sa_order t1 left join sa_project t2 on t1.sa_projectid=t2.sa_projectid and t1.siteid=t2.siteid left join sys_enterprise_contacts t3 on t1.rec_contactsid=t3.contactsid and t1.siteid=t3.siteid left join sys_hr t4 on t1.saler_hrid=t4.hrid and t1.siteid=t4.siteid left join sa_agents t5 on t1.sys_enterpriseid=t5.sys_enterpriseid and t1.siteid=t5.siteid left join sys_dataextend t6 on t6.ownertable='sys_enterprise' and t6.ownerid=t5.sys_enterpriseid and t6.siteid=t5.siteid left join sys_enterprise t7 on t7.sys_enterpriseid=t1.pay_enterpriseid and t7.siteid=t1.siteid left join sys_dataextend t8 on t8.ownertable='sys_enterprise' and t8.ownerid=t7.sys_enterpriseid and t8.siteid=t7.siteid left join sys_dataextend t9 on t9.ownertable='sys_enterprise' and t9.ownerid=t3.sys_enterpriseid and t9.siteid=t3.siteid where t1.checkdate is not null and t1.sa_orderid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "'");
|
|
|
- Rows saorderdetailRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t3.erpitemno from sa_orderitems t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid left join plm_itemextend t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where t1.sa_orderid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "' order by t1.rowno");
|
|
|
-
|
|
|
- if (saorderRows.isEmpty()) {
|
|
|
- return issucess;
|
|
|
- }
|
|
|
- Row saorder = saorderRows.get(0);
|
|
|
-
|
|
|
- String fsonum = saorder.getString("sonum");
|
|
|
- String fsaler = saorder.getString("salername");
|
|
|
- String hrcode = saorder.getString("hrcode");
|
|
|
- String checkdate = getDate_Str1(saorder.getDate("checkdate"));
|
|
|
- String fagentnum = saorder.getString("agentnum");
|
|
|
- String fcontact = saorder.getString("name");
|
|
|
- String fphonenumber = saorder.getString("phonenumber");
|
|
|
- String faddress = saorder.getString("faddress");
|
|
|
- String fnotes = saorder.getString("remarks");
|
|
|
- String fprojectname = "";
|
|
|
- String freviewtype = saorderRows.get(0).getString("reviewtype");
|
|
|
- String fpayagentnum = saorderRows.get(0).getString("payentcode");
|
|
|
- String frecagentnum = saorderRows.get(0).getString("recentcode");
|
|
|
- String ftype = saorder.getString("type");
|
|
|
- // String ferptype = "ZSO1";
|
|
|
- String ferptype = "ZSF1";
|
|
|
-
|
|
|
- if (!StringUtils.isBlank(saorderRows.get(0).getString("erpagentnum"))) {
|
|
|
- fagentnum = saorderRows.get(0).getString("erpagentnum");
|
|
|
- }
|
|
|
- StringBuffer xmlbuffer = new StringBuffer();
|
|
|
- xmlbuffer.append("<Request>");
|
|
|
- xmlbuffer.append("<Access>");
|
|
|
- xmlbuffer.append("<Authentication user=\"tiptop\" password=\"\"/>");
|
|
|
- xmlbuffer.append("<Connection application=\"ESO\" source=\"192.168.10.115\"/>");
|
|
|
- xmlbuffer.append("<Organization name=\"" + SITEID + "\"/>");
|
|
|
- xmlbuffer.append("<Locale language=\"zh_cn\"/>");
|
|
|
- xmlbuffer.append("</Access>");
|
|
|
- xmlbuffer.append("<RequestContent>");
|
|
|
- xmlbuffer.append("<Document>");
|
|
|
- xmlbuffer.append("<RecordSet id=\"1\">");
|
|
|
- xmlbuffer.append("<Master name=\"oea_file\">");
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"oea00\" value=\"" + 8 + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"oea01\" value=\"" + ferptype + "\"/>");// 单别
|
|
|
- xmlbuffer.append("<Field name=\"oea02\" value=\"" + checkdate + "\"/>");// 单据日期
|
|
|
- xmlbuffer.append("<Field name=\"oea03\" value=\"" + fpayagentnum + "\"/>");// 付款客户编号
|
|
|
- xmlbuffer.append("<Field name=\"oea04\" value=\"" + frecagentnum + "\"/>");// 收货客户编号
|
|
|
- xmlbuffer.append("<Field name=\"oea10\" value=\"" + fsonum + "\"/>");// 借出单号
|
|
|
- xmlbuffer.append("<Field name=\"oea14\" value=\"" + hrcode.toLowerCase() + "\"/>");// 业务员
|
|
|
- xmlbuffer.append("<Field name=\"oap041\" value=\"" + fcontact + ";" + fphonenumber + ";" + faddress + "\"/>");// 地址
|
|
|
- xmlbuffer.append("<Field name=\"oap042\" value=\"" + saorder.getString("province") + "->"
|
|
|
- + saorder.getString("city") + "->" + saorder.getString("county") + "\"/>");// 省市县
|
|
|
- xmlbuffer.append("<Field name=\"oap044\" value=\"" + fprojectname + "\"/>");// 项目
|
|
|
- xmlbuffer.append("<Field name=\"oeaud01\" value=\"" + fnotes + "\"/>");// 备注
|
|
|
- xmlbuffer.append("<Field name=\"oeaud10\" value=\"" + freviewtype + "\"/>");// 订单评审类型
|
|
|
-
|
|
|
- xmlbuffer.append("<Detail name=\"oeb_file\" node_id=\"1_1\">");
|
|
|
-
|
|
|
- if (!saorderdetailRows.isEmpty()) {
|
|
|
- for (Row row : saorderdetailRows) {
|
|
|
- String ferpitemno = row.getString("erpitemno");
|
|
|
- String fitemno = row.getString("itemno");
|
|
|
- double fqty = row.getDouble("qty");
|
|
|
- String fplandate = getDate_Str1(row.getDate("deliverydate"));
|
|
|
- String fdetailnotes = row.getString("remarks");
|
|
|
- double frateprice = row.getDouble("price");
|
|
|
- double frateamount = row.getDouble("amount");
|
|
|
- long frownum = row.getLong("rowno");
|
|
|
-
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"oeb04\" value=\"" + ferpitemno + "\"/>");// 料号(ERP商品编号)
|
|
|
- xmlbuffer.append("<Field name=\"oeb11\" value=\"" + fitemno + "\"/>");// 客户产品编码(DRP商品编号)
|
|
|
- xmlbuffer.append("<Field name=\"oeb12\" value=\"" + fqty + "\"/>");// 数量
|
|
|
- xmlbuffer.append("<Field name=\"oeb15\" value=\"" + fplandate + "\"/>");// 交货日期
|
|
|
- xmlbuffer.append("<Field name=\"oeb13\" value=\"" + frateprice + "\"/>");// 单价
|
|
|
- xmlbuffer.append("<Field name=\"oeb14t\" value=\"" + frateamount + "\"/>");// 金额
|
|
|
- xmlbuffer.append("<Field name=\"oebud04\" value=\"" + fsonum + "\"/>");// 借出单号
|
|
|
- xmlbuffer.append("<Field name=\"oebud05\" value=\"" + frownum + "\"/>");// 行号
|
|
|
- String fbackdate = getDate_Str1(row.getDate("toolbackdate"));
|
|
|
- xmlbuffer.append("<Field name=\"oeb30\" value=\"" + fbackdate + "\"/>");// 预计归还日期
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- xmlbuffer.append("</Detail>");
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- xmlbuffer.append("</Master>");
|
|
|
- xmlbuffer.append("</RecordSet>");
|
|
|
- xmlbuffer.append("</Document>");
|
|
|
- xmlbuffer.append("</RequestContent>");
|
|
|
- xmlbuffer.append("</Request>");
|
|
|
- logger.info("借出单上传请求" + fsonum + xmlbuffer.toString());
|
|
|
- try {
|
|
|
- TIPTOPServiceGateWay gateWay = new TIPTOPServiceGateWay();
|
|
|
- TIPTOPServiceGateWayPortType portType = gateWay.getTIPTOPServiceGateWayPortType();
|
|
|
-
|
|
|
- CreateSalesOrderDataESORequestCreateSalesOrderDataESORequest esoRequest = new CreateSalesOrderDataESORequestCreateSalesOrderDataESORequest();
|
|
|
- esoRequest.setRequest(xmlbuffer.toString());
|
|
|
- CreateSalesOrderDataESOResponseCreateSalesOrderDataESOResponse esoResponse = portType
|
|
|
- .createSalesOrderDataESO(esoRequest);
|
|
|
- String result = esoResponse.getResponse();
|
|
|
- logger.info("借出单上传请求" + fsonum + result);
|
|
|
-
|
|
|
- Document document = DocumentHelper.parseText(result);
|
|
|
- issucess = saveLog(controller, "sa_order", uniqueIDValue, "工具借用", xmlbuffer.toString(), document);
|
|
|
- issucess = saveDataextend(controller, "sa_order", uniqueIDValue, document);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- logger.info("借出单上传错误" + fsonum + e.getMessage());
|
|
|
- }
|
|
|
- return issucess;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 借货转销售上传erp服务
|
|
|
- */
|
|
|
- public static boolean uploadBorrowToSale_post(Controller controller, long uniqueIDValue) throws YosException {
|
|
|
- boolean issucess = false;
|
|
|
-
|
|
|
- Rows aftersalesmagRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t2.sonum from sa_aftersalesmag t1 left join sa_order t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid where t1.sa_aftersalesmagid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "'");
|
|
|
- Rows aftersalesmagdetailRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t2.rowno from sa_aftersalesmag_items t1 left join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid where t1.sa_aftersalesmagid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "' order by t2.rowno");
|
|
|
-
|
|
|
- if (aftersalesmagRows.isEmpty()) {
|
|
|
- return issucess;
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isBlank(aftersalesmagRows.get(0).getString("sonum"))) {
|
|
|
- return issucess;
|
|
|
- }
|
|
|
- Row taftersalesmag = aftersalesmagRows.get(0);
|
|
|
-
|
|
|
- Rows erpupdatelogRows = controller.dbConnect
|
|
|
- .runSqlQuery("select * from sys_erpupdatelog where ownertable='sa_order' and ownerid="
|
|
|
- + aftersalesmagRows.get(0).getLong("sa_orderid") + "order by createdate desc");
|
|
|
-
|
|
|
- if (erpupdatelogRows.isEmpty()) {
|
|
|
- return issucess;
|
|
|
- }
|
|
|
- String ferpbillno = erpupdatelogRows.get(0).getString("erpbillno");
|
|
|
- String fbillnum = taftersalesmag.getString("billno");
|
|
|
- String checkdate = getDate_Str1(taftersalesmag.getDate("checkdate"));
|
|
|
-
|
|
|
- StringBuffer xmlbuffer = new StringBuffer();
|
|
|
- xmlbuffer.append("<Request>");
|
|
|
- xmlbuffer.append("<Access>");
|
|
|
- xmlbuffer.append("<Authentication user=\"tiptop\" password=\"\"/>");
|
|
|
- xmlbuffer.append("<Connection application=\"ESO\" source=\"192.168.10.115\"/>");
|
|
|
- xmlbuffer.append("<Organization name=\"" + SITEID + "\"/>");
|
|
|
- xmlbuffer.append("<Locale language=\"zh_cn\"/>");
|
|
|
- xmlbuffer.append("</Access>");
|
|
|
- xmlbuffer.append("<RequestContent>");
|
|
|
- xmlbuffer.append("<Document>");
|
|
|
- xmlbuffer.append("<RecordSet id=\"1\">");
|
|
|
- xmlbuffer.append("<Master name=\"oea_file\">");
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"oea00\" value=\"" + 9 + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"oea01\" value=\"" + "" + "\"/>");// 单别
|
|
|
- xmlbuffer.append("<Field name=\"oea02\" value=\"" + checkdate + "\"/>");// 单据日期
|
|
|
- xmlbuffer.append("<Field name=\"oea10\" value=\"" + fbillnum + "\"/>");// 单号
|
|
|
- xmlbuffer.append("<Field name=\"oea12\" value=\"" + ferpbillno + "\"/>");// 原借出单号
|
|
|
-
|
|
|
- xmlbuffer.append("<Detail name=\"oeb_file\" node_id=\"1_1\">");
|
|
|
-
|
|
|
- if (aftersalesmagdetailRows.isEmpty()) {
|
|
|
- for (Row row : aftersalesmagdetailRows) {
|
|
|
- double fqty = row.getDouble("qty");
|
|
|
- double frateprice = row.getDouble("price");
|
|
|
- double frateamount = row.getDouble("amount");
|
|
|
- int fsorownum = row.getInteger("rowno");
|
|
|
-
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"oeb71\" value=\"" + fsorownum + "\"/>");// 原借出单行号
|
|
|
- xmlbuffer.append("<Field name=\"oeb12\" value=\"" + fqty + "\"/>");// 数量
|
|
|
- xmlbuffer.append("<Field name=\"oeb13\" value=\"" + frateprice + "\"/>");// 单价
|
|
|
- xmlbuffer.append("<Field name=\"oeb14t\" value=\"" + frateamount + "\"/>");// 金额
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- xmlbuffer.append("</Detail>");
|
|
|
-
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- xmlbuffer.append("</Master>");
|
|
|
- xmlbuffer.append("</RecordSet>");
|
|
|
- xmlbuffer.append("</Document>");
|
|
|
- xmlbuffer.append("</RequestContent>");
|
|
|
- xmlbuffer.append("</Request>");
|
|
|
- logger.info("借货转销售上传请求" + fbillnum + xmlbuffer.toString());
|
|
|
- try {
|
|
|
- TIPTOPServiceGateWay gateWay = new TIPTOPServiceGateWay();
|
|
|
- TIPTOPServiceGateWayPortType portType = gateWay.getTIPTOPServiceGateWayPortType();
|
|
|
-
|
|
|
- CreateSalesOrderDataESORequestCreateSalesOrderDataESORequest esoRequest = new CreateSalesOrderDataESORequestCreateSalesOrderDataESORequest();
|
|
|
- esoRequest.setRequest(xmlbuffer.toString());
|
|
|
- CreateSalesOrderDataESOResponseCreateSalesOrderDataESOResponse esoResponse = portType
|
|
|
- .createSalesOrderDataESO(esoRequest);
|
|
|
- String result = esoResponse.getResponse();
|
|
|
- logger.info("借货转销售上传请求" + fbillnum + result);
|
|
|
-
|
|
|
- Document document = DocumentHelper.parseText(result);
|
|
|
- issucess = saveLog(controller, "sa_aftersalesmag", uniqueIDValue, "返退单", xmlbuffer.toString(), document);
|
|
|
- issucess = saveDataextend(controller, "sa_aftersalesmag", uniqueIDValue, document);
|
|
|
- } catch (Exception e) {
|
|
|
- logger.info("借货转销售错误" + fbillnum + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return issucess;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 借货退回上传erp服务
|
|
|
- */
|
|
|
- public static boolean uploadBorrowToReturn_post(Controller controller, long uniqueIDValue) throws YosException {
|
|
|
- boolean issucess = false;
|
|
|
- Rows aftersalesmagRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t2.sonum from sa_aftersalesmag t1 left join sa_order t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid where t1.sa_aftersalesmagid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "'");
|
|
|
- Rows aftersalesmagdetailRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t2.rowno,t2.itemno from sa_aftersalesmag_items t1 left join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid where t1.sa_aftersalesmagid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "' order by t2.rowno");
|
|
|
-
|
|
|
- if (aftersalesmagRows.isEmpty()) {
|
|
|
- return issucess;
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(aftersalesmagRows.get(0).getString("sonum"))) {
|
|
|
- return issucess;
|
|
|
- }
|
|
|
- Row taftersalesmag = aftersalesmagRows.get(0);
|
|
|
-
|
|
|
- Rows erpupdatelogRows = controller.dbConnect
|
|
|
- .runSqlQuery("select * from sys_erpupdatelog where ownertable='sa_order' and ownerid="
|
|
|
- + aftersalesmagRows.get(0).getLong("sa_orderid") + "order by createdate desc");
|
|
|
-
|
|
|
- if (erpupdatelogRows.isEmpty()) {
|
|
|
- return issucess;
|
|
|
- }
|
|
|
- String ferpbillno = erpupdatelogRows.get(0).getString("erpbillno");
|
|
|
- String fbillnum = taftersalesmag.getString("billno");
|
|
|
- String checkdate = getDate_Str1(taftersalesmag.getDate("checkdate"));
|
|
|
-
|
|
|
- StringBuffer xmlbuffer = new StringBuffer();
|
|
|
- xmlbuffer.append("<Request>");
|
|
|
- xmlbuffer.append("<Access>");
|
|
|
- xmlbuffer.append("<Authentication user=\"tiptop\" password=\"\"/>");
|
|
|
- xmlbuffer.append("<Connection application=\"ESO\" source=\"192.168.10.115\"/>");
|
|
|
- xmlbuffer.append("<Organization name=\"" + SITEID + "\"/>");
|
|
|
- xmlbuffer.append("<Locale language=\"zh_cn\"/>");
|
|
|
- xmlbuffer.append("</Access>");
|
|
|
- xmlbuffer.append("<RequestContent>");
|
|
|
- xmlbuffer.append("<Document>");
|
|
|
- xmlbuffer.append("<RecordSet id=\"1\">");
|
|
|
- xmlbuffer.append("<Master name=\"oha_file\">");
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"oha01\" value=\"" + "" + "\"/>");// 单别
|
|
|
- xmlbuffer.append("<Field name=\"oha02\" value=\"" + checkdate + "\"/>");// 单据日期
|
|
|
- xmlbuffer.append("<Field name=\"oha05\" value=\"" + "5" + "\"/>");// 销退类型
|
|
|
- xmlbuffer.append("<Field name=\"oha09\" value=\"" + "6" + "\"/>");// 销退方式
|
|
|
- xmlbuffer.append("<Field name=\"oha16\" value=\"" + ferpbillno + "\"/>");// 借出单号
|
|
|
-
|
|
|
- xmlbuffer.append("<Detail name=\"ohb_file\" node_id=\"1_1\">");
|
|
|
- if (aftersalesmagdetailRows.isEmpty()) {
|
|
|
- for (Row row : aftersalesmagdetailRows) {
|
|
|
- String fitemno = row.getString("itemno");
|
|
|
- double fqty = row.getDouble("qty");
|
|
|
- int fsorownum = row.getInteger("rowno");
|
|
|
-
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"ohb04\" value=\"" + fitemno + "\"/>");// 料号
|
|
|
- xmlbuffer.append("<Field name=\"ohb09\" value=\"" + "W11" + "\"/>");// 仓库
|
|
|
- xmlbuffer.append("<Field name=\"ohb091\" value=\"" + "" + "\"/>");// 库位
|
|
|
- xmlbuffer.append("<Field name=\"ohb092\" value=\"" + "" + "\"/>");// 批号
|
|
|
- xmlbuffer.append("<Field name=\"ohb12\" value=\"" + fqty + "\"/>");// 数量
|
|
|
- xmlbuffer.append("<Field name=\"ohb31\" value=\"" + ferpbillno + "\"/>");// 借出单号
|
|
|
- xmlbuffer.append("<Field name=\"ohb32\" value=\"" + fsorownum + "\"/>");// 借出单号项次
|
|
|
- xmlbuffer.append("<Field name=\"ohb50\" value=\"" + "A210" + "\"/>");// 理由编号号
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- xmlbuffer.append("</Detail>");
|
|
|
-
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- xmlbuffer.append("</Master>");
|
|
|
- xmlbuffer.append("</RecordSet>");
|
|
|
- xmlbuffer.append("</Document>");
|
|
|
- xmlbuffer.append("</RequestContent>");
|
|
|
- xmlbuffer.append("</Request>");
|
|
|
- logger.info("借货退回上传请求" + fbillnum + xmlbuffer.toString());
|
|
|
- try {
|
|
|
- TIPTOPServiceGateWay gateWay = new TIPTOPServiceGateWay();
|
|
|
- TIPTOPServiceGateWayPortType portType = gateWay.getTIPTOPServiceGateWayPortType();
|
|
|
-
|
|
|
- CreateSalesReturnEsoRequestCreateSalesReturnEsoRequest esoRequest = new CreateSalesReturnEsoRequestCreateSalesReturnEsoRequest();
|
|
|
- esoRequest.setRequest(xmlbuffer.toString());
|
|
|
- CreateSalesReturnEsoResponseCreateSalesReturnEsoResponse esoResponse = portType
|
|
|
- .createSalesReturnEso(esoRequest);
|
|
|
- String result = esoResponse.getResponse();
|
|
|
- logger.info("借货退回上传请求" + fbillnum + result);
|
|
|
-
|
|
|
- Document document = DocumentHelper.parseText(result);
|
|
|
- issucess = saveLog(controller, "sa_aftersalesmag", uniqueIDValue, "借货退回", xmlbuffer.toString(), document);
|
|
|
- issucess = saveDataextend(controller, "sa_aftersalesmag", uniqueIDValue, document);
|
|
|
- } catch (Exception e) {
|
|
|
- logger.info("借货退回上传错误" + fbillnum + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return issucess;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 发货单上传erp服务
|
|
|
- */
|
|
|
- public static boolean uploadSainvoice_post(Controller controller, long uniqueIDValue) throws YosException {
|
|
|
- boolean issucess = false;
|
|
|
- Rows dispatchRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t2.sonum,t3.address,t3.province,t3.city,t3.county from sa_dispatch t1 left join sa_order t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid left join sys_enterprise_contacts t3 on t1.rec_contactsid=t3.contactsid and t1.siteid=t3.siteid where t1.sa_dispatchid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "'");
|
|
|
- Rows dispatchdetailRows = controller.dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t3.erpitemno,t2.rowno sorowno,t2.itemname from sa_dispatch_items t1 left join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid left join plm_itemextend t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where t1.sa_dispatchid="
|
|
|
- + uniqueIDValue + " and t1.siteid='" + controller.siteid + "' order by t1.rowno");
|
|
|
- if (dispatchRows.isEmpty()) {
|
|
|
- return issucess;
|
|
|
- }
|
|
|
- Row sainvoice = dispatchRows.get(0);
|
|
|
-
|
|
|
- String fsonum = sainvoice.getString("sonum");
|
|
|
- String finvonum = sainvoice.getString("billno");
|
|
|
- String recheckdate = getDate_Str1(sainvoice.getDate("recheckdate"));
|
|
|
- String fdate = getDate_Str1(sainvoice.getDate("billdate"));
|
|
|
- String faddress = sainvoice.getString("address");
|
|
|
- String fnotes = sainvoice.getString("remarks");
|
|
|
- String ftype = "ZSA1";
|
|
|
-
|
|
|
- StringBuffer xmlbuffer = new StringBuffer();
|
|
|
- xmlbuffer.append("<Request>");
|
|
|
- xmlbuffer.append("<Access>");
|
|
|
- xmlbuffer.append("<Authentication user=\"tiptop\" password=\"\"/>");
|
|
|
- xmlbuffer.append("<Connection application=\"ESO\" source=\"192.168.10.115\"/>");
|
|
|
- xmlbuffer.append("<Organization name=\"" + SITEID + "\"/>");
|
|
|
- xmlbuffer.append("<Locale language=\"zh_cn\"/>");
|
|
|
- xmlbuffer.append("</Access>");
|
|
|
- xmlbuffer.append("<RequestContent>");
|
|
|
- xmlbuffer.append("<Document>");
|
|
|
- xmlbuffer.append("<RecordSet id=\"1\">");
|
|
|
- xmlbuffer.append("<Master name=\"oga_file\">");
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"oga01\" value=\"" + ftype + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"oga02\" value=\"" + recheckdate + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"oga16\" value=\"" + fsonum + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"oap041\" value=\"" + faddress + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"oap042\" value=\"" + sainvoice.getString("province") + "->"
|
|
|
- + sainvoice.getString("city") + "->" + sainvoice.getString("county") + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"ogaud01\" value=\"" + fnotes + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"ogaud02\" value=\"" + finvonum + "\"/>");
|
|
|
-
|
|
|
- xmlbuffer.append("<Detail name=\"ogb_file\" node_id=\"1_1\">");
|
|
|
-
|
|
|
- if (!dispatchdetailRows.isEmpty()) {
|
|
|
- for (Row row : dispatchdetailRows) {
|
|
|
- String ferpitemno = row.getString("erpitemno");
|
|
|
- double fqty = row.getDouble("qty");
|
|
|
- // String fplandate = getDate_Str11(detailpao.getDate("fplandate"));
|
|
|
- int frownum = row.getInteger("rowno");
|
|
|
- int fsorownum = row.getInteger("sorowno");
|
|
|
- String fitemname = row.getString("itemname");
|
|
|
- xmlbuffer.append("<Record>");
|
|
|
- xmlbuffer.append("<Field name=\"ogb03\" value=\"" + frownum + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"ogb04\" value=\"" + ferpitemno + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"ogb12\" value=\"" + fqty + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"ogb31\" value=\"" + fsonum + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"ogb32\" value=\"" + fsorownum + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"ogb1003\" value=\"" + fdate + "\"/>");
|
|
|
- xmlbuffer.append("<Field name=\"ogbud01\" value=\"" + fitemname + "\"/>");
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- xmlbuffer.append("</Detail>");
|
|
|
-
|
|
|
- xmlbuffer.append("</Record>");
|
|
|
- xmlbuffer.append("</Master>");
|
|
|
- xmlbuffer.append("</RecordSet>");
|
|
|
- xmlbuffer.append("</Document>");
|
|
|
- xmlbuffer.append("</RequestContent>");
|
|
|
- xmlbuffer.append("</Request>");
|
|
|
- logger.info("发货单上传" + finvonum + xmlbuffer.toString());
|
|
|
- try {
|
|
|
- TIPTOPServiceGateWay gateWay = new TIPTOPServiceGateWay();
|
|
|
- TIPTOPServiceGateWayPortType portType = gateWay.getTIPTOPServiceGateWayPortType();
|
|
|
-
|
|
|
- CreateShippingNoticeESORequestCreateShippingNoticeESORequest esoRequest = new CreateShippingNoticeESORequestCreateShippingNoticeESORequest();
|
|
|
- esoRequest.setRequest(xmlbuffer.toString());
|
|
|
- CreateShippingNoticeESOResponseCreateShippingNoticeESOResponse esoResponse = portType
|
|
|
- .createShippingNoticeESO(esoRequest);
|
|
|
-
|
|
|
- String result = esoResponse.getResponse();
|
|
|
- logger.info("发货单返回" + finvonum + result);
|
|
|
-
|
|
|
- Document document = DocumentHelper.parseText(result);
|
|
|
- issucess = saveLog(controller, "sa_dispatch", uniqueIDValue, "发货单", xmlbuffer.toString(), document);
|
|
|
- issucess = saveDataextend(controller, "sa_dispatch", uniqueIDValue, document);
|
|
|
- } catch (Exception e) {
|
|
|
- logger.info("发货单上传错误" + finvonum + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return issucess;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 上传日志更新
|
|
|
- *
|
|
|
- * @param controller
|
|
|
- * @param ownertable
|
|
|
- * @param ownerid
|
|
|
- * @param type
|
|
|
- * @param request
|
|
|
- * @param document
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static boolean saveLog(Controller controller, String ownertable, long ownerid, String type, String request,
|
|
|
- Document document) {
|
|
|
- boolean issuccess = false;
|
|
|
- try {
|
|
|
- SQLFactory sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp上传日志新增");
|
|
|
- sqlFactory.addParameter("sys_erpupdatelogid", controller.createTableID("sys_erpupdatelog"));
|
|
|
- sqlFactory.addParameter("siteid", controller.siteid);
|
|
|
- sqlFactory.addParameter("userid", controller.userid);
|
|
|
- sqlFactory.addParameter("username", controller.username);
|
|
|
- sqlFactory.addParameter("ownerid", ownerid);
|
|
|
- sqlFactory.addParameter("ownertable", ownertable);
|
|
|
- sqlFactory.addParameter("type", type);
|
|
|
- sqlFactory.addParameter("request", request);
|
|
|
- sqlFactory.addParameter("response", document.asXML());
|
|
|
- String status = document.getRootElement().element("Execution").element("Status").attribute("code")
|
|
|
- .getText();
|
|
|
- if ("0".equals(status)) {
|
|
|
- String ferpbillno = document.getRootElement().element("ResponseContent").element("Parameter")
|
|
|
- .element("Record").element("Field").attribute("value").getText();
|
|
|
- sqlFactory.addParameter("erpbillno", ferpbillno);
|
|
|
- sqlFactory.addParameter("errmsg", "");
|
|
|
- issuccess = true;
|
|
|
- } else {
|
|
|
- String ferrmsg = document.getRootElement().element("Execution").element("Status")
|
|
|
- .attribute("description").getText();
|
|
|
- sqlFactory.addParameter("erpbillno", 0);
|
|
|
- sqlFactory.addParameter("errmsg", ferrmsg);
|
|
|
- issuccess = false;
|
|
|
- }
|
|
|
- sqlFactory.addParameter("status", status);
|
|
|
- controller.dbConnect.runSqlUpdate(sqlFactory);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return issuccess;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 上传日志更新
|
|
|
- *
|
|
|
- * @param controller
|
|
|
- * @param ownertable
|
|
|
- * @param ownerid
|
|
|
- * @param type
|
|
|
- * @param request
|
|
|
- * @param document
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static boolean saveDataextend(Controller controller, String ownertable, long ownerid, Document document) {
|
|
|
- boolean issuccess = false;
|
|
|
- try {
|
|
|
- Rows rows = controller.dbConnect.runSqlQuery(
|
|
|
- "select * from sys_dataextend where ownertable='" + ownertable + "' and ownerid=" + ownerid);
|
|
|
- SQLFactory sqlFactory;
|
|
|
- if (!rows.isEmpty()) {
|
|
|
- sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp数据扩展信息更新");
|
|
|
- sqlFactory.addParameter("sys_dataextendid", rows.get(0).getLong("sys_dataextendid"));
|
|
|
- } else {
|
|
|
- sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp数据扩展信息新增");
|
|
|
- sqlFactory.addParameter("sys_dataextendid", controller.createTableID("sys_dataextend"));
|
|
|
- }
|
|
|
- sqlFactory.addParameter("siteid", controller.siteid);
|
|
|
- sqlFactory.addParameter("userid", controller.userid);
|
|
|
- sqlFactory.addParameter("username", controller.username);
|
|
|
- sqlFactory.addParameter("ownerid", ownerid);
|
|
|
- sqlFactory.addParameter("ownertable", ownertable);
|
|
|
- String status = document.getRootElement().element("Execution").element("Status").attribute("code")
|
|
|
- .getText();
|
|
|
- logger.info("0".equals(status));
|
|
|
- if ("0".equals(status)) {
|
|
|
- String ferpbillno = document.getRootElement().element("ResponseContent").element("Parameter")
|
|
|
- .element("Record").element("Field").attribute("value").getText();
|
|
|
- sqlFactory.addParameter("erpbillno", ferpbillno);
|
|
|
- logger.info("上传日志" + sqlFactory.getSQL());
|
|
|
- controller.dbConnect.runSqlUpdate(sqlFactory);
|
|
|
- issuccess = true;
|
|
|
- } else {
|
|
|
- issuccess = false;
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return issuccess;
|
|
|
- }
|
|
|
-
|
|
|
- public static String getDate_Str1(Date date) {
|
|
|
- if (date == null) {
|
|
|
- return "";
|
|
|
- }
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- return format.format(date.getTime());
|
|
|
- }
|
|
|
-}
|