|
@@ -12,10 +12,8 @@ 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.Row;
|
|
|
|
|
-import common.data.Rows;
|
|
|
|
|
-import common.data.RowsMap;
|
|
|
|
|
-import common.data.SQLFactory;
|
|
|
|
|
|
|
+import common.annotation.QUERYBYROWINDEX;
|
|
|
|
|
+import common.data.*;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.log4j.Logger;
|
|
import org.apache.log4j.Logger;
|
|
|
import restcontroller.R;
|
|
import restcontroller.R;
|
|
@@ -37,13 +35,14 @@ import static java.time.LocalDate.now;
|
|
|
@API(title = "发货单")
|
|
@API(title = "发货单")
|
|
|
public class dispatch extends Controller {
|
|
public class dispatch extends Controller {
|
|
|
private static Logger logger = Logger.getLogger(dispatch.class);
|
|
private static Logger logger = Logger.getLogger(dispatch.class);
|
|
|
|
|
+
|
|
|
public dispatch(JSONObject arg0) throws YosException {
|
|
public dispatch(JSONObject arg0) throws YosException {
|
|
|
super(arg0);
|
|
super(arg0);
|
|
|
// TODO Auto-generated constructor stub
|
|
// TODO Auto-generated constructor stub
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- @API(title = "发货单新增更新", apiversion = R.ID20221114135203.v1.class,intervaltime = 200)
|
|
|
|
|
|
|
+ @API(title = "发货单新增更新", apiversion = R.ID20221114135203.v1.class, intervaltime = 200)
|
|
|
@CACHEING_CLEAN(apiversions = {R.ID20221114135303.v1.class, R.ID20221114135403.v1.class, R.ID20230320160203.v1.class})
|
|
@CACHEING_CLEAN(apiversions = {R.ID20221114135303.v1.class, R.ID20221114135403.v1.class, R.ID20230320160203.v1.class})
|
|
|
public String insertormodify_dispatch() throws YosException {
|
|
public String insertormodify_dispatch() throws YosException {
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
@@ -69,19 +68,19 @@ public class dispatch extends Controller {
|
|
|
}
|
|
}
|
|
|
sqlFactory.addParameter("sa_orderid", sa_orderid);
|
|
sqlFactory.addParameter("sa_orderid", sa_orderid);
|
|
|
// 订货企业id
|
|
// 订货企业id
|
|
|
- sqlFactory.addParameter("sys_enterpriseid",content.getLong("sys_enterpriseid"));
|
|
|
|
|
|
|
+ sqlFactory.addParameter("sys_enterpriseid", content.getLong("sys_enterpriseid"));
|
|
|
// 物流公司档案ID
|
|
// 物流公司档案ID
|
|
|
//sqlFactory.addParameter("sa_logiscompid", rowsinfo.get(0).getLong("sa_logiscompid"));
|
|
//sqlFactory.addParameter("sa_logiscompid", rowsinfo.get(0).getLong("sa_logiscompid"));
|
|
|
// 合作企业联系人表ID(收货信息)
|
|
// 合作企业联系人表ID(收货信息)
|
|
|
- if(!rowsinfo.isEmpty()){
|
|
|
|
|
|
|
+ if (!rowsinfo.isEmpty()) {
|
|
|
sqlFactory.addParameter("rec_contactsid", rowsinfo.get(0).getLong("contactsid"));
|
|
sqlFactory.addParameter("rec_contactsid", rowsinfo.get(0).getLong("contactsid"));
|
|
|
- }else {
|
|
|
|
|
- sqlFactory.addParameter("rec_contactsid",0);
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sqlFactory.addParameter("rec_contactsid", 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//运费状态
|
|
//运费状态
|
|
|
- sqlFactory.addParameter("freightstatus","");
|
|
|
|
|
- sqlFactory.addParameter("remarks",remarks);
|
|
|
|
|
|
|
+ sqlFactory.addParameter("freightstatus", "");
|
|
|
|
|
+ sqlFactory.addParameter("remarks", remarks);
|
|
|
sqlFactory.addParameter("billdate", now());
|
|
sqlFactory.addParameter("billdate", now());
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_dispatch", sa_dispatchid, "新增", "发货单新增成功").getSQL());
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_dispatch", sa_dispatchid, "新增", "发货单新增成功").getSQL());
|
|
|
} else {
|
|
} else {
|
|
@@ -163,6 +162,7 @@ public class dispatch extends Controller {
|
|
|
|
|
|
|
|
@API(title = "发货单详情", apiversion = R.ID20221114135303.v1.class)
|
|
@API(title = "发货单详情", apiversion = R.ID20221114135303.v1.class)
|
|
|
@CACHEING
|
|
@CACHEING
|
|
|
|
|
+ @QUERYBYROWINDEX(uniquecolumnname = "sa_orderid", listapiversion = {R.ID20221205111302.v1.class, R.ID20221114135403.v1.class})
|
|
|
public String queryDispatchMain() throws YosException {
|
|
public String queryDispatchMain() throws YosException {
|
|
|
Long sa_dispatchid = content.getLong("sa_dispatchid");
|
|
Long sa_dispatchid = content.getLong("sa_dispatchid");
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "发货单详情查询");
|
|
SQLFactory sqlFactory = new SQLFactory(this, "发货单详情查询");
|
|
@@ -225,29 +225,33 @@ public class dispatch extends Controller {
|
|
|
where.append(")");
|
|
where.append(")");
|
|
|
}
|
|
}
|
|
|
if (whereObject.containsKey("param") && !"".equals(whereObject.getString("param"))) {
|
|
if (whereObject.containsKey("param") && !"".equals(whereObject.getString("param"))) {
|
|
|
- Rows rowsDispatchid = dbConnect.runSqlQuery("select t1.sa_dispatchid 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.siteid='"+siteid+"' and (t4.itemname like '%"+whereObject.getString("param")+"%' or t4.itemno like '%"+whereObject.getString("param")+"%' or t3.sonum='"+whereObject.getString("param")+"')");
|
|
|
|
|
|
|
+ Rows rowsDispatchid = dbConnect.runSqlQuery("select t1.sa_dispatchid 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.siteid='" + siteid + "' and (t4.itemname like '%" + whereObject.getString("param") + "%' or t4.itemno like '%" + whereObject.getString("param") + "%' or t3.sonum='" + whereObject.getString("param") + "')");
|
|
|
|
|
|
|
|
- if(rowsDispatchid.toJsonArray("sa_dispatchid").isEmpty()){
|
|
|
|
|
- where.append(" and t1.sa_dispatchid in (0)");
|
|
|
|
|
- }else {
|
|
|
|
|
- String str = rowsDispatchid.toJsonArray("sa_dispatchid").toJSONString();
|
|
|
|
|
- str = str.replace("[", "(").replace("]", ")");
|
|
|
|
|
- where.append(" and t1.sa_dispatchid in" ).append(str);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (rowsDispatchid.toJsonArray("sa_dispatchid").isEmpty()) {
|
|
|
|
|
+ where.append(" and t1.sa_dispatchid in (0)");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ String str = rowsDispatchid.toJsonArray("sa_dispatchid").toJSONString();
|
|
|
|
|
+ str = str.replace("[", "(").replace("]", ")");
|
|
|
|
|
+ where.append(" and t1.sa_dispatchid in").append(str);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "发货单列表查询", pageSize, pageNumber, pageSorting);
|
|
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
|
|
- sqlFactory.addParameter_SQL("where", where);
|
|
|
|
|
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
|
|
-
|
|
|
|
|
|
|
+// SQLFactory sqlFactory = new SQLFactory(this, "发货单列表查询", pageSize, pageNumber, pageSorting);
|
|
|
|
|
+// sqlFactory.addParameter("siteid", siteid);
|
|
|
|
|
+// sqlFactory.addParameter_SQL("where", where);
|
|
|
|
|
+// Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
|
|
+ QuerySQL querySQL = queryDispatchList(where.toString());
|
|
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
|
|
+ querySQL.setOrderBy(pageSorting);
|
|
|
|
|
+ Rows rows = querySQL.query();
|
|
|
|
|
+
|
|
|
ArrayList<Long> ids = rows.toArrayList("sa_dispatchid", new ArrayList<>());
|
|
ArrayList<Long> ids = rows.toArrayList("sa_dispatchid", new ArrayList<>());
|
|
|
//查询数量金额
|
|
//查询数量金额
|
|
|
RowsMap dispatchAmountRowsMap = Dispatch.getDispatchAmountAndQty(this, ids);
|
|
RowsMap dispatchAmountRowsMap = Dispatch.getDispatchAmountAndQty(this, ids);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for (Row row : rows) {
|
|
for (Row row : rows) {
|
|
|
Long id = row.getLong("sa_dispatchid");
|
|
Long id = row.getLong("sa_dispatchid");
|
|
|
if (dispatchAmountRowsMap.get(id.toString()).isNotEmpty()) {
|
|
if (dispatchAmountRowsMap.get(id.toString()).isNotEmpty()) {
|
|
@@ -260,11 +264,32 @@ public class dispatch extends Controller {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //查询发货单列表
|
|
|
|
|
+ public QuerySQL queryDispatchList(String where) throws YosException {
|
|
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_dispatch");
|
|
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.sys_enterpriseid = t2.sys_enterpriseid AND t1.siteid = t2.siteid",
|
|
|
|
|
+ "enterprisename", "abbreviation");
|
|
|
|
|
+ querySQL.addQueryFields("enterprisephonenumber", "t2.phonenumber");
|
|
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_order", "t3", "t1.sa_orderid = t3.sa_orderid AND t1.siteid = t3.siteid");
|
|
|
|
|
+ querySQL.addQueryFields("projectname", "case when t3.type='项目订单' then t9.projectname else t3.projectnote end ");
|
|
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_contacts", "t5", "t1.rec_contactsid = t5.contactsid AND t1.siteid = t5.siteid",
|
|
|
|
|
+ "province", "city", "county", "address");
|
|
|
|
|
+ querySQL.addQueryFields("contactsphonenumber", "t5.phonenumber");
|
|
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t7", "t7.sys_enterpriseid = t1.sys_enterpriseid AND t1.siteid = t7.siteid",
|
|
|
|
|
+ "agentnum");
|
|
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t8", "t8.ownertable = 'sa_dispatch' and t8.ownerid = t1.sa_dispatchid AND t1.siteid = t8.siteid",
|
|
|
|
|
+ "erpbillno");
|
|
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_project", "t9", "t9.sa_projectid = t3.sa_projectid AND t9.siteid = t3.siteid");
|
|
|
|
|
+ querySQL.setWhere("t1.siteid", siteid);
|
|
|
|
|
+ querySQL.setWhere(where);
|
|
|
|
|
+ return querySQL;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@API(title = "经销商列表查询(管理端)", apiversion = R.ID20230324125803.v1.class)
|
|
@API(title = "经销商列表查询(管理端)", apiversion = R.ID20230324125803.v1.class)
|
|
|
public String query_agentList() throws YosException {
|
|
public String query_agentList() throws YosException {
|
|
|
|
|
|
|
@@ -291,6 +316,7 @@ public class dispatch extends Controller {
|
|
|
|
|
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
@API(title = "删除", apiversion = R.ID20221114135503.v1.class)
|
|
@API(title = "删除", apiversion = R.ID20221114135503.v1.class)
|
|
|
@CACHEING_CLEAN(apiversions = {R.ID20221114135303.v1.class, R.ID20221114135403.v1.class, R.ID20230320160203.v1.class})
|
|
@CACHEING_CLEAN(apiversions = {R.ID20221114135303.v1.class, R.ID20221114135403.v1.class, R.ID20230320160203.v1.class})
|
|
|
public String delete() throws YosException {
|
|
public String delete() throws YosException {
|
|
@@ -305,15 +331,15 @@ public class dispatch extends Controller {
|
|
|
Rows logisticsRows = dbConnect.runSqlQuery("select * from sa_logistics_items where siteid='"
|
|
Rows logisticsRows = dbConnect.runSqlQuery("select * from sa_logistics_items where siteid='"
|
|
|
+ siteid + "' and sa_dispatchid='" + sa_dispatchid + "'");
|
|
+ siteid + "' and sa_dispatchid='" + sa_dispatchid + "'");
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (RowsStatus.isNotEmpty()) {
|
|
if (RowsStatus.isNotEmpty()) {
|
|
|
if (!RowsStatus.get(0).getString("status").equals("新建")) {
|
|
if (!RowsStatus.get(0).getString("status").equals("新建")) {
|
|
|
batchDeleteErr.addErr(sa_dispatchid, "非新建状态的发货单无法删除");
|
|
batchDeleteErr.addErr(sa_dispatchid, "非新建状态的发货单无法删除");
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(logisticsRows.isNotEmpty()) {
|
|
|
|
|
- batchDeleteErr.addErr(sa_dispatchid, "存在发货物流明细信息,无法删除");
|
|
|
|
|
|
|
+ if (logisticsRows.isNotEmpty()) {
|
|
|
|
|
+ batchDeleteErr.addErr(sa_dispatchid, "存在发货物流明细信息,无法删除");
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -324,7 +350,7 @@ public class dispatch extends Controller {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// @API(title = "审核", apiversion = R.ID20221114135603.v1.class)
|
|
|
|
|
|
|
+ // @API(title = "审核", apiversion = R.ID20221114135603.v1.class)
|
|
|
// @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class,cashbill.class})
|
|
// @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class,cashbill.class})
|
|
|
// public String check() throws YosException {
|
|
// public String check() throws YosException {
|
|
|
// Long sa_dispatchid = content.getLong("sa_dispatchid");
|
|
// Long sa_dispatchid = content.getLong("sa_dispatchid");
|
|
@@ -394,7 +420,7 @@ public class dispatch extends Controller {
|
|
|
|
|
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
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+")" );
|
|
|
|
|
|
|
+ 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");
|
|
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 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()) {
|
|
if (!rowsDispatchDetail.isEmpty()) {
|
|
@@ -422,7 +448,7 @@ public class dispatch extends Controller {
|
|
|
|
|
|
|
|
|
|
|
|
|
@API(title = "手工关闭", apiversion = R.ID20230404134703.v1.class)
|
|
@API(title = "手工关闭", apiversion = R.ID20230404134703.v1.class)
|
|
|
- @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class,cashbill.class})
|
|
|
|
|
|
|
+ @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class, cashbill.class})
|
|
|
public String unclose() throws YosException {
|
|
public String unclose() throws YosException {
|
|
|
Long sa_dispatchid = content.getLong("sa_dispatchid");
|
|
Long sa_dispatchid = content.getLong("sa_dispatchid");
|
|
|
Long sa_orderid = 0L;
|
|
Long sa_orderid = 0L;
|
|
@@ -440,17 +466,17 @@ public class dispatch extends Controller {
|
|
|
}
|
|
}
|
|
|
//对接erp生成erp发货单
|
|
//对接erp生成erp发货单
|
|
|
if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") && siteid.equalsIgnoreCase("ccyosg")) {
|
|
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")){
|
|
|
|
|
|
|
+ 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();
|
|
return getErrReturnObject().setErrMsg(result).toString();
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
JSONArray jsonArray = erpDocking.queryErpSainvoice(rows.get(0).getString("billno"));
|
|
JSONArray jsonArray = erpDocking.queryErpSainvoice(rows.get(0).getString("billno"));
|
|
|
ArrayList<String> dispatchsqlList = new ArrayList<>();
|
|
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+"'");
|
|
|
|
|
|
|
+ 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);
|
|
dbConnect.runSqlUpdate(dispatchsqlList);
|
|
@@ -458,7 +484,7 @@ public class dispatch extends Controller {
|
|
|
}
|
|
}
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
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+")" );
|
|
|
|
|
|
|
+ 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");
|
|
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 t1.sa_dispatchid=" + sa_dispatchid);
|
|
|
if (!rowsDispatchDetail.isEmpty()) {
|
|
if (!rowsDispatchDetail.isEmpty()) {
|
|
@@ -474,8 +500,8 @@ public class dispatch extends Controller {
|
|
|
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"));
|
|
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"));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- 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);
|
|
|
|
|
- for (Row row:orderRows) {
|
|
|
|
|
|
|
+ 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);
|
|
|
|
|
+ for (Row row : orderRows) {
|
|
|
sqlList.add("update sa_order set status='审核' where sa_orderid=" + row.getLong("sa_orderid") + " and siteid='" + siteid + "'");
|
|
sqlList.add("update sa_order set status='审核' where sa_orderid=" + row.getLong("sa_orderid") + " and siteid='" + siteid + "'");
|
|
|
}
|
|
}
|
|
|
SQLFactory sqlFactoryupdate = new SQLFactory(this, "发货单关闭");
|
|
SQLFactory sqlFactoryupdate = new SQLFactory(this, "发货单关闭");
|
|
@@ -490,15 +516,15 @@ public class dispatch extends Controller {
|
|
|
|
|
|
|
|
|
|
|
|
|
@API(title = "行关闭", apiversion = R.ID20230522093703.v1.class)
|
|
@API(title = "行关闭", apiversion = R.ID20230522093703.v1.class)
|
|
|
- @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class,cashbill.class})
|
|
|
|
|
|
|
+ @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class, cashbill.class})
|
|
|
public String closeRows() throws YosException {
|
|
public String closeRows() throws YosException {
|
|
|
JSONArray sa_dispatch_itemsids = content.getJSONArray("sa_dispatch_itemsids");
|
|
JSONArray sa_dispatch_itemsids = content.getJSONArray("sa_dispatch_itemsids");
|
|
|
BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_dispatch_itemsids.size());
|
|
BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_dispatch_itemsids.size());
|
|
|
- String sql ="";
|
|
|
|
|
- if(sa_dispatch_itemsids.size()>0){
|
|
|
|
|
- sql ="select t1.sa_dispatch_itemsid,t1.sa_orderitemsid,t1.qty,t1.outwarehouseqty,t1.sa_dispatchid,t1.rowno,t3.itemno,t2.billno,t2.status,t1.isclose from sa_dispatch_items t1 left join sa_dispatch t2 on t1.sa_dispatchid=t2.sa_dispatchid and t1.siteid=t2.siteid left join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where t1.sa_dispatch_itemsid in" + sa_dispatch_itemsids.toJSONString() + " and t1.siteid='" + siteid + "'";
|
|
|
|
|
|
|
+ String sql = "";
|
|
|
|
|
+ if (sa_dispatch_itemsids.size() > 0) {
|
|
|
|
|
+ sql = "select t1.sa_dispatch_itemsid,t1.sa_orderitemsid,t1.qty,t1.outwarehouseqty,t1.sa_dispatchid,t1.rowno,t3.itemno,t2.billno,t2.status,t1.isclose from sa_dispatch_items t1 left join sa_dispatch t2 on t1.sa_dispatchid=t2.sa_dispatchid and t1.siteid=t2.siteid left join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where t1.sa_dispatch_itemsid in" + sa_dispatch_itemsids.toJSONString() + " and t1.siteid='" + siteid + "'";
|
|
|
sql = sql.replace("[", "(").replace("]", ")");
|
|
sql = sql.replace("[", "(").replace("]", ")");
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
return getErrReturnObject().setErrMsg("请选择发货单行后,进行行关闭").toString();
|
|
return getErrReturnObject().setErrMsg("请选择发货单行后,进行行关闭").toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -513,40 +539,40 @@ public class dispatch extends Controller {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- String orderdetailSql="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_dispatch_itemsid in" + sa_dispatch_itemsids.toJSONString() + " )";
|
|
|
|
|
|
|
+ String orderdetailSql = "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_dispatch_itemsid in" + sa_dispatch_itemsids.toJSONString() + " )";
|
|
|
orderdetailSql = orderdetailSql.replace("[", "(").replace("]", ")");
|
|
orderdetailSql = orderdetailSql.replace("[", "(").replace("]", ")");
|
|
|
Rows rowsOrderDetail = dbConnect.runSqlQuery(orderdetailSql);
|
|
Rows rowsOrderDetail = dbConnect.runSqlQuery(orderdetailSql);
|
|
|
RowsMap rowsMap = rowsOrderDetail.toRowsMap("sa_orderitemsid");
|
|
RowsMap rowsMap = rowsOrderDetail.toRowsMap("sa_orderitemsid");
|
|
|
- for (Row row :rows) {
|
|
|
|
|
|
|
+ for (Row row : rows) {
|
|
|
//对接erp生成erp发货单
|
|
//对接erp生成erp发货单
|
|
|
- if(row.getBoolean("isclose")){
|
|
|
|
|
- batchDeleteErr.addErr(row.getLong("sa_dispatch_itemsid"), "第"+row.getString("rowno")+"行的发货单明细已关闭,请勿重复关闭");
|
|
|
|
|
|
|
+ if (row.getBoolean("isclose")) {
|
|
|
|
|
+ batchDeleteErr.addErr(row.getLong("sa_dispatch_itemsid"), "第" + row.getString("rowno") + "行的发货单明细已关闭,请勿重复关闭");
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") && siteid.equalsIgnoreCase("ccyosg")) {
|
|
if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") && siteid.equalsIgnoreCase("ccyosg")) {
|
|
|
- ERPDocking erpDocking =new ERPDocking();
|
|
|
|
|
- String result =erpDocking.closeErpSainvoiceRow(row.getString("billno"),this,row.getLong("rowno"),row.getString("itemno"),row.getLong("sa_dispatchid"));
|
|
|
|
|
- if(!result.equals("true")){
|
|
|
|
|
|
|
+ ERPDocking erpDocking = new ERPDocking();
|
|
|
|
|
+ String result = erpDocking.closeErpSainvoiceRow(row.getString("billno"), this, row.getLong("rowno"), row.getString("itemno"), row.getLong("sa_dispatchid"));
|
|
|
|
|
+ if (!result.equals("true")) {
|
|
|
batchDeleteErr.addErr(row.getLong("sa_dispatch_itemsid"), result);
|
|
batchDeleteErr.addErr(row.getLong("sa_dispatch_itemsid"), result);
|
|
|
continue;
|
|
continue;
|
|
|
- }else {
|
|
|
|
|
- sqlList.add("update sa_dispatch_items set isclose=1 where sa_dispatch_itemsid="+row.getLong("sa_dispatch_itemsid"));
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sqlList.add("update sa_dispatch_items set isclose=1 where sa_dispatch_itemsid=" + row.getLong("sa_dispatch_itemsid"));
|
|
|
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"));
|
|
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"));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
|
|
|
- Rows sumcountRows =dbConnect.runSqlQuery("select count(1) sumcount from sa_dispatch_items where sa_dispatchid="+rows.get(0).getLong("sa_dispatchid") +" and siteid='"+siteid+"'");
|
|
|
|
|
- Rows closecountRows =dbConnect.runSqlQuery("select count(1) closecount from sa_dispatch_items where sa_dispatchid="+rows.get(0).getLong("sa_dispatchid") +" and siteid='"+siteid+"' and isclose=1");
|
|
|
|
|
- if(sumcountRows.get(0).getLong("sumcount")==closecountRows.get(0).getLong("closecount")){
|
|
|
|
|
|
|
+ Rows sumcountRows = dbConnect.runSqlQuery("select count(1) sumcount from sa_dispatch_items where sa_dispatchid=" + rows.get(0).getLong("sa_dispatchid") + " and siteid='" + siteid + "'");
|
|
|
|
|
+ Rows closecountRows = dbConnect.runSqlQuery("select count(1) closecount from sa_dispatch_items where sa_dispatchid=" + rows.get(0).getLong("sa_dispatchid") + " and siteid='" + siteid + "' and isclose=1");
|
|
|
|
|
+ if (sumcountRows.get(0).getLong("sumcount") == closecountRows.get(0).getLong("closecount")) {
|
|
|
if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") && siteid.equalsIgnoreCase("ccyosg")) {
|
|
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,rows.get(0).getLong("sa_dispatchid"));
|
|
|
|
|
- if(!result.equals("true")){
|
|
|
|
|
|
|
+ ERPDocking erpDocking = new ERPDocking();
|
|
|
|
|
+ String result = erpDocking.closeErpSainvoice(rows.get(0).getString("billno"), true, this, rows.get(0).getLong("sa_dispatchid"));
|
|
|
|
|
+ if (!result.equals("true")) {
|
|
|
return getErrReturnObject().setErrMsg(result).toString();
|
|
return getErrReturnObject().setErrMsg(result).toString();
|
|
|
- }else {
|
|
|
|
|
- dbConnect.runSqlUpdate("update sa_dispatch set status='手工关闭',closeby='"+username+"',closedate=CURRENT_TIMESTAMP where sa_dispatchid="+rows.get(0).getLong("sa_dispatchid"));
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ dbConnect.runSqlUpdate("update sa_dispatch set status='手工关闭',closeby='" + username + "',closedate=CURRENT_TIMESTAMP where sa_dispatchid=" + rows.get(0).getLong("sa_dispatchid"));
|
|
|
dbConnect.runSqlUpdate(DataContrlLog.createLog(this, "sa_dispatch", rows.get(0).getLong("sa_dispatchid"), "手工关闭", "发货单手工关闭成功").getSQL());
|
|
dbConnect.runSqlUpdate(DataContrlLog.createLog(this, "sa_dispatch", rows.get(0).getLong("sa_dispatchid"), "手工关闭", "发货单手工关闭成功").getSQL());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -556,22 +582,22 @@ public class dispatch extends Controller {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- @API(title = "自动关闭(erp调用)", apiversion = R.ID20230413110103.v1.class,accesstoken = false)
|
|
|
|
|
- @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class,cashbill.class})
|
|
|
|
|
|
|
+ @API(title = "自动关闭(erp调用)", apiversion = R.ID20230413110103.v1.class, accesstoken = false)
|
|
|
|
|
+ @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class, cashbill.class})
|
|
|
public String autoClose() throws YosException {
|
|
public String autoClose() throws YosException {
|
|
|
String finvonum = content.getString("finvonum");
|
|
String finvonum = content.getString("finvonum");
|
|
|
|
|
|
|
|
- Rows rows = dbConnect.runSqlQuery("select * from sa_dispatch where status='复核' and siteid='CCYOSG' and billno='"+finvonum+"'");
|
|
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from sa_dispatch where status='复核' and siteid='CCYOSG' and billno='" + finvonum + "'");
|
|
|
Rows rowsdetail = dbConnect.runSqlQuery("select t1.* 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='复核' and t1.siteid='CCYOSG'");
|
|
Rows rowsdetail = dbConnect.runSqlQuery("select t1.* 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='复核' and t1.siteid='CCYOSG'");
|
|
|
RowsMap rowsMap = rowsdetail.toRowsMap("sa_dispatchid");
|
|
RowsMap rowsMap = rowsdetail.toRowsMap("sa_dispatchid");
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- ERPDocking erpDocking =new ERPDocking();
|
|
|
|
|
|
|
+ ERPDocking erpDocking = new ERPDocking();
|
|
|
for (Row row : rows) {
|
|
for (Row row : rows) {
|
|
|
String sa_dispatchid = row.getString("sa_dispatchid");
|
|
String sa_dispatchid = row.getString("sa_dispatchid");
|
|
|
String billno = row.getString("billno");
|
|
String billno = row.getString("billno");
|
|
|
- String result =erpDocking.closeErpSainvoice(billno,false,this, row.getLong("sa_dispatchid"));
|
|
|
|
|
- if(result.equals("true")){
|
|
|
|
|
- sqlList.add("update sa_dispatch set status='关闭' where sa_dispatchid='"+sa_dispatchid+"' and siteid='CCYOSG'");
|
|
|
|
|
|
|
+ String result = erpDocking.closeErpSainvoice(billno, false, this, row.getLong("sa_dispatchid"));
|
|
|
|
|
+ if (result.equals("true")) {
|
|
|
|
|
+ sqlList.add("update sa_dispatch set status='关闭' where sa_dispatchid='" + sa_dispatchid + "' and siteid='CCYOSG'");
|
|
|
SQLFactory sqlFactory = new SQLFactory(new DataContrlLog(), "数据操作日志新增");
|
|
SQLFactory sqlFactory = new SQLFactory(new DataContrlLog(), "数据操作日志新增");
|
|
|
sqlFactory.addParameter("ownertable", "sa_dispatch");
|
|
sqlFactory.addParameter("ownertable", "sa_dispatch");
|
|
|
sqlFactory.addParameter("ownerid", sa_dispatchid);
|
|
sqlFactory.addParameter("ownerid", sa_dispatchid);
|
|
@@ -581,15 +607,15 @@ public class dispatch extends Controller {
|
|
|
sqlFactory.addParameter("actionby", "admin");
|
|
sqlFactory.addParameter("actionby", "admin");
|
|
|
sqlFactory.addParameter("siteid", "CCYOSG");
|
|
sqlFactory.addParameter("siteid", "CCYOSG");
|
|
|
sqlList.add(sqlFactory.getSQL());
|
|
sqlList.add(sqlFactory.getSQL());
|
|
|
- }else {
|
|
|
|
|
- logger.info("发货单自动关闭错误:"+result);
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ logger.info("发货单自动关闭错误:" + result);
|
|
|
return getErrReturnObject().setErrMsg(result).toString();
|
|
return getErrReturnObject().setErrMsg(result).toString();
|
|
|
}
|
|
}
|
|
|
JSONArray jsonArray = erpDocking.queryErpSainvoice(billno);
|
|
JSONArray jsonArray = erpDocking.queryErpSainvoice(billno);
|
|
|
- if(!jsonArray.isEmpty()){
|
|
|
|
|
- for (Object object:jsonArray) {
|
|
|
|
|
- JSONObject jsonObject = (JSONObject)object;
|
|
|
|
|
- sqlList.add("update sa_dispatch_items set outwarehouseqty="+jsonObject.getBigDecimalValue("fqty1")+" where rowno ="+jsonObject.getIntValue("frownum")+" and sa_dispatchid='"+sa_dispatchid+"' and siteid='CCYOSG'");
|
|
|
|
|
|
|
+ if (!jsonArray.isEmpty()) {
|
|
|
|
|
+ for (Object object : jsonArray) {
|
|
|
|
|
+ JSONObject jsonObject = (JSONObject) object;
|
|
|
|
|
+ sqlList.add("update sa_dispatch_items set outwarehouseqty=" + jsonObject.getBigDecimalValue("fqty1") + " where rowno =" + jsonObject.getIntValue("frownum") + " and sa_dispatchid='" + sa_dispatchid + "' and siteid='CCYOSG'");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -599,7 +625,7 @@ public class dispatch extends Controller {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@API(title = "复核", apiversion = R.ID20221114135803.v1.class)
|
|
@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})
|
|
|
|
|
|
|
+ @CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, dispatch.class, dispatchItems.class, cashbill.class})
|
|
|
public String recheck() throws YosException {
|
|
public String recheck() throws YosException {
|
|
|
Long sa_dispatchid = content.getLong("sa_dispatchid");
|
|
Long sa_dispatchid = content.getLong("sa_dispatchid");
|
|
|
Rows dispatchRows = dbConnect.runSqlQuery("select sa_dispatchid,status,billno,sa_orderid from sa_dispatch where sa_dispatchid ='"
|
|
Rows dispatchRows = dbConnect.runSqlQuery("select sa_dispatchid,status,billno,sa_orderid from sa_dispatch where sa_dispatchid ='"
|
|
@@ -615,7 +641,7 @@ public class dispatch extends Controller {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
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+")" );
|
|
|
|
|
|
|
+ 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");
|
|
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 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()) {
|
|
if (!rowsDispatchDetail.isEmpty()) {
|
|
@@ -630,7 +656,7 @@ public class dispatch extends Controller {
|
|
|
}
|
|
}
|
|
|
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"));
|
|
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 {
|
|
|
|
|
|
|
+ } else {
|
|
|
return getErrReturnObject().setErrMsg("该发货单明细不存在,无法复核").toString();
|
|
return getErrReturnObject().setErrMsg("该发货单明细不存在,无法复核").toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -639,15 +665,15 @@ public class dispatch extends Controller {
|
|
|
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 ='"
|
|
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 + "'");
|
|
+ sa_dispatchid + "' and t1.siteid='" + siteid + "'");
|
|
|
SQLFactory sqlFactoryupdate = new SQLFactory(this, "发货单复核");
|
|
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发货单
|
|
//对接erp生成erp发货单
|
|
|
if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") && siteid.equalsIgnoreCase("ccyosg")) {
|
|
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")){
|
|
|
|
|
|
|
+ ERPDocking erpDocking = new ERPDocking();
|
|
|
|
|
+ String result = erpDocking.createErpSainvoice(rows.get(0), rowsdetail, this, sa_dispatchid);
|
|
|
|
|
+ if (!result.equals("true")) {
|
|
|
System.out.println(result);
|
|
System.out.println(result);
|
|
|
return getErrReturnObject().setErrMsg(result).toString();
|
|
return getErrReturnObject().setErrMsg(result).toString();
|
|
|
}
|
|
}
|
|
@@ -666,7 +692,7 @@ public class dispatch extends Controller {
|
|
|
// }
|
|
// }
|
|
|
// }
|
|
// }
|
|
|
// }
|
|
// }
|
|
|
- Executor.sendEml(this, "dispatchreccheck", sa_dispatchid,new ArrayList<>());
|
|
|
|
|
|
|
+ Executor.sendEml(this, "dispatchreccheck", sa_dispatchid, new ArrayList<>());
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_dispatch", sa_dispatchid, "复核", "发货单复核成功").getSQL());
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_dispatch", sa_dispatchid, "复核", "发货单复核成功").getSQL());
|
|
|
|
|
|
|
|
sqlFactoryupdate.addParameter("siteid", siteid);
|
|
sqlFactoryupdate.addParameter("siteid", siteid);
|
|
@@ -676,7 +702,7 @@ public class dispatch extends Controller {
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
|
|
|
Long sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
|
|
Long sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
|
|
|
- String message = "您的发货单"+rows.get(0).getString("billno")+"已复核,请及时查看!";
|
|
|
|
|
|
|
+ String message = "您的发货单" + rows.get(0).getString("billno") + "已复核,请及时查看!";
|
|
|
sendMsg(message, sa_dispatchid, sys_enterpriseid);
|
|
sendMsg(message, sa_dispatchid, sys_enterpriseid);
|
|
|
|
|
|
|
|
return getSucReturnObject().toString();
|
|
return getSucReturnObject().toString();
|
|
@@ -759,6 +785,7 @@ public class dispatch extends Controller {
|
|
|
content.put("sa_dispatchid", sa_dispatchid);
|
|
content.put("sa_dispatchid", sa_dispatchid);
|
|
|
return queryDispatchMain();
|
|
return queryDispatchMain();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
public void sendMsg(String content, Long sa_dispatchid, Long sys_enterpriseid) throws YosException {
|
|
public void sendMsg(String content, Long sa_dispatchid, Long sys_enterpriseid) throws YosException {
|
|
|
|
|
|
|
|
ArrayList<Long> userList = getEnterpriseHrs(sys_enterpriseid).toArrayList("userid", new ArrayList<>());
|
|
ArrayList<Long> userList = getEnterpriseHrs(sys_enterpriseid).toArrayList("userid", new ArrayList<>());
|
|
@@ -771,6 +798,7 @@ public class dispatch extends Controller {
|
|
|
remind.setTouserid(userList);
|
|
remind.setTouserid(userList);
|
|
|
remind.sendByDialogMsg().createSys_message();
|
|
remind.sendByDialogMsg().createSys_message();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
@API(title = "查询erp对接记录", apiversion = R.ID20230228133403.v1.class)
|
|
@API(title = "查询erp对接记录", apiversion = R.ID20230228133403.v1.class)
|
|
|
@CACHEING
|
|
@CACHEING
|
|
|
public String queryErpupdatelog() throws YosException {
|
|
public String queryErpupdatelog() throws YosException {
|