|
|
@@ -12,7 +12,6 @@ import common.YosException;
|
|
|
import common.annotation.API;
|
|
|
import common.annotation.CACHEING;
|
|
|
import common.annotation.CACHEING_CLEAN;
|
|
|
-
|
|
|
import common.data.*;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.log4j.Logger;
|
|
|
@@ -22,6 +21,7 @@ import restcontroller.webmanage.executorService.Executor;
|
|
|
import restcontroller.webmanage.sale.order.Order;
|
|
|
import restcontroller.webmanage.sale.order.OrderItems;
|
|
|
import utility.ERPDocking;
|
|
|
+import utility.tools.WebRequest;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -453,6 +453,9 @@ public class dispatch extends Controller {
|
|
|
Long sa_orderid = 0L;
|
|
|
Rows rows = dbConnect.runSqlQuery("select sa_dispatchid,status,billno,sa_orderid from sa_dispatch where sa_dispatchid ='"
|
|
|
+ sa_dispatchid + "' and siteid='" + siteid + "'");
|
|
|
+
|
|
|
+ Rows rowsdetail = dbConnect.runSqlQuery("select sa_dispatch_itemsid from sa_dispatch_items where sa_dispatchid ='"
|
|
|
+ + sa_dispatchid + "' and siteid='" + siteid + "'");
|
|
|
if (rows.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("该发货单不存在")
|
|
|
.toString();
|
|
|
@@ -463,24 +466,43 @@ public class dispatch extends Controller {
|
|
|
.toString();
|
|
|
}
|
|
|
}
|
|
|
- //对接erp生成erp发货单
|
|
|
- if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") && siteid.equalsIgnoreCase("ccyosg")) {
|
|
|
- ERPDocking erpDocking = new ERPDocking();
|
|
|
- String result = erpDocking.closeErpSainvoice(rows.get(0).getString("billno"), true, this, sa_dispatchid);
|
|
|
- if (!result.equals("true")) {
|
|
|
- return getErrReturnObject().setErrMsg(result).toString();
|
|
|
- } else {
|
|
|
- JSONArray jsonArray = erpDocking.queryErpSainvoice(rows.get(0).getString("billno"));
|
|
|
- ArrayList<String> dispatchsqlList = new ArrayList<>();
|
|
|
- if (!jsonArray.isEmpty()) {
|
|
|
- for (Object object1 : jsonArray) {
|
|
|
- JSONObject jsonObject = (JSONObject) object1;
|
|
|
- dispatchsqlList.add("update sa_dispatch_items set outwarehouseqty=" + jsonObject.getBigDecimalValue("fqty1") + " where rowno =" + jsonObject.getIntValue("frownum") + " and sa_dispatchid='" + sa_dispatchid + "' and siteid='" + siteid + "'");
|
|
|
- }
|
|
|
- }
|
|
|
- dbConnect.runSqlUpdate(dispatchsqlList);
|
|
|
- }
|
|
|
+
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("classname", "getIcinvbal");
|
|
|
+ object.put("method", "getIcstockbillMsg");
|
|
|
+
|
|
|
+ JSONObject content = new JSONObject();
|
|
|
+ content.put("sa_dispatch_itemsids", rowsdetail.toJsonArray("sa_dispatch_itemsid"));
|
|
|
+ object.put("content", content);
|
|
|
+
|
|
|
+ WebRequest request = new WebRequest();
|
|
|
+ String result = request.doPost(object.toString(),
|
|
|
+ "http://60.190.151.198:8089/BYESB/jaxrs/webclientrest");
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(result);
|
|
|
+ if(!jsonArray.isEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("中间表存在未同步的销售出库单,无法手工关闭")
|
|
|
+ .toString();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //对接erp生成erp发货单
|
|
|
+// if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") && siteid.equalsIgnoreCase("ccyosg")) {
|
|
|
+// ERPDocking erpDocking = new ERPDocking();
|
|
|
+// String result = erpDocking.closeErpSainvoice(rows.get(0).getString("billno"), true, this, sa_dispatchid);
|
|
|
+// if (!result.equals("true")) {
|
|
|
+// return getErrReturnObject().setErrMsg(result).toString();
|
|
|
+// } else {
|
|
|
+// JSONArray jsonArray = erpDocking.queryErpSainvoice(rows.get(0).getString("billno"));
|
|
|
+// ArrayList<String> dispatchsqlList = new ArrayList<>();
|
|
|
+// if (!jsonArray.isEmpty()) {
|
|
|
+// for (Object object1 : jsonArray) {
|
|
|
+// JSONObject jsonObject = (JSONObject) object1;
|
|
|
+// dispatchsqlList.add("update sa_dispatch_items set outwarehouseqty=" + jsonObject.getBigDecimalValue("fqty1") + " where rowno =" + jsonObject.getIntValue("frownum") + " and sa_dispatchid='" + sa_dispatchid + "' and siteid='" + siteid + "'");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// dbConnect.runSqlUpdate(dispatchsqlList);
|
|
|
+// }
|
|
|
+// }
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
|
|
|
Rows rowsOrderDetail = dbConnect.runSqlQuery("select t1.undeliqty,t1.deliedqty,t1.qty,t1.sa_orderitemsid from sa_orderitems t1 where t1.sa_orderitemsid in (select sa_orderitemsid from sa_dispatch_items where sa_dispatchid=" + sa_dispatchid + ")");
|
|
|
@@ -669,14 +691,15 @@ public class dispatch extends Controller {
|
|
|
sqlList.add("update sa_dispatch set sa_orderid=" + orderRows.get(0).getLong("sa_orderid") + " where siteid='" + siteid + "' and sa_dispatchid=" + sa_dispatchid);
|
|
|
}
|
|
|
//对接erp生成erp发货单
|
|
|
- if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") && siteid.equalsIgnoreCase("ccyosg")) {
|
|
|
- ERPDocking erpDocking = new ERPDocking();
|
|
|
- String result = erpDocking.createErpSainvoice(rows.get(0), rowsdetail, this, sa_dispatchid);
|
|
|
- if (!result.equals("true")) {
|
|
|
- System.out.println(result);
|
|
|
- return getErrReturnObject().setErrMsg(result).toString();
|
|
|
- }
|
|
|
- }
|
|
|
+// if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") && siteid.equalsIgnoreCase("ccyosg")) {
|
|
|
+// ERPDocking erpDocking = new ERPDocking();
|
|
|
+// String result = erpDocking.createErpSainvoice(rows.get(0), rowsdetail, this, sa_dispatchid);
|
|
|
+// if (!result.equals("true")) {
|
|
|
+// System.out.println(result);
|
|
|
+// return getErrReturnObject().setErrMsg(result).toString();
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
// //判断当前订单是否已发完货,如果发完,则生把订单变为关闭状态
|
|
|
// //总数量
|
|
|
// Rows totalRows = dbConnect.runSqlQuery("select count(1) count,sa_orderid from sa_orderitems where siteid='" + siteid + "' group by sa_orderid");
|
|
|
@@ -707,6 +730,70 @@ public class dispatch extends Controller {
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "反复核", apiversion = R.ID20230720152503.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class, cashbill.class})
|
|
|
+ public String unrecheck() throws YosException {
|
|
|
+ Long sa_dispatchid = content.getLong("sa_dispatchid");
|
|
|
+ Rows dispatchRows = dbConnect.runSqlQuery("select sa_dispatchid,status,billno,sa_orderid,sys_enterpriseid from sa_dispatch where sa_dispatchid ='"
|
|
|
+ + sa_dispatchid + "' and siteid='" + siteid + "'");
|
|
|
+ if (dispatchRows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("该发货单不存在")
|
|
|
+ .toString();
|
|
|
+ } else {
|
|
|
+ if (!dispatchRows.get(0).getString("status").equals("复核")) {
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + dispatchRows.get(0).getString("billno") + "】的发货单为非复核状态,无法反复核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("classname", "getIcinvbal");
|
|
|
+ object.put("method", "getSainvoiceMsg");
|
|
|
+
|
|
|
+ JSONObject content = new JSONObject();
|
|
|
+ content.put("billno", dispatchRows.get(0).getString("billno"));
|
|
|
+ object.put("content", content);
|
|
|
+
|
|
|
+ WebRequest request = new WebRequest();
|
|
|
+ String result = request.doPost(object.toString(),
|
|
|
+ "http://60.190.151.198:8089/BYESB/jaxrs/webclientrest");
|
|
|
+ if(result.equals("true")){
|
|
|
+ return getErrReturnObject().setErrMsg("K3发货单为非删除状态,无法反复核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ Rows rowsOrderDetail = dbConnect.runSqlQuery("select t1.undeliqty,t1.deliedqty,t1.qty,t1.sa_orderitemsid from sa_orderitems t1 where t1.sa_orderitemsid in (select sa_orderitemsid from sa_dispatch_items where sa_dispatchid=" + sa_dispatchid + ")");
|
|
|
+ RowsMap rowsMap = rowsOrderDetail.toRowsMap("sa_orderitemsid");
|
|
|
+ Rows rowsDispatchDetail = dbConnect.runSqlQuery("select t1.qty,t1.outwarehouseqty,t1.sa_orderitemsid,t1.rowno,t2.itemname from sa_dispatch_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.sa_dispatchid=" + sa_dispatchid);
|
|
|
+ if (!rowsDispatchDetail.isEmpty()) {
|
|
|
+ for (Row row : rowsDispatchDetail) {
|
|
|
+ sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").add(row.getBigDecimal("qty").subtract(row.getBigDecimal("outwarehouseqty"))) + ",deliedqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty").subtract(row.getBigDecimal("qty").subtract(row.getBigDecimal("outwarehouseqty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg("该发货单明细不存在,无法复核").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ SQLFactory sqlFactoryupdate = new SQLFactory(this, "发货单复核");
|
|
|
+ Rows orderRows = dbConnect.runSqlQuery("select distinct t1.sa_orderid from sa_orderitems t1 inner join sa_dispatch_items t2 on t1.siteid=t2.siteid and t1.sa_orderitemsid=t2.sa_orderitemsid where t1.siteid='" + siteid + "' and t2.sa_dispatchid=" + sa_dispatchid);
|
|
|
+
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_dispatch", sa_dispatchid, "反复核", "发货单反复核成功").getSQL());
|
|
|
+
|
|
|
+ sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
+ sqlFactoryupdate.addParameter("sa_dispatchid", sa_dispatchid);
|
|
|
+ sqlFactoryupdate.addParameter("recheckby", username);
|
|
|
+ sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+
|
|
|
+ Long sys_enterpriseid = dispatchRows.get(0).getLong("sys_enterpriseid");
|
|
|
+ String message = "您的发货单" + dispatchRows.get(0).getString("billno") + "已复核,请及时查看!";
|
|
|
+ sendMsg(message, sa_dispatchid, sys_enterpriseid);
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@API(title = "一键生成发货单", apiversion = R.ID20230220100604.v1.class)
|
|
|
@CACHEING_CLEAN(apiversions = {R.ID20221114135303.v1.class, R.ID20221114135403.v1.class, R.ID20230320160203.v1.class})
|