|
@@ -939,7 +939,7 @@ public class stockbill extends Controller {
|
|
|
}
|
|
}
|
|
|
Row st_stockbill = rows.get(0);
|
|
Row st_stockbill = rows.get(0);
|
|
|
for (String FMACHINECODE : CODE) {
|
|
for (String FMACHINECODE : CODE) {
|
|
|
- Rows stockbillitemsrows = dbConnect.runSqlQuery("select t1.itemid,t1.qty,t2.skucontrol from st_stockbill_items t1 left join plm_item t2 on t1.itemid=t2.itemid where t1.st_stockbillid ='"
|
|
|
|
|
|
|
+ Rows stockbillitemsrows = dbConnect.runSqlQuery("select t1.itemid,t1.qty,t2.skucontrol,t1.st_stockbill_itemsid from st_stockbill_items t1 left join plm_item t2 on t1.itemid=t2.itemid where t1.st_stockbillid ='"
|
|
|
+ st_stockbillid + "' and t1.siteid='" + siteid + "'");
|
|
+ st_stockbillid + "' and t1.siteid='" + siteid + "'");
|
|
|
Rows stockbillitemskurows = dbConnect.runSqlQuery("select t1.*,t2.itemid from st_stockbill_items_sku t1 left join sa_itemsku t2 on t1.sku=t2.sku where t1.st_stockbillid ='"
|
|
Rows stockbillitemskurows = dbConnect.runSqlQuery("select t1.*,t2.itemid from st_stockbill_items_sku t1 left join sa_itemsku t2 on t1.sku=t2.sku where t1.st_stockbillid ='"
|
|
|
+ st_stockbillid + "' and t1.siteid='" + siteid + "'");
|
|
+ st_stockbillid + "' and t1.siteid='" + siteid + "'");
|
|
@@ -1013,11 +1013,16 @@ public class stockbill extends Controller {
|
|
|
&& (skuRowsMap.get(FMACHINECODE).get(0).getString("stockno")
|
|
&& (skuRowsMap.get(FMACHINECODE).get(0).getString("stockno")
|
|
|
.equals("103") || skuRowsMap.get(FMACHINECODE).get(0).getString("stockno").equals("109")) ? "101"
|
|
.equals("103") || skuRowsMap.get(FMACHINECODE).get(0).getString("stockno").equals("109")) ? "101"
|
|
|
: skuRowsMap.get(FMACHINECODE).get(0).getString("stockno");
|
|
: skuRowsMap.get(FMACHINECODE).get(0).getString("stockno");
|
|
|
|
|
+
|
|
|
Rows stockrows = dbConnect.runSqlQuery("select *from st_stock where stockno='" + stockno + "'");
|
|
Rows stockrows = dbConnect.runSqlQuery("select *from st_stock where stockno='" + stockno + "'");
|
|
|
|
|
|
|
|
|
|
|
|
|
if(st_stockbill_itemsid>0 && dbConnect.runSqlQuery("select 1 from st_stockbill_items_sku where st_stockbillid=st_stockbill_itemsid and st_stockbillid="+st_stockbillid).size()>0){
|
|
if(st_stockbill_itemsid>0 && dbConnect.runSqlQuery("select 1 from st_stockbill_items_sku where st_stockbillid=st_stockbill_itemsid and st_stockbillid="+st_stockbillid).size()>0){
|
|
|
scanqtyrefresh();
|
|
scanqtyrefresh();
|
|
|
|
|
+ stockbillitemsrows = dbConnect.runSqlQuery("select t1.itemid,t1.qty,t2.skucontrol,t1.st_stockbill_itemsid from st_stockbill_items t1 left join plm_item t2 on t1.itemid=t2.itemid where t1.st_stockbillid ='"
|
|
|
|
|
+ + st_stockbillid + "' and t1.siteid='" + siteid + "'");
|
|
|
|
|
+ stockbillitemskurows = dbConnect.runSqlQuery("select t1.*,t2.itemid from st_stockbill_items_sku t1 left join sa_itemsku t2 on t1.sku=t2.sku where t1.st_stockbillid ='"
|
|
|
|
|
+ + st_stockbillid + "' and t1.siteid='" + siteid + "'");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1026,6 +1031,8 @@ public class stockbill extends Controller {
|
|
|
}
|
|
}
|
|
|
if (stockid == 0) {
|
|
if (stockid == 0) {
|
|
|
skustockid = st_stockbill.getLong("stockid");
|
|
skustockid = st_stockbill.getLong("stockid");
|
|
|
|
|
+ }else{
|
|
|
|
|
+ skustockid=stockid;
|
|
|
}
|
|
}
|
|
|
InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill_items_sku");
|
|
InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill_items_sku");
|
|
|
long st_stockbill_items_skuid = createTableID("st_stockbill_items_sku");
|
|
long st_stockbill_items_skuid = createTableID("st_stockbill_items_sku");
|
|
@@ -1058,6 +1065,7 @@ public class stockbill extends Controller {
|
|
|
insertSQL.setValue("st_stockbillid", st_stockbillid);
|
|
insertSQL.setValue("st_stockbillid", st_stockbillid);
|
|
|
insertSQL.setValue("st_stockbill_itemsid", st_stockbill_itemsidnew);
|
|
insertSQL.setValue("st_stockbill_itemsid", st_stockbill_itemsidnew);
|
|
|
}else{
|
|
}else{
|
|
|
|
|
+
|
|
|
if(stockbillitemsrows.toRowsMap("itemid").get(skuitemid).sum("qty").compareTo(BigDecimal.valueOf(stockbillitemskurows.toRowsMap("itemid").get(skuitemid).size()))<=0){
|
|
if(stockbillitemsrows.toRowsMap("itemid").get(skuitemid).sum("qty").compareTo(BigDecimal.valueOf(stockbillitemskurows.toRowsMap("itemid").get(skuitemid).size()))<=0){
|
|
|
BigDecimal newqty = BigDecimal.valueOf(stockbillitemskurows.toRowsMap("itemid").get(skuitemid).size()).subtract(stockbillitemsrows.toRowsMap("itemid").get(skuitemid).sum("qty")).add(BigDecimal.ONE);
|
|
BigDecimal newqty = BigDecimal.valueOf(stockbillitemskurows.toRowsMap("itemid").get(skuitemid).size()).subtract(stockbillitemsrows.toRowsMap("itemid").get(skuitemid).sum("qty")).add(BigDecimal.ONE);
|
|
|
sqllist.add("update st_stockbill_items set qty=qty+"+newqty+" where st_stockbill_itemsid ="+stockbillitemsrows.toRowsMap("itemid").get(skuitemid).get(0).getLong("st_stockbill_itemsid"));
|
|
sqllist.add("update st_stockbill_items set qty=qty+"+newqty+" where st_stockbill_itemsid ="+stockbillitemsrows.toRowsMap("itemid").get(skuitemid).get(0).getLong("st_stockbill_itemsid"));
|
|
@@ -1120,7 +1128,7 @@ public class stockbill extends Controller {
|
|
|
long st_stockbillid = content.getLong("st_stockbillid");
|
|
long st_stockbillid = content.getLong("st_stockbillid");
|
|
|
ArrayList<String> sqllist = new ArrayList<>();
|
|
ArrayList<String> sqllist = new ArrayList<>();
|
|
|
Rows stockbillskuRows = dbConnect.runSqlQuery("select t1.sku,t2.itemid,t1.st_stockbill_items_skuid from st_stockbill_items_sku t1 left join sa_itemsku t2 on t1.sku=t2.sku where t1.st_stockbillid=t1.st_stockbill_itemsid and t1.st_stockbillid="+st_stockbillid);
|
|
Rows stockbillskuRows = dbConnect.runSqlQuery("select t1.sku,t2.itemid,t1.st_stockbill_items_skuid from st_stockbill_items_sku t1 left join sa_itemsku t2 on t1.sku=t2.sku where t1.st_stockbillid=t1.st_stockbill_itemsid and t1.st_stockbillid="+st_stockbillid);
|
|
|
- Rows stockbilldetailRows = dbConnect.runSqlQuery("select t1.itemid,t1.st_stockbill_itemsid,(t1.qty-t2.smqty) qty from st_stockbill_items t1 inner join (select st_stockbill_itemsid,count(1) smqty from st_stockbill_items_sku where st_stockbillid='"+st_stockbillid+"' and st_stockbillid!=st_stockbill_itemsid group by st_stockbill_itemsid) t2 on t1.st_stockbill_itemsid=t2.st_stockbill_itemsid where t1.st_stockbillid="+st_stockbillid +" and skucontrol=1");
|
|
|
|
|
|
|
+ Rows stockbilldetailRows = dbConnect.runSqlQuery("select t1.itemid,t1.st_stockbill_itemsid,(t1.qty-ifnull(t2.smqty,0)) qty from st_stockbill_items t1 left join (select st_stockbill_itemsid,count(1) smqty from st_stockbill_items_sku where st_stockbillid='"+st_stockbillid+"' and st_stockbillid!=st_stockbill_itemsid group by st_stockbill_itemsid) t2 on t1.st_stockbill_itemsid=t2.st_stockbill_itemsid where t1.st_stockbillid="+st_stockbillid +" and skucontrol=1");
|
|
|
RowsMap stockbilldetailRowsMap = stockbilldetailRows.toRowsMap("itemid");
|
|
RowsMap stockbilldetailRowsMap = stockbilldetailRows.toRowsMap("itemid");
|
|
|
HashMap<String,Integer> itemqtymap =new HashMap<>();
|
|
HashMap<String,Integer> itemqtymap =new HashMap<>();
|
|
|
for(Row row :stockbillskuRows){
|
|
for(Row row :stockbillskuRows){
|