|
@@ -712,6 +712,57 @@ public class dispatch extends Controller {
|
|
|
|
|
|
Rows rowscurrentDispatchDetail = dbConnect.runSqlQuery("select sum(t1.qty) qty,t1.sa_orderitemsid,t1.siteid,t2.itemno 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 + " group by t1.sa_orderitemsid,t1.siteid,t2.itemno");
|
|
|
|
|
|
+ Rows rowsDispatchDetailGroupByItem = dbConnect.runSqlQuery("select sum(t1.qty) qty,t2.itemno from sa_dispatch_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.sa_dispatchid=" + sa_dispatchid + " group by t2.itemno");
|
|
|
+ RowsMap rowsMapDispatchDetailGroupByItem = rowsDispatchDetailGroupByItem.toRowsMap("itemno");
|
|
|
+
|
|
|
+ if (siteid.equalsIgnoreCase("lsa") && Parameter.get(siteid, "dispatchinstock").equals("1")) {
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("classname", "getIcinvbal");
|
|
|
+ object.put("method", "getMsg");
|
|
|
+
|
|
|
+ JSONObject content = new JSONObject();
|
|
|
+ content.put("fitemnos", rowsDispatchDetail.toJsonArray("itemno"));
|
|
|
+ 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 = new JSONArray();
|
|
|
+ if (isJSONArray(result)) {
|
|
|
+ jsonArray = JSONArray.parseArray(result);
|
|
|
+ }
|
|
|
+ SQLFactory sqlFactory1 = new SQLFactory(this, "商品发货数量汇总");
|
|
|
+ sqlFactory1.addParameter("siteid", siteid);
|
|
|
+ sqlFactory1.addParameter_in("itemno", rowsDispatchDetail.toArrayList("itemno", new ArrayList<>()));
|
|
|
+ Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
|
|
|
+ RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
|
|
|
+
|
|
|
+ for (Object obj : jsonArray) {
|
|
|
+ JSONObject jsonObject = (JSONObject) obj;
|
|
|
+ if (rowsMapDispatchDetailGroupByItem.containsKey(jsonObject.getString("fitemno"))) {
|
|
|
+ if (rowsMapDispatchDetailGroupByItem.get(jsonObject.getString("fitemno")).isNotEmpty()) {
|
|
|
+ rowsMapDispatchDetailGroupByItem.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("FQty"));
|
|
|
+ } else {
|
|
|
+ rowsMapDispatchDetailGroupByItem.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Row row : rowsDispatchDetailGroupByItem) {
|
|
|
+ if (sumQtyRowsMap.containsKey(row.getString("itemno"))) {
|
|
|
+ row.put("delinvbalqty", (row.containsKey("invbalqty") ? row.getBigDecimal("invbalqty") : BigDecimal.ZERO).subtract(sumQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty")));
|
|
|
+ } else {
|
|
|
+ row.put("delinvbalqty", row.containsKey("invbalqty") ? row.getBigDecimal("invbalqty") : BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (row.getBigDecimal("qty").compareTo(row.getBigDecimal("delinvbalqty")) > 0) {
|
|
|
+ return getErrReturnObject().setErrMsg("发货商品" + row.getString("itemno") + ",库存不足,无法操作复核!")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if (!rowscurrentDispatchDetail.isEmpty()) {
|
|
|
for (Row row : rowscurrentDispatchDetail) {
|
|
|
|
|
@@ -821,22 +872,24 @@ public class dispatch extends Controller {
|
|
|
.toString();
|
|
|
}
|
|
|
}
|
|
|
+ if (siteid.equalsIgnoreCase("lsa")) {
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-// 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<>();
|