|
@@ -1,7 +1,9 @@
|
|
package com.huimv.receiver.farm.service.impl;
|
|
package com.huimv.receiver.farm.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.huimv.receiver.farm.dao.entity.ProdBatchWeightEntity;
|
|
import com.huimv.receiver.farm.dao.entity.ProdDayWeightEntity;
|
|
import com.huimv.receiver.farm.dao.entity.ProdDayWeightEntity;
|
|
|
|
+import com.huimv.receiver.farm.dao.repo.ProdBatchWeightRepo;
|
|
import com.huimv.receiver.farm.dao.repo.ProdDayWeightRepo;
|
|
import com.huimv.receiver.farm.dao.repo.ProdDayWeightRepo;
|
|
import com.huimv.receiver.farm.service.IWeight;
|
|
import com.huimv.receiver.farm.service.IWeight;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -22,7 +24,19 @@ import java.util.Date;
|
|
public class WeightImpl implements IWeight {
|
|
public class WeightImpl implements IWeight {
|
|
@Autowired
|
|
@Autowired
|
|
private ProdDayWeightRepo dayWeightRepo;
|
|
private ProdDayWeightRepo dayWeightRepo;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProdBatchWeightRepo batchWeightRepo;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @Method : saveDayWeight
|
|
|
|
+ * @Description : 保存日总重数据
|
|
|
|
+ * @Params : [data]
|
|
|
|
+ * @Return : void
|
|
|
|
+ *
|
|
|
|
+ * @Author : ZhuoNing
|
|
|
|
+ * @Date : 2021/12/7
|
|
|
|
+ * @Time : 19:48
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public void saveDayWeight(String data) {
|
|
public void saveDayWeight(String data) {
|
|
JSONObject dayWeightJo = JSONObject.parseObject(data);
|
|
JSONObject dayWeightJo = JSONObject.parseObject(data);
|
|
@@ -32,7 +46,6 @@ public class WeightImpl implements IWeight {
|
|
ProdDayWeightEntity existDayWeightEntity = dayWeightRepo.findByDateAndFarmId(new Date(date),farmId);
|
|
ProdDayWeightEntity existDayWeightEntity = dayWeightRepo.findByDateAndFarmId(new Date(date),farmId);
|
|
if(existDayWeightEntity != null){
|
|
if(existDayWeightEntity != null){
|
|
existDayWeightEntity.setAddTime(new Timestamp(new Date().getTime()));
|
|
existDayWeightEntity.setAddTime(new Timestamp(new Date().getTime()));
|
|
-// existDayWeightEntity.setFarmId(dayWeightJo.getInteger("farmId"));
|
|
|
|
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"));
|
|
@@ -48,4 +61,39 @@ public class WeightImpl implements IWeight {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Method : saveBatchWeight
|
|
|
|
+ * @Description : 保存批次重量数据
|
|
|
|
+ * @Params : [data]
|
|
|
|
+ * @Return : void
|
|
|
|
+ *
|
|
|
|
+ * @Author : ZhuoNing
|
|
|
|
+ * @Date : 2021/12/7
|
|
|
|
+ * @Time : 19:49
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void saveBatchWeight(String data) {
|
|
|
|
+ JSONObject batchWeightJo = JSONObject.parseObject(data);
|
|
|
|
+ String batchCode = batchWeightJo.getString("batchCode");
|
|
|
|
+ System.out.println("batchCode<<"+batchCode);
|
|
|
|
+ //查找批次称重数据
|
|
|
|
+ ProdBatchWeightEntity existBatchWeightEntity = batchWeightRepo.findByBatchCode(batchCode);
|
|
|
|
+ if(existBatchWeightEntity == null){
|
|
|
|
+ ProdBatchWeightEntity newBatchWeightEntity = new ProdBatchWeightEntity();
|
|
|
|
+ newBatchWeightEntity.setBatchCode(batchWeightJo.getString("batchCode"));
|
|
|
|
+ newBatchWeightEntity.setBatchSort(batchWeightJo.getInteger("batchSort"));
|
|
|
|
+ newBatchWeightEntity.setFarmId(batchWeightJo.getInteger("farmId"));
|
|
|
|
+ newBatchWeightEntity.setGrossWeight(batchWeightJo.getFloat("grossWeight"));
|
|
|
|
+ newBatchWeightEntity.setTareWeight(batchWeightJo.getFloat("tareWeight"));
|
|
|
|
+ newBatchWeightEntity.setNetWeight(batchWeightJo.getFloat("netWeight"));
|
|
|
|
+ newBatchWeightEntity.setAddTime(new Timestamp(new Date().getTime()));
|
|
|
|
+ batchWeightRepo.saveAndFlush(newBatchWeightEntity);
|
|
|
|
+ }else{
|
|
|
|
+ existBatchWeightEntity.setGrossWeight(batchWeightJo.getFloat("grossWeight"));
|
|
|
|
+ existBatchWeightEntity.setTareWeight(batchWeightJo.getFloat("tareWeight"));
|
|
|
|
+ existBatchWeightEntity.setNetWeight(batchWeightJo.getFloat("netWeight"));
|
|
|
|
+ batchWeightRepo.saveAndFlush(existBatchWeightEntity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|