|
@@ -31,81 +31,96 @@ public class DispatchAutoCloseService extends ServiceController {
|
|
|
Rows rows = dbConnect.runSqlQuery("select * from sa_dispatch where status='复核' and siteid='ZZYOS'");
|
|
Rows rows = dbConnect.runSqlQuery("select * from sa_dispatch where status='复核' and siteid='ZZYOS'");
|
|
|
Rows rowsdetail = dbConnect.runSqlQuery("select t1.* from sa_dispatch_items t1 inner join sa_dispatch t2 on t1.sa_dispatchid=t2.sa_dispatchid and t1.siteid=t2.siteid where t2.status='复核' and t1.siteid='ZZYOS'");
|
|
Rows rowsdetail = dbConnect.runSqlQuery("select t1.* from sa_dispatch_items t1 inner join sa_dispatch t2 on t1.sa_dispatchid=t2.sa_dispatchid and t1.siteid=t2.siteid where t2.status='复核' and t1.siteid='ZZYOS'");
|
|
|
RowsMap rowsMap = rowsdetail.toRowsMap("sa_dispatchid");
|
|
RowsMap rowsMap = rowsdetail.toRowsMap("sa_dispatchid");
|
|
|
|
|
+ RowsMap rowsMap1 = rowsdetail.toRowsMap("billno");
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
ERPDocking erpDocking =new ERPDocking();
|
|
ERPDocking erpDocking =new ERPDocking();
|
|
|
- for (Row row : rows) {
|
|
|
|
|
- String sa_dispatchid = row.getString("sa_dispatchid");
|
|
|
|
|
- String billno = row.getString("billno");
|
|
|
|
|
- JSONArray jsonArray = erpDocking.queryErpSainvoice(billno);
|
|
|
|
|
-
|
|
|
|
|
- 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 {
|
|
|
|
|
- Rows erpupdatelogRows = dbConnect.runSqlQuery(
|
|
|
|
|
- "select * from sys_erpupdatelog where ownertable='sa_dispatch' and type='关闭发货单' and ownerid=" + sa_dispatchid);
|
|
|
|
|
- SQLFactory sqlFactory;
|
|
|
|
|
- if (!rows.isEmpty()) {
|
|
|
|
|
- sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp上传日志更新");
|
|
|
|
|
- sqlFactory.addParameter("sys_erpupdatelogid", erpupdatelogRows.get(0).getLong("sys_erpupdatelogid"));
|
|
|
|
|
- } else {
|
|
|
|
|
- sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp上传日志新增");
|
|
|
|
|
- sqlFactory.addParameter("sys_erpupdatelogid", createTableID("sys_erpupdatelog"));
|
|
|
|
|
|
|
+ JSONArray ErpSainvoices = erpDocking.queryErpSainvoices(1, 1000, new JSONArray(), "", "", "", true);
|
|
|
|
|
+ if(!ErpSainvoices.isEmpty()){
|
|
|
|
|
+ for (Object ErpSainvoice:ErpSainvoices) {
|
|
|
|
|
+ JSONObject erpSainvoice = (JSONObject) ErpSainvoice;
|
|
|
|
|
+ String billno = erpSainvoice.getString("finvonum");
|
|
|
|
|
+ long sa_dispatchid=0;
|
|
|
|
|
+ if(rowsMap1.containsKey(billno)){
|
|
|
|
|
+ if(rowsMap1.get(billno).isNotEmpty()){
|
|
|
|
|
+ sa_dispatchid=rowsMap1.get(billno).get(0).getLong("sa_dispatchid");
|
|
|
|
|
+ }else{
|
|
|
|
|
+ logger.info("发货单【"+billno+"】不存在:");
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ logger.info("发货单【"+billno+"】不存在:");
|
|
|
}
|
|
}
|
|
|
- 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"));
|
|
|
|
|
|
|
+ JSONArray jsonArray = erpDocking.queryErpSainvoice(billno);
|
|
|
|
|
+
|
|
|
|
|
+ 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 {
|
|
|
|
|
+ Rows erpupdatelogRows = dbConnect.runSqlQuery(
|
|
|
|
|
+ "select * from sys_erpupdatelog where ownertable='sa_dispatch' and type='关闭发货单' and ownerid=" + sa_dispatchid);
|
|
|
|
|
+ SQLFactory sqlFactory;
|
|
|
|
|
+ if (!rows.isEmpty()) {
|
|
|
|
|
+ sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp上传日志更新");
|
|
|
|
|
+ sqlFactory.addParameter("sys_erpupdatelogid", erpupdatelogRows.get(0).getLong("sys_erpupdatelogid"));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ 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();
|
|
|
}
|
|
}
|
|
|
- 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");
|
|
|
|
|
- sqlFactory.addParameter("ownerid", sa_dispatchid);
|
|
|
|
|
- sqlFactory.addParameter("action", "自动关闭");
|
|
|
|
|
- sqlFactory.addParameter("remarks", "发货单自动关闭成功");
|
|
|
|
|
- sqlFactory.addParameter("actionuserid", "1");
|
|
|
|
|
- sqlFactory.addParameter("actionby", "admin");
|
|
|
|
|
- sqlFactory.addParameter("siteid", "ZZYOS");
|
|
|
|
|
- sqlList.add(sqlFactory.getSQL());
|
|
|
|
|
- }else {
|
|
|
|
|
- logger.info("发货单自动关闭错误:"+resultobject.getString("errmsg"));
|
|
|
|
|
- }
|
|
|
|
|
- if(!jsonArray.isEmpty()){
|
|
|
|
|
- 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'");
|
|
|
|
|
|
|
+ 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");
|
|
|
|
|
+ sqlFactory.addParameter("ownerid", sa_dispatchid);
|
|
|
|
|
+ sqlFactory.addParameter("action", "自动关闭");
|
|
|
|
|
+ sqlFactory.addParameter("remarks", "发货单自动关闭成功");
|
|
|
|
|
+ sqlFactory.addParameter("actionuserid", "1");
|
|
|
|
|
+ sqlFactory.addParameter("actionby", "admin");
|
|
|
|
|
+ sqlFactory.addParameter("siteid", "ZZYOS");
|
|
|
|
|
+ sqlList.add(sqlFactory.getSQL());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ logger.info("发货单自动关闭错误:"+resultobject.getString("errmsg"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!jsonArray.isEmpty()){
|
|
|
|
|
+ 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'");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
}
|
|
}
|