|
@@ -60,16 +60,39 @@ public class WeightImpl implements IWeight {
|
|
|
private String weightPath;
|
|
|
|
|
|
@Override
|
|
|
- public Result getEggWeightDetails() throws ParseException {
|
|
|
+ public Result getEggWeightDetails(String todayDate) throws ParseException {
|
|
|
+// String url = "http://39.171.45.196:9200/egg/getWeightDetails?date=2022-06-10";
|
|
|
+// String url = "http://39.171.45.196:9200/egg/getWeightDetails";
|
|
|
+
|
|
|
+ // 获取今天数据
|
|
|
+ if(StringUtils.isBlank(todayDate)){
|
|
|
+ todayDate = new DateUtil().getTodayDateText();
|
|
|
+ }
|
|
|
+ String url = weightHttp + weightPath + "?date=" + todayDate;
|
|
|
+ System.out.println("url=" + url);
|
|
|
+ String result = restTemplate.getForObject(url, String.class);
|
|
|
+ JSONArray resultJa = JSONArray.parseArray(result);
|
|
|
+ log.info("接口返回数量=" + resultJa.size());
|
|
|
+
|
|
|
+ // 保存每天明细
|
|
|
+ saveWeightDetails(resultJa, todayDate);
|
|
|
+
|
|
|
+ // 保存汇总每天总重
|
|
|
+ saveDayWeight(resultJa, todayDate);
|
|
|
+
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result autoGenerateDayWeight() throws ParseException {
|
|
|
// String url = "http://39.171.45.196:9200/egg/getWeightDetails?date=2022-06-10";
|
|
|
// String url = "http://39.171.45.196:9200/egg/getWeightDetails";
|
|
|
|
|
|
// 获取今天数据
|
|
|
String todayDate = new DateUtil().getTodayDateText();
|
|
|
// test
|
|
|
-// String todayDate = "2022-06-10";
|
|
|
- String url = weightHttp + weightPath;
|
|
|
- url += "?date=" + todayDate;
|
|
|
+// todayDate = "2022-06-11";
|
|
|
+ String url = weightHttp + weightPath + "?date=" + todayDate;
|
|
|
System.out.println("url=" + url);
|
|
|
String result = restTemplate.getForObject(url, String.class);
|
|
|
JSONArray resultJa = JSONArray.parseArray(result);
|
|
@@ -84,6 +107,8 @@ public class WeightImpl implements IWeight {
|
|
|
return new Result(ResultCode.SUCCESS);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @Method : saveDayWeight
|
|
|
* @Description :
|
|
@@ -111,6 +136,7 @@ public class WeightImpl implements IWeight {
|
|
|
List<ProdWeightDayEntity> ProdWeightDayEntityList = getDayWeightList(todayDate);
|
|
|
prodWeightDayRepo.deleteAll(ProdWeightDayEntityList);
|
|
|
|
|
|
+ // 添加采购每日汇总
|
|
|
if(purchaseJa.size()>0){
|
|
|
BigDecimal grossTotalPurchaseBg = new BigDecimal("0");
|
|
|
BigDecimal tareTotalPurchaseBg = new BigDecimal("0");
|
|
@@ -134,7 +160,6 @@ public class WeightImpl implements IWeight {
|
|
|
}
|
|
|
netTotalPurchaseBg = netTotalPurchaseBg.add(nw);
|
|
|
}
|
|
|
-
|
|
|
ProdWeightDayEntity purchaseWeightDayEntity = new ProdWeightDayEntity();
|
|
|
purchaseWeightDayEntity.setAddDate(new java.sql.Date(dateUtil.parseDate(todayDate).getTime()));
|
|
|
purchaseWeightDayEntity.setGrossWeight(grossTotalPurchaseBg.floatValue());
|
|
@@ -144,13 +169,14 @@ public class WeightImpl implements IWeight {
|
|
|
prodWeightDayRepo.save(purchaseWeightDayEntity);
|
|
|
}
|
|
|
|
|
|
+ // 添加销售每日汇总
|
|
|
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"));
|
|
|
+ System.out.println("" + salesJo.getBigDecimal("grossWeight") + " " + salesJo.getBigDecimal("tareWeight") + " " + salesJo.getBigDecimal("netWeight"));
|
|
|
BigDecimal gw = salesJo.getBigDecimal("grossWeight");
|
|
|
if (gw == null) {
|
|
|
gw = new BigDecimal("0");
|
|
@@ -192,27 +218,13 @@ public class WeightImpl implements IWeight {
|
|
|
* @Time : 4:03
|
|
|
*/
|
|
|
private void saveWeightDetails(JSONArray resultJa, String todayDate) throws ParseException {
|
|
|
- // 读取每天的一个称重数据
|
|
|
+ // 删除每天历史记录
|
|
|
List<ProdWeightDetailsEntity> existEntityList = getTodayWeightDetails(todayDate);
|
|
|
- System.out.println("今天已经取回数量=" + existEntityList.size());
|
|
|
- JSONArray dataJa = new JSONArray();
|
|
|
+ System.out.println("今天历史记录数量=" + existEntityList.size());
|
|
|
+ prodWeightDetailsRepo.deleteAll(existEntityList);
|
|
|
+
|
|
|
for (int a = 0; a < resultJa.size(); a++) {
|
|
|
- JSONObject resultJo = resultJa.getJSONObject(a);
|
|
|
- boolean isExist = false;
|
|
|
- for (ProdWeightDetailsEntity weightDetailsEntity : existEntityList) {
|
|
|
- if (weightDetailsEntity.getSerialNumber().equalsIgnoreCase(resultJo.getString("serialNumber"))) {
|
|
|
- isExist = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!isExist) {
|
|
|
- dataJa.add(resultJo);
|
|
|
- }
|
|
|
- }
|
|
|
- System.out.println("dataJa.size=" + dataJa.size());
|
|
|
- for (int a = 0; a < dataJa.size(); a++) {
|
|
|
- System.out.println("" + (a + 1));
|
|
|
- JSONObject dataJo = dataJa.getJSONObject(a);
|
|
|
+ JSONObject dataJo = resultJa.getJSONObject(a);
|
|
|
ProdWeightDetailsEntity prodWeightDetailsEntity = new ProdWeightDetailsEntity();
|
|
|
prodWeightDetailsEntity.setSerialNumber(dataJo.getString("serialNumber"));
|
|
|
prodWeightDetailsEntity.setCarNumber(dataJo.getString("carNumber"));
|
|
@@ -231,6 +243,7 @@ public class WeightImpl implements IWeight {
|
|
|
prodWeightDetailsEntity.setWeighingTime(new java.sql.Date(new DateUtil().parseDateTime(dataJo.getString("weighingTime")).getTime()));
|
|
|
prodWeightDetailsEntity.setWeighingType(dataJo.getString("weighingType"));
|
|
|
prodWeightDetailsEntity.setAddDate(new Timestamp(new Date().getTime()));
|
|
|
+ prodWeightDetailsEntity.setUnit1(dataJo.getString("unit1"));
|
|
|
prodWeightDetailsRepo.save(prodWeightDetailsEntity);
|
|
|
}
|
|
|
}
|
|
@@ -620,7 +633,6 @@ public class WeightImpl implements IWeight {
|
|
|
// if (null != deliverState) {
|
|
|
// predList.add(criteriaBuilder.equal(root.get("deliverState").as(Integer.class), deliverState));
|
|
|
// }
|
|
|
- System.out.println("predList.size()="+predList.size());
|
|
|
//
|
|
|
Predicate[] pred = new Predicate[predList.size()];
|
|
|
Predicate and = criteriaBuilder.and(predList.toArray(pred));
|