|
@@ -26,6 +26,8 @@ import utility.tools.WebRequest;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
|
|
|
import static java.time.LocalDate.now;
|
|
|
|
|
@@ -483,13 +485,8 @@ public class dispatch extends Controller {
|
|
|
@CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class, cashbill.class})
|
|
|
public String unclose() throws YosException {
|
|
|
Long sa_dispatchid = content.getLong("sa_dispatchid");
|
|
|
- //通过版本更新发货单表头数据
|
|
|
- Dispatch.updateDispatchWithVersion(this);
|
|
|
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 cast(sa_dispatch_itemsid AS CHAR) as sa_dispatch_itemsid from sa_dispatch_items where sa_dispatchid ='"
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select sa_dispatchid,status,billno,sa_orderid,sys_enterpriseid from sa_dispatch where sa_dispatchid ='"
|
|
|
+ sa_dispatchid + "' and siteid='" + siteid + "'");
|
|
|
if (rows.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("该发货单不存在")
|
|
@@ -501,73 +498,32 @@ public class dispatch extends Controller {
|
|
|
.toString();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- 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 = new JSONArray();
|
|
|
- if (isJSONArray(result)) {
|
|
|
- jsonArray = JSONArray.parseArray(result);
|
|
|
- } else {
|
|
|
- return getErrReturnObject().setErrMsg("与中间表连接异常")
|
|
|
- .toString();
|
|
|
- }
|
|
|
- if (!jsonArray.isEmpty()) {
|
|
|
- return getErrReturnObject().setErrMsg("中间表存在未同步的销售出库单,无法手工关闭")
|
|
|
- .toString();
|
|
|
- }
|
|
|
- //
|
|
|
- JSONObject object1 = new JSONObject();
|
|
|
- object1.put("classname", "getIcinvbal");
|
|
|
- object1.put("method", "canCloseSainvoiceByHand");
|
|
|
-
|
|
|
- JSONObject content1 = new JSONObject();
|
|
|
- content1.put("billno", rows.get(0).getString("billno"));
|
|
|
- object1.put("content", content1);
|
|
|
-
|
|
|
- String canCloseSainvoiceByHand = request.doPost(object1.toString(),
|
|
|
- "http://60.190.151.198:8089/BYESB/jaxrs/webclientrest");
|
|
|
-
|
|
|
- if (!canCloseSainvoiceByHand.equals("true")) {
|
|
|
- return getErrReturnObject().setErrMsg("中间表状态不为1,无法手工关闭")
|
|
|
- .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);
|
|
|
-// }
|
|
|
-// }
|
|
|
+ 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 + ")");
|
|
|
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);
|
|
|
+ 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 ifnull(isclose,0)=0 and t1.sa_dispatchid=" + sa_dispatchid);
|
|
|
+ Rows rowsDispatchDetailGroup = dbConnect.runSqlQuery("select sum(t1.qty) qty, sum(t1.outwarehouseqty) outwarehouseqty,t1.sa_orderitemsid,t1.siteid from sa_dispatch_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where ifnull(isclose,0)=0 and t1.sa_dispatchid=" + sa_dispatchid + " group by t1.sa_orderitemsid,t1.siteid");
|
|
|
if (!rowsDispatchDetail.isEmpty()) {
|
|
|
- for (Row row : rowsDispatchDetail) {
|
|
|
+ for (Row row : rowsDispatchDetailGroup) {
|
|
|
// if(rowsMap.get(row.getLong("sa_orderitemsid")).isEmpty()) {
|
|
|
// return getErrReturnObject().setErrMsg("行号为:【" + row.getString("rowno") + "】的发货单明细不存在对应得订单行,无法审核")
|
|
|
// .toString();
|
|
@@ -591,17 +547,7 @@ public class dispatch extends Controller {
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_dispatch", sa_dispatchid, "手工关闭", "发货单手工关闭成功").getSQL());
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
|
- JSONObject objectfeek = new JSONObject();
|
|
|
- objectfeek.put("classname", "getIcinvbal");
|
|
|
- objectfeek.put("method", "updateSainvoiceStatus");
|
|
|
-
|
|
|
- JSONObject contentfeek = new JSONObject();
|
|
|
- contentfeek.put("billno", rows.get(0).getString("billno"));
|
|
|
- objectfeek.put("content", contentfeek);
|
|
|
-
|
|
|
- request.doPost(objectfeek.toString(),
|
|
|
- "http://60.190.151.198:8089/BYESB/jaxrs/webclientrest");
|
|
|
-
|
|
|
+ sendRemind(rows.get(0).getLong("sys_enterpriseid"), sa_dispatchid);
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
@@ -721,9 +667,6 @@ public class dispatch extends Controller {
|
|
|
@API(title = "复核", apiversion = R.ID20221114135803.v1.class)
|
|
|
@CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class, cashbill.class})
|
|
|
public String recheck() throws YosException {
|
|
|
- //通过版本更新发货单表头数据
|
|
|
- Dispatch.updateDispatchWithVersion(this);
|
|
|
-
|
|
|
Long sa_dispatchid = content.getLong("sa_dispatchid");
|
|
|
Rows dispatchRows = dbConnect.runSqlQuery("select sa_dispatchid,status,billno,sa_orderid from sa_dispatch where sa_dispatchid ='"
|
|
|
+ sa_dispatchid + "' and siteid='" + siteid + "'");
|
|
@@ -740,76 +683,50 @@ 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,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);
|
|
|
-
|
|
|
+ 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 rowsDispatchDetailGroup = dbConnect.runSqlQuery("select sum(t1.qty) qty,t1.sa_orderitemsid,t1.siteid 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");
|
|
|
+ Rows rowsDispatchAllDetail = dbConnect.runSqlQuery("select sum(t1.outwarehouseqty) sumoutwarehouseqty,t1.sa_orderitemsid 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 in('复核','关闭','手工关闭') group by t1.sa_orderitemsid");
|
|
|
+ RowsMap rowsDispatchAllDetailMap = rowsDispatchAllDetail.toRowsMap("sa_orderitemsid");
|
|
|
|
|
|
- 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");
|
|
|
+ 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");
|
|
|
|
|
|
- JSONObject object = new JSONObject();
|
|
|
- object.put("classname", "getIcinvbal");
|
|
|
- object.put("method", "getMsg");
|
|
|
+ if (!rowscurrentDispatchDetail.isEmpty()) {
|
|
|
+ for (Row row : rowscurrentDispatchDetail) {
|
|
|
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (Parameter.get(siteid, "dispatchinstock").equals("1")) {
|
|
|
- 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") + ",库存不足,无法操作复核!")
|
|
|
+ if (row.getBigDecimal("qty").compareTo(rowsMap.get(row.getString("sa_orderitemsid")).get(0).getBigDecimal("undeliqty")) == 1) {
|
|
|
+ return getErrReturnObject().setErrMsg("【" + row.getString("itemno") + "】的发货单明细的发货数量超过未发量,无法复核")
|
|
|
.toString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if (!rowsDispatchDetail.isEmpty()) {
|
|
|
for (Row row : rowsDispatchDetail) {
|
|
|
if (rowsMap.get(row.getString("sa_orderitemsid")).isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("行号为:【" + row.getString("rowno") + "】的发货单明细不存在对应得订单行,无法复核")
|
|
|
.toString();
|
|
|
}
|
|
|
+ if (row.getBigDecimal("qty").compareTo(BigDecimal.ZERO) != 1) {
|
|
|
+ return getErrReturnObject().setErrMsg("行号为:【" + row.getString("rowno") + "】的发货单明细的数量小于等于0,无法复核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
if (row.getBigDecimal("qty").compareTo(rowsMap.get(row.getString("sa_orderitemsid")).get(0).getBigDecimal("undeliqty")) == 1) {
|
|
|
return getErrReturnObject().setErrMsg("行号为:【" + row.getString("rowno") + "】的发货单明细的数量大于对应订单行的未发货数量,无法复核")
|
|
|
.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"));
|
|
|
+
|
|
|
+ if (!rowsDispatchAllDetailMap.get(row.getString("sa_orderitemsid")).isEmpty()) {
|
|
|
+ if ((row.getBigDecimal("qty").add(rowsDispatchAllDetailMap.get(row.getString("sa_orderitemsid")).get(0).getBigDecimal("sumoutwarehouseqty"))).compareTo(rowsMap.get(row.getString("sa_orderitemsid")).get(0).getBigDecimal("qty")) == 1) {
|
|
|
+ return getErrReturnObject().setErrMsg("行号为:【" + row.getString("rowno") + "】的发货单明细的总出库数量大于对应订单行的数量,无法复核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //logger.info(new Date() +"复核测试:"+"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"));
|
|
|
+ //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 ='"
|
|
@@ -819,33 +736,37 @@ public class dispatch extends Controller {
|
|
|
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();
|
|
|
- result = erpDocking.createErpSainvoice(rows.get(0), rowsdetail, this, sa_dispatchid);
|
|
|
+ String result = erpDocking.createErpSainvoice(rows.get(0), rowsdetail, this, sa_dispatchid);
|
|
|
if (!result.equals("true")) {
|
|
|
System.out.println(result);
|
|
|
return getErrReturnObject().setErrMsg(result).toString();
|
|
|
}
|
|
|
}
|
|
|
+ //对接erp成功后统一更新订单数量
|
|
|
+ for (Row row : rowsDispatchDetailGroup) {
|
|
|
+ logger.info(new Date() + "复核测试:" + "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"));
|
|
|
+ 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"));
|
|
|
+ }
|
|
|
|
|
|
- //判断当前订单是否已发完货,如果发完,则生把订单变为关闭状态
|
|
|
- //总数量
|
|
|
- Rows totalRows = dbConnect.runSqlQuery("select count(1) count,sa_orderid from sa_orderitems where siteid='" + siteid + "' group by sa_orderid");
|
|
|
- RowsMap totalRowsMap=totalRows.toRowsMap("sa_orderid");
|
|
|
- //已发完数量
|
|
|
- Rows deliRows = dbConnect.runSqlQuery("select count(1) count,sa_orderid from sa_orderitems where undeliqty=0 and siteid='" + siteid + "' group by sa_orderid");
|
|
|
- RowsMap deliRowsMap=deliRows.toRowsMap("sa_orderid");
|
|
|
- for (Row row:orderRows) {
|
|
|
- if(totalRowsMap.containsKey(row.getString("sa_orderid")) && deliRowsMap.containsKey(row.getString("sa_orderid"))){
|
|
|
- if (totalRowsMap.get(row.getString("sa_orderid")).get(0).getLong("count") ==deliRowsMap.get(row.getString("sa_orderid")).get(0).getLong("count")) {
|
|
|
- dbConnect.runSqlUpdate("update sa_order set status='关闭' where sa_orderid=" + row.getLong("sa_orderid") + " and siteid='" + siteid + "'");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- Executor.sendEml(this, "dispatchreccheck", sa_dispatchid, siteid);
|
|
|
+
|
|
|
+// //判断当前订单是否已发完货,如果发完,则生把订单变为关闭状态
|
|
|
+// //总数量
|
|
|
+// Rows totalRows = dbConnect.runSqlQuery("select count(1) count,sa_orderid from sa_orderitems where siteid='" + siteid + "' group by sa_orderid");
|
|
|
+// RowsMap totalRowsMap=totalRows.toRowsMap("sa_orderid");
|
|
|
+// //已发完数量
|
|
|
+// Rows deliRows = dbConnect.runSqlQuery("select count(1) count,sa_orderid from sa_orderitems where undeliqty=0 and siteid='" + siteid + "' group by sa_orderid");
|
|
|
+// RowsMap deliRowsMap=deliRows.toRowsMap("sa_orderid");
|
|
|
+// for (Row row:orderRows) {
|
|
|
+// if(totalRowsMap.containsKey(row.getString("sa_orderid")) && deliRowsMap.containsKey(row.getString("sa_orderid"))){
|
|
|
+// if (totalRowsMap.get(row.getString("sa_orderid")).get(0).getLong("count") ==deliRowsMap.get(row.getString("sa_orderid")).get(0).getLong("count")) {
|
|
|
+// dbConnect.runSqlUpdate("update sa_order set status='关闭' where sa_orderid=" + row.getLong("sa_orderid") + " and siteid='" + siteid + "'");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// Executor.sendEml(this, "dispatchreccheck", sa_dispatchid,new ArrayList<>());
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_dispatch", sa_dispatchid, "复核", "发货单复核成功").getSQL());
|
|
|
|
|
|
sqlFactoryupdate.addParameter("siteid", siteid);
|
|
@@ -1032,4 +953,11 @@ public class dispatch extends Controller {
|
|
|
Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
+
|
|
|
+ private void sendRemind(Long sys_enterpriseid, Long sa_dispatchid) throws YosException {
|
|
|
+ Rows rows1 = dbConnect.runSqlQuery("select userid from sys_enterprise_hr where siteid='" + siteid + "' and sys_enterpriseid=" + sys_enterpriseid);
|
|
|
+ HashMap<String, Object> extradata = new HashMap<>();
|
|
|
+ extradata.put("extraUserList", rows1.toArrayList("userid", new ArrayList<Long>()));
|
|
|
+ Executor.sendEml(this, "dispatch_close", sa_dispatchid, siteid, extradata);
|
|
|
+ }
|
|
|
}
|