|
@@ -111,67 +111,70 @@ public class WeightImpl implements IWeight {
|
|
|
List<ProdWeightDayEntity> ProdWeightDayEntityList = getDayWeightList(todayDate);
|
|
|
prodWeightDayRepo.deleteAll(ProdWeightDayEntityList);
|
|
|
|
|
|
- BigDecimal grossTotalPurchaseBg = new BigDecimal("0");
|
|
|
- BigDecimal tareTotalPurchaseBg = new BigDecimal("0");
|
|
|
- BigDecimal netTotalPurchaseBg = new BigDecimal("0");
|
|
|
- for (int a = 0; a < purchaseJa.size(); a++) {
|
|
|
- JSONObject purchaseJo = purchaseJa.getJSONObject(a);
|
|
|
+ if(purchaseJa.size()>0){
|
|
|
+ BigDecimal grossTotalPurchaseBg = new BigDecimal("0");
|
|
|
+ BigDecimal tareTotalPurchaseBg = new BigDecimal("0");
|
|
|
+ BigDecimal netTotalPurchaseBg = new BigDecimal("0");
|
|
|
+ for (int a = 0; a < purchaseJa.size(); a++) {
|
|
|
+ JSONObject purchaseJo = purchaseJa.getJSONObject(a);
|
|
|
// System.out.println("" + purchaseJo.getBigDecimal("grossWeight") + " " + purchaseJo.getBigDecimal("tareWeight") + " " + purchaseJo.getBigDecimal("netWeight"));
|
|
|
- BigDecimal gw = purchaseJo.getBigDecimal("grossWeight");
|
|
|
- if (gw == null) {
|
|
|
- gw = new BigDecimal("0");
|
|
|
- }
|
|
|
- grossTotalPurchaseBg = grossTotalPurchaseBg.add(gw);
|
|
|
- BigDecimal tw = purchaseJo.getBigDecimal("tareWeight");
|
|
|
- if (tw == null) {
|
|
|
- tw = new BigDecimal("0");
|
|
|
- }
|
|
|
- tareTotalPurchaseBg = tareTotalPurchaseBg.add(tw);
|
|
|
- BigDecimal nw = purchaseJo.getBigDecimal("netWeight");
|
|
|
- if (nw == null) {
|
|
|
- nw = new BigDecimal("0");
|
|
|
+ BigDecimal gw = purchaseJo.getBigDecimal("grossWeight");
|
|
|
+ if (gw == null) {
|
|
|
+ gw = new BigDecimal("0");
|
|
|
+ }
|
|
|
+ grossTotalPurchaseBg = grossTotalPurchaseBg.add(gw);
|
|
|
+ BigDecimal tw = purchaseJo.getBigDecimal("tareWeight");
|
|
|
+ if (tw == null) {
|
|
|
+ tw = new BigDecimal("0");
|
|
|
+ }
|
|
|
+ tareTotalPurchaseBg = tareTotalPurchaseBg.add(tw);
|
|
|
+ BigDecimal nw = purchaseJo.getBigDecimal("netWeight");
|
|
|
+ if (nw == null) {
|
|
|
+ nw = new BigDecimal("0");
|
|
|
+ }
|
|
|
+ netTotalPurchaseBg = netTotalPurchaseBg.add(nw);
|
|
|
}
|
|
|
- netTotalPurchaseBg = netTotalPurchaseBg.add(nw);
|
|
|
+
|
|
|
+ ProdWeightDayEntity purchaseWeightDayEntity = new ProdWeightDayEntity();
|
|
|
+ purchaseWeightDayEntity.setAddDate(new java.sql.Date(dateUtil.parseDate(todayDate).getTime()));
|
|
|
+ purchaseWeightDayEntity.setGrossWeight(grossTotalPurchaseBg.floatValue());
|
|
|
+ purchaseWeightDayEntity.setTareWeight(tareTotalPurchaseBg.floatValue());
|
|
|
+ purchaseWeightDayEntity.setNetWeight(netTotalPurchaseBg.floatValue());
|
|
|
+ purchaseWeightDayEntity.setPoundType("Purchase");
|
|
|
+ prodWeightDayRepo.save(purchaseWeightDayEntity);
|
|
|
}
|
|
|
|
|
|
- ProdWeightDayEntity purchaseWeightDayEntity = new ProdWeightDayEntity();
|
|
|
- purchaseWeightDayEntity.setAddDate(new java.sql.Date(dateUtil.parseDate(todayDate).getTime()));
|
|
|
- purchaseWeightDayEntity.setGrossWeight(grossTotalPurchaseBg.floatValue());
|
|
|
- purchaseWeightDayEntity.setTareWeight(tareTotalPurchaseBg.floatValue());
|
|
|
- purchaseWeightDayEntity.setNetWeight(netTotalPurchaseBg.floatValue());
|
|
|
- purchaseWeightDayEntity.setPoundType("Purchase");
|
|
|
- prodWeightDayRepo.save(purchaseWeightDayEntity);
|
|
|
-
|
|
|
- BigDecimal grossTotalSalesBg = new BigDecimal("0");
|
|
|
- BigDecimal tareTotalSalesBg = new BigDecimal("0");
|
|
|
- BigDecimal netTotalSalesBg = new BigDecimal("0");
|
|
|
- for (int a = 0; a < salesJa.size(); a++) {
|
|
|
- JSONObject salesJo = salesJa.getJSONObject(a);
|
|
|
+ if(salesJa.size()>0){
|
|
|
+ BigDecimal grossTotalSalesBg = new BigDecimal("0");
|
|
|
+ BigDecimal tareTotalSalesBg = new BigDecimal("0");
|
|
|
+ BigDecimal netTotalSalesBg = new BigDecimal("0");
|
|
|
+ for (int a = 0; a < salesJa.size(); a++) {
|
|
|
+ JSONObject salesJo = salesJa.getJSONObject(a);
|
|
|
// System.out.println("" + salesJo.getBigDecimal("grossWeight") + " " + salesJo.getBigDecimal("tareWeight") + " " + salesJo.getBigDecimal("netWeight"));
|
|
|
- BigDecimal gw = salesJo.getBigDecimal("grossWeight");
|
|
|
- if (gw == null) {
|
|
|
- gw = new BigDecimal("0");
|
|
|
- }
|
|
|
- grossTotalSalesBg = grossTotalSalesBg.add(gw);
|
|
|
- BigDecimal tw = salesJo.getBigDecimal("tareWeight");
|
|
|
- if (tw == null) {
|
|
|
- tw = new BigDecimal("0");
|
|
|
- }
|
|
|
- tareTotalSalesBg = tareTotalSalesBg.add(tw);
|
|
|
- BigDecimal nw = salesJo.getBigDecimal("netWeight");
|
|
|
- if (nw == null) {
|
|
|
- nw = new BigDecimal("0");
|
|
|
+ BigDecimal gw = salesJo.getBigDecimal("grossWeight");
|
|
|
+ if (gw == null) {
|
|
|
+ gw = new BigDecimal("0");
|
|
|
+ }
|
|
|
+ grossTotalSalesBg = grossTotalSalesBg.add(gw);
|
|
|
+ BigDecimal tw = salesJo.getBigDecimal("tareWeight");
|
|
|
+ if (tw == null) {
|
|
|
+ tw = new BigDecimal("0");
|
|
|
+ }
|
|
|
+ tareTotalSalesBg = tareTotalSalesBg.add(tw);
|
|
|
+ BigDecimal nw = salesJo.getBigDecimal("netWeight");
|
|
|
+ if (nw == null) {
|
|
|
+ nw = new BigDecimal("0");
|
|
|
+ }
|
|
|
+ netTotalSalesBg = netTotalSalesBg.add(nw);
|
|
|
}
|
|
|
- netTotalSalesBg = netTotalSalesBg.add(nw);
|
|
|
+ ProdWeightDayEntity salesWeightDayEntity = new ProdWeightDayEntity();
|
|
|
+ salesWeightDayEntity.setAddDate(new java.sql.Date(dateUtil.parseDate(todayDate).getTime()));
|
|
|
+ salesWeightDayEntity.setGrossWeight(grossTotalSalesBg.floatValue());
|
|
|
+ salesWeightDayEntity.setTareWeight(tareTotalSalesBg.floatValue());
|
|
|
+ salesWeightDayEntity.setNetWeight(netTotalSalesBg.floatValue());
|
|
|
+ salesWeightDayEntity.setPoundType("Sales");
|
|
|
+ prodWeightDayRepo.save(salesWeightDayEntity);
|
|
|
}
|
|
|
-
|
|
|
- ProdWeightDayEntity salesWeightDayEntity = new ProdWeightDayEntity();
|
|
|
- salesWeightDayEntity.setAddDate(new java.sql.Date(dateUtil.parseDate(todayDate).getTime()));
|
|
|
- salesWeightDayEntity.setGrossWeight(grossTotalSalesBg.floatValue());
|
|
|
- salesWeightDayEntity.setTareWeight(tareTotalSalesBg.floatValue());
|
|
|
- salesWeightDayEntity.setNetWeight(netTotalSalesBg.floatValue());
|
|
|
- salesWeightDayEntity.setPoundType("Sales");
|
|
|
- prodWeightDayRepo.save(salesWeightDayEntity);
|
|
|
}
|
|
|
|
|
|
//
|