|
|
@@ -5,6 +5,7 @@ import beans.accountbalance.CashbillEntity;
|
|
|
import beans.data.BatchDeleteErr;
|
|
|
import beans.datacontrllog.DataContrlLog;
|
|
|
import beans.dispatch.Dispatch;
|
|
|
+import beans.invbal.Invbal;
|
|
|
import beans.parameter.Parameter;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
@@ -24,6 +25,7 @@ import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static java.time.LocalDate.now;
|
|
|
@@ -182,6 +184,9 @@ public class stockbill extends Controller {
|
|
|
where.append("or t6.depname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
where.append(")");
|
|
|
}
|
|
|
+ if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
|
|
|
+ where.append(" and t1.type ='").append(whereObject.getString("type")).append("' ");
|
|
|
+ }
|
|
|
if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
where.append(" and t1.status ='").append(whereObject.getString("status")).append("' ");
|
|
|
}
|
|
|
@@ -295,13 +300,99 @@ public class stockbill extends Controller {
|
|
|
return batchDeleteErr.getReturnObject().toString();
|
|
|
|
|
|
}
|
|
|
-
|
|
|
@API(title = "审核", apiversion = R.ID20230719154103.v1.class)
|
|
|
- @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, Order.class, OrderItems.class})
|
|
|
+ @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, Order.class, OrderItems.class,restcontroller.sale.stockbill.stockbill.class})
|
|
|
public String check() throws YosException {
|
|
|
+ Long st_stockbillid = content.getLong("st_stockbillid");
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from st_stockbill where st_stockbillid ='"
|
|
|
+ + st_stockbillid + "' and siteid='" + siteid + "'");
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("该出入库单不存在")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ String type=rows.get(0).getString("type");
|
|
|
+ boolean isinstock = isinstock(type,rows.get(0).getString("rb"),true);
|
|
|
+ if(type.equals("销售出库")){
|
|
|
+ String str = unxsckcheck(st_stockbillid);
|
|
|
+ if(!str.equals("success")){
|
|
|
+ return getErrReturnObject().setErrMsg(str)
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }else if (type.equals("外购入库")) {
|
|
|
+
|
|
|
+ } else if (type.equals("生产领料出库")) {
|
|
|
+
|
|
|
+ } else if (type.equals("委外领料出库")) {
|
|
|
+
|
|
|
+ } else if (type.equals("生产入库") || type.equals("委外入库")) {
|
|
|
+
|
|
|
+ } else if (type.equals("其他入库")) {
|
|
|
+
|
|
|
+ } else if (type.equals("返修入库")) {// 云链
|
|
|
+
|
|
|
+ } else if (type.equals("返修出库")) {// 云链
|
|
|
+
|
|
|
+ }
|
|
|
+ updateIcinvbal(isinstock,0,st_stockbillid);// 即时库存计算
|
|
|
+
|
|
|
+ SQLFactory sqlFactoryupdate = new SQLFactory(this, "出入库单审核");
|
|
|
+ sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
+ sqlFactoryupdate.addParameter("st_stockbillid", st_stockbillid);
|
|
|
+ sqlFactoryupdate.addParameter("checkby", username);
|
|
|
+ sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "审核", "出入库单审核成功").getSQL());
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
|
|
|
+ @API(title = "反审核", apiversion = R.ID20230719154203.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, Order.class, OrderItems.class,stockbill.class,restcontroller.sale.stockbill.stockbill.class})
|
|
|
+ public String uncheck() throws YosException {
|
|
|
Long st_stockbillid = content.getLong("st_stockbillid");
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select type,rb from st_stockbill where st_stockbillid ='"
|
|
|
+ + st_stockbillid + "' and siteid='" + siteid + "'");
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("该出入库单不存在")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ String type=rows.get(0).getString("type");
|
|
|
+ boolean isinstock = isinstock(rows.get(0).getString("type"),rows.get(0).getString("rb"),false);
|
|
|
+ if(type.equals("销售出库")){
|
|
|
+ String str = unxsckcheck(st_stockbillid);
|
|
|
+ if(!str.equals("success")){
|
|
|
+ return getErrReturnObject().setErrMsg(str)
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }else if (type.equals("外购入库")) {
|
|
|
+
|
|
|
+ } else if (type.equals("生产领料出库")) {
|
|
|
+
|
|
|
+ } else if (type.equals("委外领料出库")) {
|
|
|
+
|
|
|
+ } else if (type.equals("生产入库") || type.equals("委外入库")) {
|
|
|
+
|
|
|
+ } else if (type.equals("其他入库")) {
|
|
|
+
|
|
|
+ } else if (type.equals("返修入库")) {// 云链
|
|
|
+
|
|
|
+ } else if (type.equals("返修出库")) {// 云链
|
|
|
+
|
|
|
+ }
|
|
|
+ updateIcinvbal(isinstock,0,st_stockbillid);// 即时库存计算
|
|
|
+
|
|
|
+ SQLFactory sqlFactoryupdate = new SQLFactory(this, "出入库单反审核");
|
|
|
+ sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
+ sqlFactoryupdate.addParameter("st_stockbillid", st_stockbillid);
|
|
|
+ sqlFactoryupdate.addParameter("checkby", username);
|
|
|
+ sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "反审核", "出入库单反审核成功").getSQL());
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
|
|
|
+ public String xsckcheck(Long st_stockbillid) throws YosException {
|
|
|
Rows rows = dbConnect.runSqlQuery("select * from st_stockbill where st_stockbillid ='"
|
|
|
+ st_stockbillid + "' and siteid='" + siteid + "'");
|
|
|
Rows rowsdetail = dbConnect.runSqlQuery("select t1.*,t2.skucontrol from st_stockbill_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.st_stockbillid ='"
|
|
|
@@ -309,40 +400,38 @@ public class stockbill extends Controller {
|
|
|
long sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
|
|
|
|
|
|
if (rows.isEmpty()) {
|
|
|
- return getErrReturnObject().setErrMsg("该出入库单不存在")
|
|
|
- .toString();
|
|
|
+ return "该出入库单不存在";
|
|
|
} else {
|
|
|
if (!rows.get(0).getString("status").equals("新建")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + rows.get(0).getString("billno") + "】的出入库单为非新建状态,无法审核")
|
|
|
- .toString();
|
|
|
+ return "单号为:【" + rows.get(0).getString("billno") + "】的出入库单为非新建状态,无法审核";
|
|
|
}
|
|
|
}
|
|
|
for(Row row : rowsdetail){
|
|
|
if (row.getBigDecimal("qty").compareTo(BigDecimal.ZERO)<1) {
|
|
|
- return getErrReturnObject().setErrMsg("表体数量不能小于0").toString();
|
|
|
+ return "表体数量不能小于0";
|
|
|
}
|
|
|
}
|
|
|
if (rows.get(0).getBigDecimal("payamount").compareTo(BigDecimal.ZERO)<=0) {
|
|
|
- return getErrReturnObject().setErrMsg("扣款金额需大于0").toString();
|
|
|
+ return "扣款金额需大于0";
|
|
|
}
|
|
|
if (StringUtils.isBlank(rows.get(0).getString("outplace"))) {
|
|
|
- return getErrReturnObject().setErrMsg("发货地不可为空").toString();
|
|
|
+ return "发货地不可为空";
|
|
|
}
|
|
|
if ((rows.get(0).getBigDecimal("payamount").add(rows.get(0).getBigDecimal("paydiscountamount"))).compareTo(rowsdetail.sum("amount"))!=0) {
|
|
|
- return getErrReturnObject().setErrMsg("扣款金额与应扣金额不符,不能审核").toString();
|
|
|
+ return "扣款金额与应扣金额不符,不能审核";
|
|
|
}
|
|
|
Rows accountbalancerows = dbConnect.runSqlQuery("select * from sa_accountbalance t1 inner join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t2.accountname='现金账户' and t1.sys_enterpriseid="+sys_enterpriseid);
|
|
|
if (accountbalancerows.isNotEmpty()) {
|
|
|
BigDecimal discountamount = accountbalancerows.get(0).getBigDecimal("discountamount");
|
|
|
if (rows.get(0).getBigDecimal("paydiscountamount").compareTo(discountamount)>0) {
|
|
|
- return getErrReturnObject().setErrMsg("优惠金额不能大于可用优惠金额").toString();
|
|
|
+ return "优惠金额不能大于可用优惠金额";
|
|
|
}
|
|
|
}else{
|
|
|
- return getErrReturnObject().setErrMsg("账户不存在").toString();
|
|
|
+ return "账户不存在";
|
|
|
}
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- Rows stockRows= dbConnect.runSqlQuery("select * from st_stock where siteid='"+siteid+"'");
|
|
|
- RowsMap stockRowsMap =stockRows.toRowsMap("itemid");
|
|
|
+// Rows stockRows= dbConnect.runSqlQuery("select * from st_stock where siteid='"+siteid+"'");
|
|
|
+// RowsMap stockRowsMap =stockRows.toRowsMap("itemid");
|
|
|
|
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
|
if(rows.get(0).getBoolean("rb")){
|
|
|
@@ -353,7 +442,7 @@ public class stockbill extends Controller {
|
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(this, sys_enterpriseid,accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
} else {
|
|
|
- return getErrReturnObject().setErrMsg("账户余额不足,还差" + Accountbalance.InsufficientBalance(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"),rowsdetail.sum("amount")) + "元!").toString();
|
|
|
+ return "账户余额不足,还差" + Accountbalance.InsufficientBalance(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"),rowsdetail.sum("amount")) + "元!";
|
|
|
}
|
|
|
}
|
|
|
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 st_stockbill_items where st_stockbillid=" + st_stockbillid + ")");
|
|
|
@@ -361,7 +450,7 @@ public class stockbill extends Controller {
|
|
|
Rows rowsDispatchDetailGroup = dbConnect.runSqlQuery("select sum(t1.qty) qty,t1.sa_orderitemsid,t1.siteid from st_stockbill_items t1 where t1.st_stockbillid=" + st_stockbillid + " group by t1.sa_orderitemsid,t1.siteid");
|
|
|
Rows rowsjudge =dbConnect.runSqlQuery("select * from (select sa_orderitemsid,sum(qty) qty from st_stockbill_items where st_stockbillid ='"+st_stockbillid+"' group by sa_orderitemsid) t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid where t1.qty>t2.undeliqty");
|
|
|
if(rowsjudge.isNotEmpty()){
|
|
|
- return getErrReturnObject().setErrMsg("存在商品已完全出库,无法审核").toString();
|
|
|
+ return "存在商品已完全出库,无法审核";
|
|
|
}
|
|
|
for (Row row : rowsDispatchDetailGroup) {
|
|
|
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"));
|
|
|
@@ -373,55 +462,44 @@ public class stockbill extends Controller {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- for(Row row :rowsdetail){
|
|
|
- String itemid= row.getString("itemid");
|
|
|
- long stockid=row.getLong("stockid");
|
|
|
- if(stockRowsMap.containsKey(itemid)){
|
|
|
- for(Row row1 :stockRowsMap.get(itemid)){
|
|
|
- if(row1.getLong("stockid")==stockid){
|
|
|
- sqlList.add("update st_stock set qty="+row1.getBigDecimal("qty").add(row.getBigDecimal("qty"))+" where stockid="+stockid);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // String batchno = row.getString("batchno");
|
|
|
- }
|
|
|
+// for(Row row :rowsdetail){
|
|
|
+// String itemid= row.getString("itemid");
|
|
|
+// long stockid=row.getLong("stockid");
|
|
|
+// if(stockRowsMap.containsKey(itemid)){
|
|
|
+// for(Row row1 :stockRowsMap.get(itemid)){
|
|
|
+// if(row1.getLong("stockid")==stockid){
|
|
|
+// sqlList.add("update st_stock set qty="+row1.getBigDecimal("qty").add(row.getBigDecimal("qty"))+" where stockid="+stockid);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// // String batchno = row.getString("batchno");
|
|
|
+// }
|
|
|
}else{
|
|
|
- for(Row row :rowsdetail){
|
|
|
- String itemid= row.getString("itemid");
|
|
|
- long stockid=row.getLong("stockid");
|
|
|
- if(stockRowsMap.containsKey(itemid)){
|
|
|
- for(Row row1 :stockRowsMap.get(itemid)){
|
|
|
- if(row1.getLong("stockid")==stockid){
|
|
|
- sqlList.add("update st_stock set qty="+row1.getBigDecimal("qty").subtract(row.getBigDecimal("qty"))+" where stockid="+stockid);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // String batchno = row.getString("batchno");
|
|
|
- }
|
|
|
+// for(Row row :rowsdetail){
|
|
|
+// String itemid= row.getString("itemid");
|
|
|
+// long stockid=row.getLong("stockid");
|
|
|
+// if(stockRowsMap.containsKey(itemid)){
|
|
|
+// for(Row row1 :stockRowsMap.get(itemid)){
|
|
|
+// if(row1.getLong("stockid")==stockid){
|
|
|
+// sqlList.add("update st_stock set qty="+row1.getBigDecimal("qty").subtract(row.getBigDecimal("qty"))+" where stockid="+stockid);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// // String batchno = row.getString("batchno");
|
|
|
+// }
|
|
|
}
|
|
|
// Rows stockbillitems = dbConnect.runSqlQuery("select t2.sa_orderid,sum(t2.price*t1.qty) amount from st_stockbill_items t1 inner join sa_orderitems t2 on t1.siteid=t2.siteid and t1.sa_orderitemsid=t2.sa_orderitemsid where t1.siteid='"+siteid+"'and t1.st_stockbillid="+st_stockbillid+" group by t2.sa_orderid");
|
|
|
// Rows orderRows =dbConnect.runSqlQuery("select * from sa_order where sa_orderid in(select t2.sa_orderid from st_stockbill_items t1 inner join sa_orderitems t2 on t1.siteid=t2.siteid and t1.sa_orderitemsid=t2.sa_orderitemsid where t1.st_stockbillid='"+st_stockbillid+"')");
|
|
|
// RowsMap orderRowsMap =orderRows.toRowsMap("sa_orderid");
|
|
|
|
|
|
-
|
|
|
- SQLFactory sqlFactoryupdate = new SQLFactory(this, "出入库单审核");
|
|
|
- sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
- sqlFactoryupdate.addParameter("st_stockbillid", st_stockbillid);
|
|
|
- sqlFactoryupdate.addParameter("checkby", username);
|
|
|
- sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "审核", "出入库单审核成功").getSQL());
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
-
|
|
|
// Accountbalance.remindSend(this, sys_enterpriseid, sa_cashbillid);
|
|
|
- return getSucReturnObject().toString();
|
|
|
+ return "success";
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public String unxsckcheck(Long st_stockbillid) throws YosException {
|
|
|
|
|
|
- @API(title = "反审核", apiversion = R.ID20230719154203.v1.class)
|
|
|
- @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, Order.class, OrderItems.class})
|
|
|
- public String uncheck() throws YosException {
|
|
|
- Long st_stockbillid = content.getLong("st_stockbillid");
|
|
|
|
|
|
Rows rows = dbConnect.runSqlQuery("select * from st_stockbill where st_stockbillid ='"
|
|
|
+ st_stockbillid + "' and siteid='" + siteid + "'");
|
|
|
@@ -430,41 +508,39 @@ public class stockbill extends Controller {
|
|
|
long sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
|
|
|
|
|
|
if (rows.isEmpty()) {
|
|
|
- return getErrReturnObject().setErrMsg("该出入库单不存在")
|
|
|
- .toString();
|
|
|
+ return "该出入库单不存在";
|
|
|
} else {
|
|
|
if (!rows.get(0).getString("status").equals("审核")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + rows.get(0).getString("billno") + "】的出入库单为非审核状态,无法反审核")
|
|
|
- .toString();
|
|
|
+ return "单号为:【" + rows.get(0).getString("billno") + "】的出入库单为非审核状态,无法反审核";
|
|
|
}
|
|
|
}
|
|
|
for(Row row : rowsdetail){
|
|
|
if (row.getBigDecimal("qty").compareTo(BigDecimal.ZERO)<1) {
|
|
|
- return getErrReturnObject().setErrMsg("表体数量不能小于0").toString();
|
|
|
+ return "表体数量不能小于0";
|
|
|
}
|
|
|
}
|
|
|
if (rows.get(0).getBigDecimal("paydiscountamount").compareTo(BigDecimal.ZERO)<0) {
|
|
|
- return getErrReturnObject().setErrMsg("优惠金额不能小于0").toString();
|
|
|
+ return "优惠金额不能小于0";
|
|
|
}
|
|
|
if (rows.get(0).getBigDecimal("payamount").compareTo(BigDecimal.ZERO)<=0) {
|
|
|
- return getErrReturnObject().setErrMsg("扣款金额需大于0").toString();
|
|
|
+ return "扣款金额需大于0";
|
|
|
}
|
|
|
if (StringUtils.isBlank(rows.get(0).getString("outplace"))) {
|
|
|
- return getErrReturnObject().setErrMsg("发货地不可为空").toString();
|
|
|
+ return "发货地不可为空";
|
|
|
}
|
|
|
if ((rows.get(0).getBigDecimal("payamount").add(rows.get(0).getBigDecimal("paydiscountamount"))).compareTo(rowsdetail.sum("amount"))!=0) {
|
|
|
- return getErrReturnObject().setErrMsg("扣款金额与应扣金额不符,不能反审核").toString();
|
|
|
+ return "扣款金额与应扣金额不符,不能反审核";
|
|
|
}
|
|
|
Rows accountbalancerows = dbConnect.runSqlQuery("select * from sa_accountbalance t1 inner join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t2.accountname='现金账户' and t1.sys_enterpriseid="+sys_enterpriseid);
|
|
|
if (accountbalancerows.isEmpty()) {
|
|
|
- return getErrReturnObject().setErrMsg("账户不存在").toString();
|
|
|
+ return "账户不存在";
|
|
|
}
|
|
|
if (rows.get(0).getString("type").equals("销售出库") && rows.get(0).getBoolean("isreceiver")) {
|
|
|
- return getErrReturnObject().setErrMsg("经销商已经确认收货,不可进行反审核").toString();
|
|
|
+ return "经销商已经确认收货,不可进行反审核";
|
|
|
}
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- Rows stockRows= dbConnect.runSqlQuery("select * from st_stock where siteid='"+siteid+"'");
|
|
|
- RowsMap stockRowsMap =stockRows.toRowsMap("itemid");
|
|
|
+// Rows stockRows= dbConnect.runSqlQuery("select * from st_stock where siteid='"+siteid+"'");
|
|
|
+// RowsMap stockRowsMap =stockRows.toRowsMap("itemid");
|
|
|
|
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
|
if(rows.get(0).getBoolean("rb")){
|
|
|
@@ -475,7 +551,7 @@ public class stockbill extends Controller {
|
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(this, sys_enterpriseid,accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
} else {
|
|
|
- return getErrReturnObject().setErrMsg("账户余额不足,还差" + Accountbalance.InsufficientBalance(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"),rowsdetail.sum("amount")) + "元!").toString();
|
|
|
+ return "账户余额不足,还差" + Accountbalance.InsufficientBalance(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"),rowsdetail.sum("amount")) + "元!";
|
|
|
}
|
|
|
}
|
|
|
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 st_stockbill_items where st_stockbillid=" + st_stockbillid + ")");
|
|
|
@@ -491,47 +567,39 @@ public class stockbill extends Controller {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- for(Row row :rowsdetail){
|
|
|
- String itemid= row.getString("itemid");
|
|
|
- long stockid=row.getLong("stockid");
|
|
|
- if(stockRowsMap.containsKey(itemid)){
|
|
|
- for(Row row1 :stockRowsMap.get(itemid)){
|
|
|
- if(row1.getLong("stockid")==stockid){
|
|
|
- sqlList.add("update st_stock set qty="+row1.getBigDecimal("qty").subtract(row.getBigDecimal("qty"))+" where stockid="+stockid);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // String batchno = row.getString("batchno");
|
|
|
- }
|
|
|
+// for(Row row :rowsdetail){
|
|
|
+// String itemid= row.getString("itemid");
|
|
|
+// long stockid=row.getLong("stockid");
|
|
|
+// if(stockRowsMap.containsKey(itemid)){
|
|
|
+// for(Row row1 :stockRowsMap.get(itemid)){
|
|
|
+// if(row1.getLong("stockid")==stockid){
|
|
|
+// sqlList.add("update st_stock set qty="+row1.getBigDecimal("qty").subtract(row.getBigDecimal("qty"))+" where stockid="+stockid);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// // String batchno = row.getString("batchno");
|
|
|
+// }
|
|
|
}else{
|
|
|
- for(Row row :rowsdetail){
|
|
|
- String itemid= row.getString("itemid");
|
|
|
- long stockid=row.getLong("stockid");
|
|
|
- if(stockRowsMap.containsKey(itemid)){
|
|
|
- for(Row row1 :stockRowsMap.get(itemid)){
|
|
|
- if(row1.getLong("stockid")==stockid){
|
|
|
- sqlList.add("update st_stock set qty="+row1.getBigDecimal("qty").add(row.getBigDecimal("qty"))+" where stockid="+stockid);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // String batchno = row.getString("batchno");
|
|
|
- }
|
|
|
+// for(Row row :rowsdetail){
|
|
|
+// String itemid= row.getString("itemid");
|
|
|
+// long stockid=row.getLong("stockid");
|
|
|
+// if(stockRowsMap.containsKey(itemid)){
|
|
|
+// for(Row row1 :stockRowsMap.get(itemid)){
|
|
|
+// if(row1.getLong("stockid")==stockid){
|
|
|
+// sqlList.add("update st_stock set qty="+row1.getBigDecimal("qty").add(row.getBigDecimal("qty"))+" where stockid="+stockid);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// // String batchno = row.getString("batchno");
|
|
|
+// }
|
|
|
}
|
|
|
// Rows stockbillitems = dbConnect.runSqlQuery("select t2.sa_orderid,sum(t2.price*t1.qty) amount from st_stockbill_items t1 inner join sa_orderitems t2 on t1.siteid=t2.siteid and t1.sa_orderitemsid=t2.sa_orderitemsid where t1.siteid='"+siteid+"'and t1.st_stockbillid="+st_stockbillid+" group by t2.sa_orderid");
|
|
|
// Rows orderRows =dbConnect.runSqlQuery("select * from sa_order where sa_orderid in(select t2.sa_orderid from st_stockbill_items t1 inner join sa_orderitems t2 on t1.siteid=t2.siteid and t1.sa_orderitemsid=t2.sa_orderitemsid where t1.st_stockbillid='"+st_stockbillid+"')");
|
|
|
// RowsMap orderRowsMap =orderRows.toRowsMap("sa_orderid");
|
|
|
-
|
|
|
-
|
|
|
- SQLFactory sqlFactoryupdate = new SQLFactory(this, "出入库单反审核");
|
|
|
- sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
- sqlFactoryupdate.addParameter("st_stockbillid", st_stockbillid);
|
|
|
- sqlFactoryupdate.addParameter("checkby", username);
|
|
|
- sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "反审核", "出入库单反审核成功").getSQL());
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
|
// Accountbalance.remindSend(this, sys_enterpriseid, sa_cashbillid);
|
|
|
- return getSucReturnObject().toString();
|
|
|
+ return "success";
|
|
|
}
|
|
|
|
|
|
@API(title = "仓库确认", apiversion = R.ID2025050709505703.v1.class)
|
|
|
@@ -590,4 +658,113 @@ public class stockbill extends Controller {
|
|
|
return entity;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param type
|
|
|
+ * @param rb
|
|
|
+ * @param fischeck
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean isinstock(String type,String rb,boolean fischeck){
|
|
|
+ if (type.equals("其他出库") || type.equals("销售出库")
|
|
|
+ || type.equals("生产领料出库") || type.equals("委外领料出库")
|
|
|
+ || type.equals("返修出库")) {
|
|
|
+ if ((fischeck && rb.equals("1")) || (!fischeck && rb.equals("0"))) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (type.equals("其他入库") || type.equals("外购入库")
|
|
|
+ || type.equals("生产入库") || type.equals("委外入库")
|
|
|
+ || type.equals("返修入库")) {
|
|
|
+ if ((fischeck && rb.equals("1")) || (!fischeck && rb.equals("0"))) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param isinstock 是否增加库存
|
|
|
+ * @param type 库存更新类型 0为默认形式。1表示生产领料更新现场仓 2表示委外领料更新现场仓
|
|
|
+ * @throws YosException
|
|
|
+ */
|
|
|
+ public void updateIcinvbal(boolean isinstock, int type,Long st_stockbillid) throws YosException {
|
|
|
+ ArrayList<String> sqlList =new ArrayList();
|
|
|
+ Rows icstockbilldetail =dbConnect.runSqlQuery("select t1.*,t2.skucontrol from st_stockbill_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.st_stockbillid ='"
|
|
|
+ + st_stockbillid + "' and t1.siteid='" + siteid + "'");// 出入库表体
|
|
|
+ ArrayList<Long> itemids = new ArrayList<Long>();
|
|
|
+ itemids = icstockbilldetail.toArrayList("itemid",new ArrayList<>());
|
|
|
+ itemids.add((long) 0);
|
|
|
+ int i = 0;
|
|
|
+ String sql="select * from st_invbal where itemid in"+itemids;
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
+ Rows invbals = dbConnect.runSqlQuery(sql);
|
|
|
+ RowsMap invbalsRowsMap=invbals.toRowsMap("itemid");
|
|
|
+ for(Row row : icstockbilldetail){
|
|
|
+ String itemid = row.getString("itemid");
|
|
|
+ //String batchno = row.getString("batchno");
|
|
|
+ //String fdcspno = row.getString("fdcspno");
|
|
|
+ String stockid = row.getString("stockid");
|
|
|
+
|
|
|
+// if (type == 1 && !getSysVars().getBoolean("FISBATCHFORXC")) {
|
|
|
+// fdcspno = "**********";
|
|
|
+// fbatchno = "**********";
|
|
|
+// fstockno = getPaoSet("TDEPARTMENT").getPao(0)
|
|
|
+// .getPaoSet("TSTOCKXC").getPao(0).getString("fstockno");
|
|
|
+// icinvbal = detailpao.getPaoSet("$icinvbal", "icinvbal",
|
|
|
+// "fitemno='" + fitemno + "' and fstockno='" + fstockno
|
|
|
+// + "' and fdcspno='" + fdcspno
|
|
|
+// + "' and fbatchno='" + fbatchno + "'");
|
|
|
+// } else if (type == 2 && !getSysVars().getBoolean("FISBATCHFORXC")) {
|
|
|
+// fdcspno = "**********";
|
|
|
+// fbatchno = "**********";
|
|
|
+// fstockno = getPaoSet("TSUPPLIER").getPao(0)
|
|
|
+// .getPaoSet("TSTOCKXC").getPao(0).getString("fstockno");
|
|
|
+// icinvbal = detailpao.getPaoSet("$icinvbal", "icinvbal",
|
|
|
+// "fitemno='" + fitemno + "' and fstockno='" + fstockno
|
|
|
+// + "' and fdcspno='" + fdcspno
|
|
|
+// + "' and fbatchno='" + fbatchno + "'");
|
|
|
+// }
|
|
|
+ BigDecimal qty = isinstock ? row.getBigDecimal("qty") : row.getBigDecimal("qty").negate();
|
|
|
+ if(invbalsRowsMap.containsKey(itemid)){
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "即时库存新增");
|
|
|
+ sqlFactory.addParameter("st_invbalid", createTableID("st_invbal"));
|
|
|
+ sqlFactory.addParameter("qty", qty);
|
|
|
+ sqlFactory.addParameter("itemid", itemid);
|
|
|
+ sqlFactory.addParameter("stockid", stockid);
|
|
|
+ sqlFactory.addParameter("siteid",siteid);
|
|
|
+ sqlFactory.addParameter("userid", userid);
|
|
|
+ sqlFactory.addParameter("username", username);
|
|
|
+ sqlList.add(sqlFactory.getSQL());
|
|
|
+ }else{
|
|
|
+ if(invbalsRowsMap.get(itemid).toRowsMap("stockid").containsKey(stockid)){
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "即时库存更新");
|
|
|
+ sqlFactory.addParameter("st_invbalid", createTableID("st_invbal"));
|
|
|
+ sqlFactory.addParameter("qty", invbalsRowsMap.get(itemid).toRowsMap("stockid").get(stockid).get(0).getBigDecimal("qty").add(qty));
|
|
|
+ sqlFactory.addParameter("itemid", itemid);
|
|
|
+ sqlFactory.addParameter("stockid", stockid);
|
|
|
+ sqlFactory.addParameter("siteid",siteid);
|
|
|
+ sqlFactory.addParameter("userid", userid);
|
|
|
+ sqlFactory.addParameter("username", username);
|
|
|
+ sqlList.add(sqlFactory.getSQL());
|
|
|
+ }else{
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(new Invbal(), "即时库存新增");
|
|
|
+ sqlFactory.addParameter("st_invbalid", createTableID("st_invbal"));
|
|
|
+ sqlFactory.addParameter("qty", qty);
|
|
|
+ sqlFactory.addParameter("itemid", itemid);
|
|
|
+ sqlFactory.addParameter("stockid", stockid);
|
|
|
+ sqlFactory.addParameter("siteid",siteid);
|
|
|
+ sqlFactory.addParameter("userid", userid);
|
|
|
+ sqlFactory.addParameter("username", username);
|
|
|
+ sqlList.add(sqlFactory.getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ }
|
|
|
}
|