Commit 104a795b authored by hywang's avatar hywang

1.修改从称获取的重量格式,获取什么显示什么

2.基础信息和称重信息增重格式改为小数点后1位
3.称重加默认日期为当日
4.性能测定自动带上扫标签时的重量
5.更换设置和同步的图标
parent a6536e2d
...@@ -9,8 +9,8 @@ android { ...@@ -9,8 +9,8 @@ android {
applicationId "com.phlx.anchorcollect" applicationId "com.phlx.anchorcollect"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
versionCode 3 versionCode 4
versionName "1.0.2" versionName "1.0.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
......
...@@ -124,6 +124,8 @@ public class Configs { ...@@ -124,6 +124,8 @@ public class Configs {
public static Long tempUnid; public static Long tempUnid;
//临时存放耳标数据 //临时存放耳标数据
public static CattleResumeEntity tempCattleResume; public static CattleResumeEntity tempCattleResume;
//临时存放重量数据
public static Double tempWeight= 0.0;
//首页fragment标签 //首页fragment标签
public static int mainPosition; public static int mainPosition;
......
...@@ -72,7 +72,7 @@ public class BtService extends Service implements EventObserver { ...@@ -72,7 +72,7 @@ public class BtService extends Service implements EventObserver {
Log.e(TAG, "onRead: " + data); Log.e(TAG, "onRead: " + data);
// ToastUtils.showShort("onRead: " + data); // ToastUtils.showShort("onRead: " + data);
String weightData = data.substring(data.indexOf("wn") + 3, data.indexOf("kg") - 2); String weightData = data.substring(data.indexOf("wn") + 3, data.indexOf("kg"));
EventMsg eventMsg = new EventMsg(); EventMsg eventMsg = new EventMsg();
eventMsg.setAction(Configs.currentEvent); eventMsg.setAction(Configs.currentEvent);
eventMsg.setObj(weightData); eventMsg.setObj(weightData);
......
...@@ -270,7 +270,8 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve ...@@ -270,7 +270,8 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
if (result != null && result.size() > 0) { if (result != null && result.size() > 0) {
//总增重 //总增重
if (Configs.tempCattleResume != null && Configs.tempCattleResume.getBirthHeavy() != null) { if (Configs.tempCattleResume != null && Configs.tempCattleResume.getBirthHeavy() != null) {
totalGainWeight.set(result.get(0).getWeight() - Configs.tempCattleResume.getBirthHeavy()); double doubleTotal = result.get(0).getWeight() - Configs.tempCattleResume.getBirthHeavy();
totalGainWeight.set(Double.parseDouble(new DecimalFormat("0.0").format(doubleTotal)));
lastGainDate.set(result.get(0).getWTime()); lastGainDate.set(result.get(0).getWTime());
adgGainDate.set(result.get(0).getWTime()); adgGainDate.set(result.get(0).getWTime());
...@@ -279,7 +280,8 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve ...@@ -279,7 +280,8 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
} }
if (result.size() >= 1) { if (result.size() >= 1) {
lastGainWeight.set(result.get(0).getWeight()); double doublelastGain = result.get(0).getWeight();
lastGainWeight.set(Double.parseDouble(new DecimalFormat("0.0").format(doublelastGain)));
//// Log.e("weight", "lastGainWeight:" + lastGainWeight.get()); //// Log.e("weight", "lastGainWeight:" + lastGainWeight.get());
if (result.size() > 1) {//两条以上记录 if (result.size() > 1) {//两条以上记录
dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat = new SimpleDateFormat("yyyy-MM-dd");
...@@ -572,6 +574,8 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve ...@@ -572,6 +574,8 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
if (eventType.getAction().equals(EventTag.EVENT_WEIGHT_DATA_BASICS)) { if (eventType.getAction().equals(EventTag.EVENT_WEIGHT_DATA_BASICS)) {
Double weightNum = Double.parseDouble(eventType.getObj().toString().trim()); Double weightNum = Double.parseDouble(eventType.getObj().toString().trim());
if (weightNum > 25) { if (weightNum > 25) {
if (isWeightScan)
Configs.tempWeight = weightNum;
scanRfid(); scanRfid();
isWeightScan = false; isWeightScan = false;
} else { } else {
...@@ -586,7 +590,7 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve ...@@ -586,7 +590,7 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
} }
isWeightScan = true; isWeightScan = true;
} }
weight.set(eventType.getObj().toString()); weight.set(weightNum + "");
} }
}); });
RxSubscriptions.add(weightBus); RxSubscriptions.add(weightBus);
...@@ -604,6 +608,7 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve ...@@ -604,6 +608,7 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
Configs.tempUnid = null; Configs.tempUnid = null;
Configs.tempRfid = ""; Configs.tempRfid = "";
Configs.tempCattleResume = null; Configs.tempCattleResume = null;
Configs.tempWeight = 0.0;
tag.set(""); tag.set("");
rfid.set(""); rfid.set("");
rfidTag = ""; rfidTag = "";
......
...@@ -272,6 +272,7 @@ public class PerformanceVM extends BaseViewModel<Repository> { ...@@ -272,6 +272,7 @@ public class PerformanceVM extends BaseViewModel<Repository> {
Configs.resumeId = null; Configs.resumeId = null;
} }
performanceEntity.setRemark(remarkParamEntity.getContent()); performanceEntity.setRemark(remarkParamEntity.getContent());
performanceEntity.setWeight(Configs.tempWeight);
performanceEntity.setUploadStatus("0"); performanceEntity.setUploadStatus("0");
uploadData = new ArrayList<>(); uploadData = new ArrayList<>();
......
...@@ -99,7 +99,7 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor ...@@ -99,7 +99,7 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
public ObservableField<String> tag = new ObservableField<>(""); public ObservableField<String> tag = new ObservableField<>("");
public ObservableField<String> rfid = new ObservableField<>(""); public ObservableField<String> rfid = new ObservableField<>("");
public ObservableField<Double> weight = new ObservableField<>(0.0); public ObservableField<Double> weight = new ObservableField<>(50.2);
public ObservableField<Double> lastGainWeight = new ObservableField<>(0.0);//上次增重 public ObservableField<Double> lastGainWeight = new ObservableField<>(0.0);//上次增重
public ObservableField<Double> adgGainWeight = new ObservableField<>(0.0);//日增重 public ObservableField<Double> adgGainWeight = new ObservableField<>(0.0);//日增重
...@@ -170,7 +170,14 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor ...@@ -170,7 +170,14 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
// imgFile = new File(imgUrl); // imgFile = new File(imgUrl);
uiList.clear(); uiList.clear();
int i = 0; int i = 0;
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
for (GenTableColumn gtc : Configs.weightMan) { for (GenTableColumn gtc : Configs.weightMan) {
if (gtc.getHtmlType().equals("datetime")) {
if (gtc.getContent() == null || "".equals(gtc.getContent())) {
gtc.setContent(dateFormat.format(new Date()));
gtc.setShowName(dateFormat.format(new Date()));
}
}
if (i < 4) { if (i < 4) {
uiList.add(gtc); uiList.add(gtc);
} else { } else {
...@@ -287,7 +294,9 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor ...@@ -287,7 +294,9 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
if (result != null && result.size() > 0) { if (result != null && result.size() > 0) {
//总增重 //总增重
if (Configs.tempCattleResume != null && Configs.tempCattleResume.getBirthHeavy() != null) { if (Configs.tempCattleResume != null && Configs.tempCattleResume.getBirthHeavy() != null) {
totalGainWeight.set(result.get(0).getWeight() - Configs.tempCattleResume.getBirthHeavy());
double doubleTotal = result.get(0).getWeight() - Configs.tempCattleResume.getBirthHeavy();
totalGainWeight.set(Double.parseDouble(new DecimalFormat("0.0").format(doubleTotal)));
lastGainDate.set(result.get(0).getWTime()); lastGainDate.set(result.get(0).getWTime());
adgGainDate.set(result.get(0).getWTime()); adgGainDate.set(result.get(0).getWTime());
totalGainDate.set(result.get(0).getWTime()); totalGainDate.set(result.get(0).getWTime());
...@@ -295,7 +304,8 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor ...@@ -295,7 +304,8 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
} }
if (result.size() >= 1) { if (result.size() >= 1) {
lastGainWeight.set(result.get(0).getWeight()); double doublelastGain = result.get(0).getWeight();
lastGainWeight.set(Double.parseDouble(new DecimalFormat("0.0").format(doublelastGain)));
// Log.e("weight", "lastGainWeight:" + lastGainWeight.get()); // Log.e("weight", "lastGainWeight:" + lastGainWeight.get());
if (result.size() > 1) {//两条以上记录 if (result.size() > 1) {//两条以上记录
dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat = new SimpleDateFormat("yyyy-MM-dd");
...@@ -382,6 +392,11 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor ...@@ -382,6 +392,11 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
@Override @Override
public void call() { public void call() {
if (Configs.tempUnid == null) {
onShowDialogEvent.setValue("请先扫描耳标!");
return;
}
if (weight.get() < 25) { if (weight.get() < 25) {
onShowDialogEvent.setValue("重量非法!请先称重!"); onShowDialogEvent.setValue("重量非法!请先称重!");
return; return;
...@@ -499,6 +514,13 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor ...@@ -499,6 +514,13 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
for (GenTableColumn gtc : Configs.weightMan) { for (GenTableColumn gtc : Configs.weightMan) {
if (gtc.getHtmlType() != null && gtc.getHtmlType().equals("datetime")) {
if (gtc.getContent() == null || "".equals(gtc.getContent())) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
gtc.setContent(dateFormat.format(new Date()));
gtc.setShowName(dateFormat.format(new Date()));
}
}
if (name.equals(gtc.getJavaField())) { if (name.equals(gtc.getJavaField())) {
try { try {
Log.e("key:", name); Log.e("key:", name);
...@@ -527,7 +549,6 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor ...@@ -527,7 +549,6 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
} }
} }
onNotifyAllEvent.setValue(false); onNotifyAllEvent.setValue(false);
} else { } else {
onNotifyAllEvent.setValue(true); onNotifyAllEvent.setValue(true);
...@@ -557,6 +578,14 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor ...@@ -557,6 +578,14 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
gtc.setContent(""); gtc.setContent("");
gtc.setShowName(""); gtc.setShowName("");
gtc.notifyChange(); gtc.notifyChange();
if (gtc.getHtmlType() != null && gtc.getHtmlType().equals("datetime")) {
if (gtc.getContent() == null || "".equals(gtc.getContent())) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
gtc.setContent(dateFormat.format(new Date()));
gtc.setShowName(dateFormat.format(new Date()));
}
}
} }
queryGainWeight();//刷新一下增重数据 queryGainWeight();//刷新一下增重数据
...@@ -627,10 +656,12 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor ...@@ -627,10 +656,12 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
if (eventType.getAction().equals(EventTag.EVENT_WEIGHT_DATA_WEIGHT)) { if (eventType.getAction().equals(EventTag.EVENT_WEIGHT_DATA_WEIGHT)) {
Double weightNum = Double.parseDouble(eventType.getObj().toString().trim()); Double weightNum = Double.parseDouble(eventType.getObj().toString().trim());
if (weightNum > 25) { if (weightNum > 25) {
if (isWeightScan)
Configs.tempWeight = weightNum;
scanRfid(); scanRfid();
isWeightScan = false; isWeightScan = false;
} else { } else {
if (weight.get()!=null && weight.get() > 25) { if (weight.get() != null && weight.get() > 25) {
lastGainWeight.set(0.0); lastGainWeight.set(0.0);
adgGainWeight.set(0.0); adgGainWeight.set(0.0);
...@@ -669,6 +700,7 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor ...@@ -669,6 +700,7 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
Configs.tempUnid = null; Configs.tempUnid = null;
Configs.tempRfid = ""; Configs.tempRfid = "";
Configs.tempCattleResume = null; Configs.tempCattleResume = null;
Configs.tempWeight = 0.0;
tag.set(""); tag.set("");
rfid.set(""); rfid.set("");
rfidTag = ""; rfidTag = "";
......
...@@ -27,6 +27,7 @@ import com.phlx.anchorcollect.ui.fragment.ImmunRecordFragment; ...@@ -27,6 +27,7 @@ import com.phlx.anchorcollect.ui.fragment.ImmunRecordFragment;
import com.phlx.anchorcollect.ui.fragment.MedicalRecordFragment; import com.phlx.anchorcollect.ui.fragment.MedicalRecordFragment;
import com.phlx.anchorcollect.ui.fragment.PerformanceFragment; import com.phlx.anchorcollect.ui.fragment.PerformanceFragment;
import com.phlx.anchorcollect.ui.fragment.WeightManFragment; import com.phlx.anchorcollect.ui.fragment.WeightManFragment;
import com.uhf.structures.DynamicQParams;
import com.uhf.structures.InventoryParams; import com.uhf.structures.InventoryParams;
import me.goldze.mvvmhabit.utils.ToastUtils; import me.goldze.mvvmhabit.utils.ToastUtils;
...@@ -170,8 +171,39 @@ public class MainActivity extends BaseActivity<ActivityMainBinding, MainVM> { ...@@ -170,8 +171,39 @@ public class MainActivity extends BaseActivity<ActivityMainBinding, MainVM> {
inventoryParams.inventoryArea = 2; inventoryParams.inventoryArea = 2;
inventoryParams.len = 6; inventoryParams.len = 6;
App.getInstance().getLinkage().Radio_SetInventoryParams(inventoryParams); App.getInstance().getLinkage().Radio_SetInventoryParams(inventoryParams);
setAlgorithm();
} }
/**
* 获取算法
*/
private void setAlgorithm() {
DynamicQParams dynamicQParams = new DynamicQParams();
int dynamic_state =
App.getInstance().getLinkage().Radio_GetSingulationAlgorithmDyParameters(dynamicQParams);
if (dynamic_state == 0) {
dynamicQParams.thresholdMultiplier = 4;
int dynamicResult =
App.getInstance().getLinkage().Radio_SetSingulationAlgorithmDyParameters(dynamicQParams);
if (dynamicResult == 0) {
// ToastUtils.showShort("设置动态算法成功");
// int saveStatue = App.getInstance().getLinkage().saveR2000Setting();
// if (saveStatue == 0) {
//// ToastUtils.showShort("参数保存成功");
// } else {
// ToastUtils.showShort("参数保存失败");
// }
} else {
ToastUtils.showShort("设置动态算法失败");
}
// ToastUtils.showShort("获取动态算法成功");
}else {
ToastUtils.showShort("获取动态算法失败");
}
}
@Override @Override
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="tag" android:text="可视耳标号"
android:textColor="@color/colorPrimary" android:textColor="@color/colorPrimary"
android:textSize="@dimen/sp_10" /> android:textSize="@dimen/sp_10" />
...@@ -338,7 +338,7 @@ ...@@ -338,7 +338,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="10dp" android:layout_margin="10dp"
android:src="@mipmap/ic_set" android:src="@mipmap/icon_sync"
binding:layout_constraintRight_toLeftOf="@+id/iv_setting" binding:layout_constraintRight_toLeftOf="@+id/iv_setting"
binding:layout_constraintTop_toTopOf="parent" binding:layout_constraintTop_toTopOf="parent"
binding:onClickCommand="@{viewModel.onSyncClick}" /> binding:onClickCommand="@{viewModel.onSyncClick}" />
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="tag" android:text="可视耳标号"
android:textColor="@color/colorPrimary" android:textColor="@color/colorPrimary"
android:textSize="@dimen/sp_10" /> android:textSize="@dimen/sp_10" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment