|
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Project : huimv.shiwan
|
|
* @Project : huimv.shiwan
|
|
@@ -46,13 +47,16 @@ public class WeightImpl implements IWeight {
|
|
Long date = dayWeightJo.getLong("addTime");
|
|
Long date = dayWeightJo.getLong("addTime");
|
|
Integer farmId = dayWeightJo.getInteger("farmId");
|
|
Integer farmId = dayWeightJo.getInteger("farmId");
|
|
//
|
|
//
|
|
- ProdDayWeightEntity existDayWeightEntity = dayWeightRepo.findByDateAndFarmId(new Date(date),farmId);
|
|
|
|
- if(existDayWeightEntity != null){
|
|
|
|
|
|
+ Optional<ProdDayWeightEntity> optional = dayWeightRepo.findByDateAndFarmId(new Date(date),farmId);
|
|
|
|
+ log.info("optional.isPresent>>"+optional.isPresent());
|
|
|
|
+ if(optional.isPresent()){
|
|
|
|
+ ProdDayWeightEntity existDayWeightEntity = optional.get();
|
|
existDayWeightEntity.setAddTime(new Timestamp(new Date().getTime()));
|
|
existDayWeightEntity.setAddTime(new Timestamp(new Date().getTime()));
|
|
existDayWeightEntity.setGrossWeight(dayWeightJo.getFloat("grossWeight"));
|
|
existDayWeightEntity.setGrossWeight(dayWeightJo.getFloat("grossWeight"));
|
|
existDayWeightEntity.setTareWeight(dayWeightJo.getFloat("tareWeight"));
|
|
existDayWeightEntity.setTareWeight(dayWeightJo.getFloat("tareWeight"));
|
|
existDayWeightEntity.setNetWeight(dayWeightJo.getFloat("netWeight"));
|
|
existDayWeightEntity.setNetWeight(dayWeightJo.getFloat("netWeight"));
|
|
dayWeightRepo.saveAndFlush(existDayWeightEntity);
|
|
dayWeightRepo.saveAndFlush(existDayWeightEntity);
|
|
|
|
+ log.info("编辑每天总重>>"+existDayWeightEntity);
|
|
}else{
|
|
}else{
|
|
ProdDayWeightEntity newDayWeightEntity = new ProdDayWeightEntity();
|
|
ProdDayWeightEntity newDayWeightEntity = new ProdDayWeightEntity();
|
|
newDayWeightEntity.setAddTime(new Timestamp(new Date().getTime()));
|
|
newDayWeightEntity.setAddTime(new Timestamp(new Date().getTime()));
|
|
@@ -61,6 +65,7 @@ public class WeightImpl implements IWeight {
|
|
newDayWeightEntity.setTareWeight(dayWeightJo.getFloat("tareWeight"));
|
|
newDayWeightEntity.setTareWeight(dayWeightJo.getFloat("tareWeight"));
|
|
newDayWeightEntity.setNetWeight(dayWeightJo.getFloat("netWeight"));
|
|
newDayWeightEntity.setNetWeight(dayWeightJo.getFloat("netWeight"));
|
|
dayWeightRepo.saveAndFlush(newDayWeightEntity);
|
|
dayWeightRepo.saveAndFlush(newDayWeightEntity);
|
|
|
|
+ log.info("新增每天总重>>"+newDayWeightEntity);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -79,10 +84,11 @@ public class WeightImpl implements IWeight {
|
|
public void saveBatchWeight(String data) {
|
|
public void saveBatchWeight(String data) {
|
|
JSONObject batchWeightJo = JSONObject.parseObject(data);
|
|
JSONObject batchWeightJo = JSONObject.parseObject(data);
|
|
String batchCode = batchWeightJo.getString("batchCode");
|
|
String batchCode = batchWeightJo.getString("batchCode");
|
|
- System.out.println("batchCode<<"+batchCode);
|
|
|
|
|
|
+ System.out.println("batchCode>>"+batchCode);
|
|
//查找批次称重数据
|
|
//查找批次称重数据
|
|
- ProdBatchWeightEntity existBatchWeightEntity = batchWeightRepo.findByBatchCode(batchCode);
|
|
|
|
- if(existBatchWeightEntity == null){
|
|
|
|
|
|
+ Optional<ProdBatchWeightEntity> optional = batchWeightRepo.findByBatchCode(batchCode);
|
|
|
|
+ log.info("optional.isPresent>>"+optional.isPresent());
|
|
|
|
+ if(!optional.isPresent()){
|
|
ProdBatchWeightEntity newBatchWeightEntity = new ProdBatchWeightEntity();
|
|
ProdBatchWeightEntity newBatchWeightEntity = new ProdBatchWeightEntity();
|
|
newBatchWeightEntity.setBatchCode(batchWeightJo.getString("batchCode"));
|
|
newBatchWeightEntity.setBatchCode(batchWeightJo.getString("batchCode"));
|
|
newBatchWeightEntity.setBatchSort(batchWeightJo.getInteger("batchSort"));
|
|
newBatchWeightEntity.setBatchSort(batchWeightJo.getInteger("batchSort"));
|
|
@@ -94,6 +100,7 @@ public class WeightImpl implements IWeight {
|
|
batchWeightRepo.saveAndFlush(newBatchWeightEntity);
|
|
batchWeightRepo.saveAndFlush(newBatchWeightEntity);
|
|
log.info("新增批次称重数据>>"+newBatchWeightEntity);
|
|
log.info("新增批次称重数据>>"+newBatchWeightEntity);
|
|
}else{
|
|
}else{
|
|
|
|
+ ProdBatchWeightEntity existBatchWeightEntity = optional.get();
|
|
existBatchWeightEntity.setGrossWeight(batchWeightJo.getFloat("grossWeight"));
|
|
existBatchWeightEntity.setGrossWeight(batchWeightJo.getFloat("grossWeight"));
|
|
existBatchWeightEntity.setTareWeight(batchWeightJo.getFloat("tareWeight"));
|
|
existBatchWeightEntity.setTareWeight(batchWeightJo.getFloat("tareWeight"));
|
|
existBatchWeightEntity.setNetWeight(batchWeightJo.getFloat("netWeight"));
|
|
existBatchWeightEntity.setNetWeight(batchWeightJo.getFloat("netWeight"));
|