|
|
@@ -162,11 +162,12 @@ public class sendplandetail extends Controller {
|
|
|
|
|
|
|
|
|
ArrayList<String> list = new ArrayList<>();
|
|
|
- Rows sendplandetailsgroupitemid = dbConnect.runSqlQuery("select t2.itemid,t1.sa_sendplandetailid,t1.sendqty from sa_sendplandetail t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid where t1.sa_sendplanid=" + sendplandetails.get(0).getLong("sa_sendplanid") + " and t2.itemid="+sendplandetails.get(0).getLong("itemid")+" and t1.siteid='" + siteid + "' order by t2.sa_orderid desc");
|
|
|
+ Rows sendplandetailsgroupitemid = dbConnect.runSqlQuery("select t2.itemid,t1.sa_sendplandetailid,t1.sendqty,t1.canuseqty from sa_sendplandetail t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid where t1.sa_sendplanid=" + sendplandetails.get(0).getLong("sa_sendplanid") + " and t2.itemid="+sendplandetails.get(0).getLong("itemid")+" and t1.siteid='" + siteid + "' order by t2.sa_orderid desc");
|
|
|
BigDecimal sendqtyold = BigDecimal.ZERO;
|
|
|
+ BigDecimal canuseqty= sendplandetailsgroupitemid.max("canuseqty");
|
|
|
for(int a=0; a<sendplandetailsgroupitemid.size();a++){
|
|
|
if(a>0){
|
|
|
- list.add("update sa_sendplandetail set canuseqty=canuseqty-"+sendqtyold+" where sa_sendplandetailid="+sendplandetailsgroupitemid.get(a).getLong("sa_sendplandetailid"));
|
|
|
+ list.add("update sa_sendplandetail set canuseqty="+canuseqty.subtract(sendqtyold)+" where sa_sendplandetailid="+sendplandetailsgroupitemid.get(a).getLong("sa_sendplandetailid"));
|
|
|
}
|
|
|
sendqtyold=sendqtyold.add(sendplandetailsgroupitemid.get(a).getBigDecimal("sendqty"));
|
|
|
}
|