|
@@ -1,6 +1,9 @@
|
|
|
package restcontroller.webmanage.sale.logistics;
|
|
package restcontroller.webmanage.sale.logistics;
|
|
|
|
|
|
|
|
import beans.datacontrllog.DataContrlLog;
|
|
import beans.datacontrllog.DataContrlLog;
|
|
|
|
|
+import beans.order.Order;
|
|
|
|
|
+import beans.parameter.Parameter;
|
|
|
|
|
+import beans.remind.Remind;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.huaweicloud.sdk.meeting.v1.model.SearchQosHistoryMeetingsRequest;
|
|
import com.huaweicloud.sdk.meeting.v1.model.SearchQosHistoryMeetingsRequest;
|
|
@@ -9,10 +12,7 @@ import common.YosException;
|
|
|
import common.annotation.API;
|
|
import common.annotation.API;
|
|
|
import common.annotation.CACHEING;
|
|
import common.annotation.CACHEING;
|
|
|
import common.annotation.CACHEING_CLEAN;
|
|
import common.annotation.CACHEING_CLEAN;
|
|
|
-import common.data.QuerySQL;
|
|
|
|
|
-import common.data.Row;
|
|
|
|
|
-import common.data.Rows;
|
|
|
|
|
-import common.data.SQLFactory;
|
|
|
|
|
|
|
+import common.data.*;
|
|
|
import restcontroller.R;
|
|
import restcontroller.R;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
@@ -186,6 +186,7 @@ public class LSALogistics extends Controller {
|
|
|
"billno");
|
|
"billno");
|
|
|
querySQL.setWhere("t1.siteid='" + siteid + "'");
|
|
querySQL.setWhere("t1.siteid='" + siteid + "'");
|
|
|
querySQL.setWhere("t2.sys_enterpriseid=" + sys_enterpriseid);
|
|
querySQL.setWhere("t2.sys_enterpriseid=" + sys_enterpriseid);
|
|
|
|
|
+ querySQL.setWhere("t2.status='审核'");
|
|
|
querySQL.setWhere("t1.transportqty<qty");
|
|
querySQL.setWhere("t1.transportqty<qty");
|
|
|
querySQL.setWhere("NOT EXISTS(SELECT 1 from sa_logistics_items WHERE sa_logisticsid=" + sa_logisticsid + " and st_stockbill_itemsid=t1.st_stockbill_itemsid)");
|
|
querySQL.setWhere("NOT EXISTS(SELECT 1 from sa_logistics_items WHERE sa_logisticsid=" + sa_logisticsid + " and st_stockbill_itemsid=t1.st_stockbill_itemsid)");
|
|
|
querySQL.setWhere(where.toString());
|
|
querySQL.setWhere(where.toString());
|
|
@@ -301,4 +302,86 @@ public class LSALogistics extends Controller {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //TODO 审核时必填字段?
|
|
|
|
|
+ @API(title = "审核、反审核", apiversion = R.ID20230721110502.v1.class)
|
|
|
|
|
+ @CACHEING_CLEAN(apiversions = {R.ID20221122132804.v1.class, R.ID20221122133004.v1.class, R.ID20221114135303.v1.class, R.ID20230219093203.v1.class})
|
|
|
|
|
+ public String checkOrUncheck() throws YosException {
|
|
|
|
|
+ Long sa_logisticsid = content.getLong("sa_logisticsid");
|
|
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ Rows rows = LSALogisticsHelper.getLogisticsRows(this);
|
|
|
|
|
+ if (rows.isEmpty()) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("请选择物流单").toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ Row logisticsRow = rows.get(0);
|
|
|
|
|
+ String billno = logisticsRow.getString("billno");
|
|
|
|
|
+ String status = logisticsRow.getString("status");
|
|
|
|
|
+ if ("收货".equals(status)) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("该物流单为收货状态,无法审核与反审核").toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "物流单审核");
|
|
|
|
|
+ if (status.equals("审核")) {
|
|
|
|
|
+ sqlFactory = new SQLFactory(this, "物流单反审核");
|
|
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_logistics", sa_logisticsid, "反审核", "反审核:" + sa_logisticsid).getSQL());
|
|
|
|
|
+ Rows itemsrows = dbConnect.runSqlQuery("SELECT * from sa_logistics_items WHERE sa_logisticsid=" + sa_logisticsid + " and siteid='" + siteid + "'");
|
|
|
|
|
+ for (Row item : itemsrows) {
|
|
|
|
|
+ Long st_stockbill_itemsid = item.getLong("st_stockbill_itemsid");
|
|
|
|
|
+ BigDecimal qty = item.getBigDecimal("qty");
|
|
|
|
|
+ sqlList.add("UPDATE st_stockbill_items SET transportqty=transportqty-" + qty + " WHERE st_stockbill_itemsid=" + st_stockbill_itemsid + " and siteid='" + siteid + "'");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (status.equals("新建")) {
|
|
|
|
|
+
|
|
|
|
|
+ Rows itemsrows = dbConnect.runSqlQuery("SELECT * from sa_logistics_items WHERE sa_logisticsid=" + sa_logisticsid + " and siteid='" + siteid + "'");
|
|
|
|
|
+ for (Row item : itemsrows) {
|
|
|
|
|
+ Long st_stockbill_itemsid = item.getLong("st_stockbill_itemsid");
|
|
|
|
|
+ BigDecimal qty = item.getBigDecimal("qty");
|
|
|
|
|
+ if (isOut(this, st_stockbill_itemsid, qty)) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("超出最大可送货数量").toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlList.add("UPDATE st_stockbill_items SET transportqty=transportqty+" + qty + " WHERE st_stockbill_itemsid=" + st_stockbill_itemsid + " and siteid='" + siteid + "'");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_logistics", sa_logisticsid, "审核", "审核:" + sa_logisticsid).getSQL());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Rows dispatchRows = dbConnect.runSqlQuery("SELECT sa_orderid FROM st_stockbill_items t1 INNER JOIN sa_logistics_items t2 ON t2.st_stockbill_itemsid=t1.st_stockbill_itemsid AND t2.siteid=t1.siteid WHERE t2.sa_logisticsid=" + sa_logisticsid + " AND t2.siteid='" + siteid + "'");
|
|
|
|
|
+ Long sa_orderid = 0L;
|
|
|
|
|
+ if (dispatchRows.isNotEmpty()) {
|
|
|
|
|
+ sa_orderid = dispatchRows.get(0).getLong("sa_orderid");
|
|
|
|
|
+ }
|
|
|
|
|
+ String sonum = "";
|
|
|
|
|
+ Rows orderRows = Order.getOrderRows(this, sa_orderid);
|
|
|
|
|
+ Long sys_enterpriseid = 0L;
|
|
|
|
|
+ if (orderRows.isNotEmpty()) {
|
|
|
|
|
+ sonum = orderRows.get(0).getString("sonum");
|
|
|
|
|
+ sys_enterpriseid = orderRows.get(0).getLong("sys_enterpriseid");
|
|
|
|
|
+ }
|
|
|
|
|
+ sendMsg("您的订单【" + sonum + "】已发货,物流单号【" + billno + "】 !", sa_orderid, sys_enterpriseid);
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlFactory.addParameter("userid", userid);
|
|
|
|
|
+ sqlFactory.addParameter("username", username);
|
|
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
|
|
+ sqlFactory.addParameter("sa_logisticsid", sa_logisticsid);
|
|
|
|
|
+ sqlList.add(sqlFactory.getSQL());
|
|
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
+ return getSucReturnObject().toString();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void sendMsg(String content, Long sa_orderid, Long sys_enterpriseid) throws YosException {
|
|
|
|
|
+
|
|
|
|
|
+ ArrayList<Long> userList = getEnterpriseHrs(sys_enterpriseid).toArrayList("userid", new ArrayList<>());
|
|
|
|
|
+ Remind remind = new Remind(this);
|
|
|
|
|
+ remind.setTitle("物流消息");
|
|
|
|
|
+ remind.setContent(content);
|
|
|
|
|
+ remind.setType("应用");
|
|
|
|
|
+ remind.setObjectid(sa_orderid);
|
|
|
|
|
+ remind.setObjectname("sa_order");
|
|
|
|
|
+ remind.setTouserid(userList);
|
|
|
|
|
+ remind.createSys_message();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|