Explorar el Código

发货单,退货单增加erp上传记录

hu hace 2 años
padre
commit
01beeb6dc7

+ 2 - 2
src/custom/restcontroller/webmanage/sale/aftersalesmag/aftersalesmag.java

@@ -345,7 +345,7 @@ public class aftersalesmag extends Controller {
             //对接erp生成erp发货单
             if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true")) {
                 ERPDocking erpDocking =new ERPDocking();
-                String result =erpDocking.createErpSareturn(rows.get(0),rowsdetail);
+                String result =erpDocking.createErpSareturn(rows.get(0),rowsdetail,this,sa_aftersalesmagid);
                 if(!result.equals("true")){
                     System.out.println(result);
                     return getErrReturnObject().setErrMsg(result).toString();
@@ -378,7 +378,7 @@ public class aftersalesmag extends Controller {
         if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true")) {
             ERPDocking erpDocking =new ERPDocking();
             String billno = rows.get(0).getString("billno");
-            String result =erpDocking.recheckErpSareturn(billno,false);
+            String result =erpDocking.recheckErpSareturn(billno,false,this,sa_aftersalesmagid);
             if(!result.equals("true")){
                 return getErrReturnObject().setErrMsg(result).toString();
             }

+ 5 - 3
src/custom/restcontroller/webmanage/sale/dispatch/dispatch.java

@@ -429,9 +429,11 @@ public class dispatch extends Controller {
         //对接erp生成erp发货单
         if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true")) {
             ERPDocking erpDocking =new ERPDocking();
-            String result =erpDocking.closeErpSainvoice(rows.get(0).getString("billno"),true);
+            String result =erpDocking.closeErpSainvoice(rows.get(0).getString("billno"),true,this,sa_dispatchid);
             if(!result.equals("true")){
                 return getErrReturnObject().setErrMsg(result).toString();
+            }else {
+
             }
         }
         ArrayList<String> sqlList = new ArrayList<>();
@@ -480,7 +482,7 @@ public class dispatch extends Controller {
         for (Row row : rows) {
             String sa_dispatchid = row.getString("sa_dispatchid");
             String billno = row.getString("billno");
-            String result =erpDocking.closeErpSainvoice(billno,false);
+            String result =erpDocking.closeErpSainvoice(billno,false,this, row.getLong("sa_dispatchid"));
             if(result.equals("true")){
                 sqlList.add("update sa_dispatch set status='关闭' where sa_dispatchid='"+sa_dispatchid+"' and siteid='ZZYOS'");
                 SQLFactory sqlFactory = new SQLFactory(new DataContrlLog(), "数据操作日志新增");
@@ -540,7 +542,7 @@ public class dispatch extends Controller {
             //对接erp生成erp发货单
             if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true")) {
                 ERPDocking erpDocking =new ERPDocking();
-                String result =erpDocking.createErpSainvoice(rows.get(0),rowsdetail);
+                String result =erpDocking.createErpSainvoice(rows.get(0),rowsdetail,this,sa_dispatchid);
                 if(!result.equals("true")){
                      System.out.println(result);
                     return getErrReturnObject().setErrMsg(result).toString();

+ 1 - 0
src/custom/restcontroller/webmanage/sale/item/Item.java

@@ -155,6 +155,7 @@ public class Item extends Controller {
         sqlFactory.addParameter("iswoodproducts", content.getStringValue("iswoodproducts"));
 
         sqlFactory.addParameter("sa_customschemeid", content.getLongValue("sa_customschemeid"));
+        sqlFactory.addParameter("financeclasstype", content.getStringValue("financeclasstype"));
 
         sqlList.add(sqlFactory.getSQL());
         // 货品档案扩展属性字段表

+ 2 - 2
src/custom/restcontroller/webmanage/sale/item/SQL/货品档案新增.sql

@@ -2,9 +2,9 @@ insert into plm_item (siteid, itemid, createby, createdate, changeuserid, change
                       isauxunit, unitgroupid, itemname, isonsale, status, model, spec, orderminqty, orderaddqty,
                       orderminqty_auxunit, orderaddqty_auxunit, remarks, barcode, skucontrol, batchcontrol, grossweight,
                       weight, height, width, length, delivery, istool, marketprice, standards, stockstatus2,
-                      stockstatus1, warrantyday, iswuliao, isservice,color,packageqty,ismodule,iswoodproducts,sa_customschemeid,cheek,delistingstatus)
+                      stockstatus1, warrantyday, iswuliao, isservice,color,packageqty,ismodule,iswoodproducts,sa_customschemeid,cheek,delistingstatus,financeclasstype)
 values ($siteid$, $itemid$, $username$, CURRENT_TIME, $userid$, $username$, CURRENT_TIME, $itemno$, $unitid$,
         $isauxunit$, $unitgroupid$, $itemname$, $isonsale$, '新建', $model$, $spec$, $orderminqty$, $orderaddqty$,
         $orderminqty_auxunit$, $orderaddqty_auxunit$, $remarks$, $barcode$, $skucontrol$, $batchcontrol$, $grossweight$,
         $weight$, $height$, $width$, $length$, $delivery$, $istool$, $marketprice$, $standards$,
-        $stockstatus2$, $stockstatus1$, $warrantyday$, $iswuliao$, $isservice$,$color$,$packageqty$,$ismodule$,$iswoodproducts$,$sa_customschemeid$,$cheek$,$delistingstatus$)
+        $stockstatus2$, $stockstatus1$, $warrantyday$, $iswuliao$, $isservice$,$color$,$packageqty$,$ismodule$,$iswoodproducts$,$sa_customschemeid$,$cheek$,$delistingstatus$,$financeclasstype$)

+ 2 - 1
src/custom/restcontroller/webmanage/sale/item/SQL/货品档案更新.sql

@@ -38,7 +38,8 @@ SET changeuserid=$userid$,
     packageqty = $packageqty$,
     iswoodproducts=$iswoodproducts$,
     isservice = $isservice$,
-    sa_customschemeid=$sa_customschemeid$
+    sa_customschemeid=$sa_customschemeid$,
+    financeclasstype=$financeclasstype$
 WHERE itemid = $itemid$
   and siteid = $siteid$
 

+ 43 - 3
src/custom/service/AftersalesmagAutoRecheckService.java

@@ -1,6 +1,7 @@
 package service;
 
 import beans.datacontrllog.DataContrlLog;
+import beans.uploaderpdata.UploadDataToERP_HY;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import common.ServiceController;
@@ -11,8 +12,10 @@ import common.data.RowsMap;
 import common.data.SQLFactory;
 import org.apache.log4j.Logger;
 import utility.ERPDocking;
+import utility.tools.WebRequest;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 
 
 /**
@@ -31,8 +34,45 @@ public class AftersalesmagAutoRecheckService extends ServiceController {
         for (Row row : rows) {
             String sa_aftersalesmagid = row.getString("sa_aftersalesmagid");
             String billno = row.getString("billno");
-            String result =erpDocking.recheckErpSareturn(billno,false);
-            if(result.equals("true")){
+            JSONObject object= new JSONObject();
+            JSONObject objectdetail= new JSONObject();
+            object.put("access_token","basicDrp");
+            object.put("classname","Sareturn");
+            object.put("method","closeSareturn");
+            objectdetail.put("freturnnum",billno);
+            objectdetail.put("isManual",false);
+            object.put("content",objectdetail);
+
+            HashMap<String, String> map = new HashMap<>();
+            map.put("content-Type", "application/json");
+            String result = new WebRequest().doPost(object.toString(), "http://124.71.196.182:8001/rest/ws_v2/basicDrp", map);
+
+            JSONObject resultobject = JSONObject.parseObject(result);
+            try {
+                SQLFactory sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp上传日志新增");
+                sqlFactory.addParameter("sys_erpupdatelogid", createTableID("sys_erpupdatelog"));
+                sqlFactory.addParameter("siteid", "ZZYOS");
+                sqlFactory.addParameter("userid", 1);
+                sqlFactory.addParameter("username","admin");
+                sqlFactory.addParameter("ownerid", sa_aftersalesmagid);
+                sqlFactory.addParameter("ownertable", "sa_aftersalesmag");
+                sqlFactory.addParameter("type", "复核erp退/换货单");
+                sqlFactory.addParameter("request", object.toString());
+                sqlFactory.addParameter("response", resultobject.toJSONString());
+
+                if ("0".equals(resultobject.getString("errcode"))) {
+                    sqlFactory.addParameter("erpbillno", billno);
+                    sqlFactory.addParameter("errmsg", "");
+                } else {
+                    sqlFactory.addParameter("erpbillno", "");
+                    sqlFactory.addParameter("errmsg", resultobject.getString("errmsg"));
+                }
+                sqlFactory.addParameter("status", resultobject.getString("errcode"));
+                sqlList.add(sqlFactory.getSQL());
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            if(resultobject.getString("errcode").equals("0")){
                 sqlList.add("update sa_aftersalesmag set status='复核' where sa_aftersalesmagid='"+sa_aftersalesmagid+"' and siteid='ZZYOS'");
                 SQLFactory sqlFactory = new SQLFactory(new DataContrlLog(), "数据操作日志新增");
                 sqlFactory.addParameter("ownertable", "sa_aftersalesmag");
@@ -44,7 +84,7 @@ public class AftersalesmagAutoRecheckService extends ServiceController {
                 sqlFactory.addParameter("siteid", "ZZYOS");
                 sqlList.add(sqlFactory.getSQL());
             }else {
-                logger.info("换货单自动复核错误:"+result);
+                logger.info("换货单自动复核错误:"+resultobject.getString("errmsg"));
             }
 
         }

+ 157 - 0
src/custom/service/AutoDockItemService.java

@@ -0,0 +1,157 @@
+package service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import common.ServiceController;
+import common.YosException;
+import common.data.Row;
+import common.data.Rows;
+import common.data.RowsMap;
+import common.data.SQLFactory;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import restcontroller.webmanage.sale.item.Item;
+import utility.ERPDocking;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+
+public class AutoDockItemService extends ServiceController {
+    @Override
+    public void serviceRun() throws YosException {
+        ArrayList<String> sqlList = new ArrayList<>();
+        String siteid ="ZZYOS";
+        Rows itemRows = dbConnect.runSqlQuery("SELECT itemid,itemno from  plm_item WHERE siteid = '" + siteid + "' AND status = '新建' ");
+        Rows itemRowsAll = dbConnect.runSqlQuery("SELECT itemid,itemno from  plm_item WHERE siteid = '" + siteid + "'");
+        //单位
+        Rows unitRows = dbConnect.runSqlQuery("SELECT unitid,unitname from  plm_unit WHERE siteid = '" + siteid + "'");
+        RowsMap unitRowsMap = itemRows.toRowsMap("unitname");
+
+        RowsMap itemRowsMap = itemRows.toRowsMap("itemno");
+        RowsMap itemRowsMapAll = itemRowsAll.toRowsMap("itemno");
+        ERPDocking erpDocking =new ERPDocking();
+        Rows servicesRows = dbConnect.runSqlQuery("select lastruntime from sys_services where classname='AutoDockItemService'");
+        Date date =new Date();
+        if(!servicesRows.isEmpty()){
+            if(StringUtils.isNotBlank(servicesRows.get(0).getString("lastruntime"))){
+                date=servicesRows.get(0).getDate("lastruntime");
+            }
+        }
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        JSONArray jsonArray = erpDocking.getErpItemRows(simpleDateFormat.format(date), 100000, 1);
+        if(!jsonArray.isEmpty()){
+            for (Object object:jsonArray) {
+                JSONObject jsonObject =(JSONObject)object;
+                if(!itemRowsMapAll.containsKey(jsonObject.getString("fitemno"))){
+                    long itemid = createTableID("plm_item");
+                    SQLFactory sqlFactory = new SQLFactory(Item.class, "货品档案新增");
+                    sqlFactory.addParameter("siteid", siteid);
+                    sqlFactory.addParameter("itemid", createTableID("plm_item"));
+                    sqlFactory.addParameter("username", "admin");
+                    sqlFactory.addParameter("userid", 1);
+                    sqlFactory.addParameter("itemno", jsonObject.getString("fitemno"));
+                    if(unitRowsMap.containsKey(jsonObject.getString("funit"))){
+                        sqlFactory.addParameter("unitid", unitRowsMap.get(jsonObject.getString("funit")).get(0).getLong("unitid"));
+                    }else {
+                        sqlFactory.addParameter("unitid", 0);
+                    }
+                    sqlFactory.addParameter("isauxunit", 0);
+                    sqlFactory.addParameter("unitgroupid","null");
+
+                    sqlFactory.addParameter("itemname", jsonObject.getString("fitemname"));
+                    sqlFactory.addParameter("isonsale", 0);
+                    sqlFactory.addParameter("model", jsonObject.getString("fmodel"));
+                    sqlFactory.addParameter("spec", jsonObject.getString("spec"));
+                    // 订单起订量
+                    sqlFactory.addParameter("orderminqty", 1);
+                    // 订单增量
+                    sqlFactory.addParameter("orderaddqty", 1);
+                    // 订单起订量控制单位(0:主单位;1:辅助单位)
+                    sqlFactory.addParameter("orderminqty_auxunit", 0);
+                    // 订单增量控制单位(0:主单位;1:辅助单位)
+                    sqlFactory.addParameter("orderaddqty_auxunit", 0);
+                    // 说明
+                    sqlFactory.addParameter("remarks", "");
+                    // 商品条形码
+                    sqlFactory.addParameter("barcode", "");
+                    // 是否单品管理
+                    sqlFactory.addParameter("skucontrol",0);
+                    // 是否批次管理
+                    sqlFactory.addParameter("batchcontrol", jsonObject.getBooleanValue("fisbatch"));
+                    // 毛重(g)
+                    sqlFactory.addParameter("grossweight", 0);
+                    // 净重(g)
+                    sqlFactory.addParameter("weight", 0);
+                    // 高度(mm)
+                    sqlFactory.addParameter("height", 0);
+                    // 宽度(mm)
+                    sqlFactory.addParameter("width", 0);
+                    // 长度(mm)
+                    sqlFactory.addParameter("length", 0);
+                    // 交期
+                    sqlFactory.addParameter("delivery", 1);
+                    // 牌价
+                    sqlFactory.addParameter("marketprice", 0);
+                    // 是否工具
+                    sqlFactory.addParameter("istool", 0);
+                    // 产品标准
+                    sqlFactory.addParameter("standards","");
+                    // 库存缺货标准
+                    sqlFactory.addParameter("stockstatus2", 1);
+                    // 库存充足标准
+                    sqlFactory.addParameter("stockstatus1", 1);
+                    // 保修期(年)
+                    sqlFactory.addParameter("warrantyday", 1);
+                    // 是否营销物料
+                    sqlFactory.addParameter("iswuliao",1);
+                    // 是否服务物料
+                    sqlFactory.addParameter("isservice", 0);
+
+                    sqlFactory.addParameter("color", jsonObject.getStringValue("fcolor"));
+                    sqlFactory.addParameter("cheek", jsonObject.getStringValue("fsizedescription"));
+                    sqlFactory.addParameter("delistingstatus","");
+
+                    sqlFactory.addParameter("ismodule", 0);
+                    sqlFactory.addParameter("packageqty", 0);
+                    sqlFactory.addParameter("iswoodproducts", 0);
+
+                    sqlFactory.addParameter("sa_customschemeid", 0);
+                    sqlFactory.addParameter("financeclasstype", jsonObject.getStringValue("fdescription"));
+
+                    sqlList.add(sqlFactory.getSQL());
+                    // 货品档案扩展属性字段表
+
+                    sqlFactory = new SQLFactory(Item.class, "货品档案-扩展新增");
+                    sqlFactory.addParameter("siteid", siteid);
+                    sqlFactory.addParameter("userid", 1);
+                    sqlFactory.addParameter("username", "admin");
+                    sqlFactory.addParameter("plm_itemextendid", createTableID("plm_itemextend"));
+                    sqlFactory.addParameter("itemid", itemid);
+                    sqlFactory.addParameter("material", jsonObject.getString("fmaterialdes"));
+                    sqlFactory.addParameter("pressure", "");
+                    sqlFactory.addParameter("caliber", "");
+                    sqlFactory.addParameter("butterflyplatedrive", "");
+                    sqlFactory.addParameter("connection", "");
+                    sqlFactory.addParameter("valveplatematerial", "");
+                    sqlFactory.addParameter("bodymaterial", "");
+                    sqlFactory.addParameter("actuatortype", "");
+                    sqlFactory.addParameter("actuatorbrand", "");
+                    sqlFactory.addParameter("isbutterfly", "");
+                    sqlFactory.addParameter("erpitemno", jsonObject.getString("fitemno"));
+                    sqlFactory.addParameter("erpitemname", jsonObject.getString("fitemname"));
+                    sqlFactory.addParameter("specalnote","");
+                    sqlFactory.addParameter("prodline", "");
+                    sqlFactory.addParameter("device", "");
+
+                    sqlList.add(sqlFactory.getSQL());
+
+                }
+
+            }
+        }
+        dbConnect.runSqlUpdate(sqlList);
+    }
+
+}

+ 47 - 5
src/custom/service/DispatchAutoCloseService.java

@@ -1,6 +1,7 @@
 package service;
 
 import beans.datacontrllog.DataContrlLog;
+import beans.uploaderpdata.UploadDataToERP_HY;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import common.ServiceController;
@@ -11,8 +12,10 @@ import common.data.RowsMap;
 import common.data.SQLFactory;
 import org.apache.log4j.Logger;
 import utility.ERPDocking;
+import utility.tools.WebRequest;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 
 
 /**
@@ -34,8 +37,47 @@ public class DispatchAutoCloseService extends ServiceController {
             String sa_dispatchid = row.getString("sa_dispatchid");
             String billno = row.getString("billno");
             JSONArray jsonArray = erpDocking.queryErpSainvoice(billno);
-            String result =erpDocking.closeErpSainvoice(billno,false);
-            if(result.equals("true")){
+
+            JSONObject object= new JSONObject();
+            JSONObject objectdetail= new JSONObject();
+            object.put("access_token","basicDrp");
+            object.put("classname","Sainvoice");
+            object.put("method","closeSainvoice");
+            objectdetail.put("finvonum",billno);
+            objectdetail.put("isManual",false);
+            object.put("content",objectdetail);
+
+            HashMap<String, String> map = new HashMap<>();
+            map.put("content-Type", "application/json");
+            String result = new WebRequest().doPost(object.toString(), "http://124.71.196.182:8001/rest/ws_v2/basicDrp", map);
+            JSONObject resultobject = JSONObject.parseObject(result);
+
+            try {
+                SQLFactory sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp上传日志新增");
+                sqlFactory.addParameter("sys_erpupdatelogid", createTableID("sys_erpupdatelog"));
+                sqlFactory.addParameter("siteid", "ZZYOS");
+                sqlFactory.addParameter("userid", 1);
+                sqlFactory.addParameter("username","admin");
+                sqlFactory.addParameter("ownerid", sa_dispatchid);
+                sqlFactory.addParameter("ownertable", "sa_dispatch");
+                sqlFactory.addParameter("type", "关闭发货单");
+                sqlFactory.addParameter("request", object.toString());
+                sqlFactory.addParameter("response", resultobject.toJSONString());
+
+                if ("0".equals(resultobject.getString("errcode"))) {
+                    sqlFactory.addParameter("erpbillno", billno);
+                    sqlFactory.addParameter("errmsg", "");
+                } else {
+                    sqlFactory.addParameter("erpbillno", "");
+                    sqlFactory.addParameter("errmsg", resultobject.getString("errmsg"));
+                }
+                sqlFactory.addParameter("status", resultobject.getString("errcode"));
+                sqlList.add(sqlFactory.getSQL());
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+            if(resultobject.getString("errcode").equals("0")){
                 sqlList.add("update sa_dispatch set status='关闭' where sa_dispatchid='"+sa_dispatchid+"' and siteid='ZZYOS'");
                 SQLFactory sqlFactory = new SQLFactory(new DataContrlLog(), "数据操作日志新增");
                 sqlFactory.addParameter("ownertable", "sa_dispatch");
@@ -47,11 +89,11 @@ public class DispatchAutoCloseService extends ServiceController {
                 sqlFactory.addParameter("siteid", "ZZYOS");
                 sqlList.add(sqlFactory.getSQL());
             }else {
-                logger.info("发货单自动关闭错误:"+result);
+                logger.info("发货单自动关闭错误:"+resultobject.getString("errmsg"));
             }
             if(!jsonArray.isEmpty()){
-                for (Object object:jsonArray) {
-                    JSONObject jsonObject = (JSONObject)object;
+                for (Object object1:jsonArray) {
+                    JSONObject jsonObject = (JSONObject)object1;
                     sqlList.add("update sa_dispatch_items set outwarehouseqty="+jsonObject.getBigDecimalValue("fqty1")+" where rowno ="+jsonObject.getIntValue("frownum")+" and sa_dispatchid='"+sa_dispatchid+"' and siteid='ZZYOS'");
                 }
             }

+ 76 - 6
src/custom/utility/ERPDocking.java

@@ -1,10 +1,14 @@
 package utility;
 
+import beans.uploaderpdata.UploadDataToERP_HY;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import common.Controller;
 import common.YosException;
 import common.data.Row;
 import common.data.Rows;
+import common.data.SQLFactory;
+import org.dom4j.Document;
 import utility.tools.WebRequest;
 
 import java.io.BufferedReader;
@@ -78,7 +82,11 @@ public class ERPDocking {
         map.put("content-Type", "application/json");
         String result = new WebRequest().doPost(object.toString(), "http://124.71.196.182:8001/rest/ws_v2/basicDrp", map);
         JSONObject resultobject = JSONObject.parseObject(result);
-        return resultobject.getJSONObject("results").getJSONArray("list");
+        if(resultobject.getString("errcode").equals("0")){
+            return resultobject.getJSONObject("results").getJSONArray("list");
+        }else {
+            return new JSONArray();
+        }
     }
 
     /**
@@ -110,7 +118,12 @@ public class ERPDocking {
             map.put("content-Type", "application/json");
             String result = new WebRequest().doPost(object.toString(), "http://124.71.196.182:8001/rest/ws_v2/basicDrp", map);
             JSONObject resultobject = JSONObject.parseObject(result);
-            return resultobject.getJSONObject("results").getJSONArray("list");
+            if(resultobject.getString("errcode").equals("0")){
+                return resultobject.getJSONObject("results").getJSONArray("list");
+            }else {
+                return new JSONArray();
+            }
+
         }
     }
 
@@ -121,7 +134,7 @@ public class ERPDocking {
      * @return
      * @throws YosException
      */
-    public String createErpSainvoice(Row dispatchRow, Rows dispatchItems) throws YosException {
+    public String createErpSainvoice(Row dispatchRow, Rows dispatchItems,Controller controller,long sa_dispatchid) throws YosException {
         {
 
             JSONObject object= new JSONObject();
@@ -160,6 +173,9 @@ public class ERPDocking {
             map.put("content-Type", "application/json");
             String result = new WebRequest().doPost(object.toString(), "http://124.71.196.182:8001/rest/ws_v2/basicDrp", map);
             JSONObject resultobject = JSONObject.parseObject(result);
+
+            saveLog(controller,"sa_dispatch",sa_dispatchid,"创建erp发货单",object.toString(),resultobject,dispatchRow.getString("billno"));
+
             if(resultobject.getString("errcode").equals("0")){
                 return "true";
             }else {
@@ -205,7 +221,7 @@ public class ERPDocking {
      * @return
      * @throws YosException
      */
-    public String closeErpSainvoice(String billno, boolean isManual) throws YosException {
+    public String closeErpSainvoice(String billno, boolean isManual,Controller controller,long sa_dispatchid) throws YosException {
         {
 
             JSONObject object= new JSONObject();
@@ -221,6 +237,9 @@ public class ERPDocking {
             map.put("content-Type", "application/json");
             String result = new WebRequest().doPost(object.toString(), "http://124.71.196.182:8001/rest/ws_v2/basicDrp", map);
             JSONObject resultobject = JSONObject.parseObject(result);
+
+            saveLog(controller,"sa_dispatch",sa_dispatchid,"关闭发货单",object.toString(),resultobject,billno);
+
             if(resultobject.getString("errcode").equals("0")){
                 return "true";
             }else {
@@ -228,6 +247,7 @@ public class ERPDocking {
             }
         }
     }
+
     /**
      * 创建Erp退/换货单
      * @param aftersalesmagRow
@@ -235,7 +255,7 @@ public class ERPDocking {
      * @return
      * @throws YosException
      */
-    public String createErpSareturn(Row aftersalesmagRow, Rows aftersalesmagItems) throws YosException {
+    public String createErpSareturn(Row aftersalesmagRow, Rows aftersalesmagItems,Controller controller,long sa_aftersalesmagid) throws YosException {
         {
 
             JSONObject object= new JSONObject();
@@ -275,6 +295,9 @@ public class ERPDocking {
              System.out.println(object.toString());
             String result = new WebRequest().doPost(object.toString(), "http://124.71.196.182:8001/rest/ws_v2/basicDrp", map);
             JSONObject resultobject = JSONObject.parseObject(result);
+
+            saveLog(controller,"sa_aftersalesmag",sa_aftersalesmagid,"创建erp退/换货单",object.toString(),resultobject,aftersalesmagRow.getString("billno"));
+
             if(resultobject.getString("errcode").equals("0")){
                 return "true";
             }else {
@@ -319,7 +342,7 @@ public class ERPDocking {
      * @return
      * @throws YosException
      */
-    public String recheckErpSareturn(String billno, boolean isManual) throws YosException {
+    public String recheckErpSareturn(String billno, boolean isManual,Controller controller,long sa_aftersalesmagid) throws YosException {
         {
 
             JSONObject object= new JSONObject();
@@ -335,6 +358,9 @@ public class ERPDocking {
             map.put("content-Type", "application/json");
             String result = new WebRequest().doPost(object.toString(), "http://124.71.196.182:8001/rest/ws_v2/basicDrp", map);
             JSONObject resultobject = JSONObject.parseObject(result);
+
+            saveLog(controller,"sa_aftersalesmag",sa_aftersalesmagid,"复核erp退/换货单",object.toString(),resultobject,billno);
+
             if(resultobject.getString("errcode").equals("0")){
                 return "true";
             }else {
@@ -342,6 +368,50 @@ public class ERPDocking {
             }
         }
     }
+
+
+    /**
+     * 上传日志更新
+     * @param controller
+     * @param ownertable
+     * @param ownerid
+     * @param type
+     * @param request
+     * @param response
+     * @param billno
+     * @return
+     */
+    public static boolean saveLog(Controller controller, String ownertable, long ownerid, String type, String request,
+                                  JSONObject response,String billno) {
+        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", response.toJSONString());
+
+            if ("0".equals(response.getString("errcode"))) {
+                sqlFactory.addParameter("erpbillno", billno);
+                sqlFactory.addParameter("errmsg", "");
+                issuccess = true;
+            } else {
+                sqlFactory.addParameter("erpbillno", "");
+                sqlFactory.addParameter("errmsg", response.getString("errmsg"));
+                issuccess = false;
+            }
+            sqlFactory.addParameter("status", response.getString("errcode"));
+            controller.dbConnect.runSqlUpdate(sqlFactory);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return issuccess;
+    }
 //    /**
 //     * crm账号同步反馈
 //     *