|
@@ -719,9 +719,36 @@ public class dispatch extends Controller {
|
|
|
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.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);
|
|
|
+ Rows rowsDispatchDetail = dbConnect.runSqlQuery("select t1.qty,t1.sa_orderitemsid,t1.rowno,t2.itemname,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);
|
|
|
+ RowsMap rowsMapDispatchDetail = rowsDispatchDetail.toRowsMap("itemno");
|
|
|
+
|
|
|
+ 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:8092/BYESB/jaxrs/webclientrest");
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(result);
|
|
|
+ for (Object obj : jsonArray) {
|
|
|
+ JSONObject jsonObject = (JSONObject) obj;
|
|
|
+ if (rowsMapDispatchDetail.containsKey(jsonObject.getString("fitemno"))) {
|
|
|
+ if (rowsMapDispatchDetail.get(jsonObject.getString("fitemno")).isNotEmpty()) {
|
|
|
+ rowsMapDispatchDetail.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("FQty"));
|
|
|
+ }else{
|
|
|
+ rowsMapDispatchDetail.get(jsonObject.getString("fitemno")).get(0).put("invbalqty",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (!rowsDispatchDetail.isEmpty()) {
|
|
|
for (Row row : rowsDispatchDetail) {
|
|
|
+ System.out.println(Parameter.get(siteid,"dispatchinstock"));
|
|
|
+ System.out.println(Parameter.get(siteid,"dispatchinstock").equals("1"));
|
|
|
if (rowsMap.get(row.getString("sa_orderitemsid")).isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("行号为:【" + row.getString("rowno") + "】的发货单明细不存在对应得订单行,无法复核")
|
|
|
.toString();
|
|
@@ -730,21 +757,33 @@ public class dispatch extends Controller {
|
|
|
return getErrReturnObject().setErrMsg("行号为:【" + row.getString("rowno") + "】的发货单明细的数量大于对应订单行的未发货数量,无法复核")
|
|
|
.toString();
|
|
|
}
|
|
|
+
|
|
|
+ if(Parameter.get(siteid,"dispatchinstock").equals("1")){
|
|
|
+ if (row.getBigDecimal("qty").compareTo(row.getBigDecimal("invbalqty")) > 0) {
|
|
|
+ return getErrReturnObject().setErrMsg("行号为:【" + row.getString("rowno") + "】的发货单明细的数量大于erp的库存数量,无法复核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").subtract(row.getBigDecimal("qty")) + ",deliedqty=" + (row.getBigDecimal("qty").add(rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
}
|
|
|
} else {
|
|
|
return getErrReturnObject().setErrMsg("该发货单明细不存在,无法复核").toString();
|
|
|
}
|
|
|
-
|
|
|
+//
|
|
|
Rows rows = dbConnect.runSqlQuery("select t1.*,t3.agentnum,t2.enterprisename,t4.sonum,t5.name,t5.phonenumber,t5.address from sa_dispatch t1 left join sys_enterprise t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid left join sa_agents t3 on t1.sys_enterpriseid=t3.sys_enterpriseid and t1.siteid=t3.siteid left join sa_order t4 on t1.sa_orderid=t4.sa_orderid and t1.siteid=t4.siteid left join sys_enterprise_contacts t5 on t1.rec_contactsid=t5.contactsid and t1.siteid=t5.siteid where t1.sa_dispatchid ='"
|
|
|
+ sa_dispatchid + "' and t1.siteid='" + siteid + "'");
|
|
|
- Rows rowsdetail = dbConnect.runSqlQuery("select t3.sonum,t2.rowno sorowno,t4.itemno,t1.batchno,t1.rowno,t1.qty,t2.price,t1.remarks from sa_dispatch_items t1 left join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid left join sa_order t3 on t2.sa_orderid=t3.sa_orderid and t2.siteid=t3.siteid left join plm_item t4 on t1.itemid=t4.itemid and t1.siteid=t4.siteid where t1.sa_dispatchid ='"
|
|
|
- + sa_dispatchid + "' and t1.siteid='" + siteid + "'");
|
|
|
+// Rows rowsdetail = dbConnect.runSqlQuery("select t3.sonum,t2.rowno sorowno,t4.itemno,t1.batchno,t1.rowno,t1.qty,t2.price,t1.remarks from sa_dispatch_items t1 left join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid left join sa_order t3 on t2.sa_orderid=t3.sa_orderid and t2.siteid=t3.siteid left join plm_item t4 on t1.itemid=t4.itemid and t1.siteid=t4.siteid where t1.sa_dispatchid ='"
|
|
|
+// + sa_dispatchid + "' and t1.siteid='" + siteid + "'");
|
|
|
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);
|
|
|
- if (orderRows.size() == 1) {
|
|
|
- sqlList.add("update sa_dispatch set sa_orderid=" + orderRows.get(0).getLong("sa_orderid") + " where siteid='" + siteid + "' and sa_dispatchid=" + sa_dispatchid);
|
|
|
- }
|
|
|
+// 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);
|
|
|
+// if (orderRows.size() == 1) {
|
|
|
+// 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();
|