Commit 7322ea62 authored by hywang's avatar hywang

1.性能测定判断重量不低于上个年龄有称重的性能测定。

parent 17486fe8
......@@ -9,8 +9,8 @@ android {
applicationId "com.phlx.anchorcollect_p"
minSdkVersion 21
targetSdkVersion 29
versionCode 23
versionName "2.3.2"
versionCode 24
versionName "2.4.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
......@@ -50,7 +50,7 @@ android {
}
greendao {
schemaVersion 7 //数据库版本号
schemaVersion 8 //数据库版本号
daoPackage 'com.phlx.anchorcollect_p.db.gen'
targetGenDir 'src/main/java'
}
......
......@@ -14,10 +14,10 @@ import org.greenrobot.greendao.identityscope.IdentityScopeType;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 7): knows all DAOs.
* Master of DAO (schema version 8): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 7;
public static final int SCHEMA_VERSION = 8;
/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
......
......@@ -25,7 +25,7 @@ public class DictEntityDao extends AbstractDao<DictEntity, Void> {
*/
public static class Properties {
public final static Property DictCode = new Property(0, String.class, "dictCode", false, "DICT_CODE");
public final static Property DictSort = new Property(1, String.class, "dictSort", false, "DICT_SORT");
public final static Property DictSort = new Property(1, int.class, "dictSort", false, "DICT_SORT");
public final static Property DictLabel = new Property(2, String.class, "dictLabel", false, "DICT_LABEL");
public final static Property DictValue = new Property(3, String.class, "dictValue", false, "DICT_VALUE");
public final static Property DictType = new Property(4, String.class, "dictType", false, "DICT_TYPE");
......@@ -54,7 +54,7 @@ public class DictEntityDao extends AbstractDao<DictEntity, Void> {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"DICT_ENTITY\" (" + //
"\"DICT_CODE\" TEXT," + // 0: dictCode
"\"DICT_SORT\" TEXT," + // 1: dictSort
"\"DICT_SORT\" INTEGER NOT NULL ," + // 1: dictSort
"\"DICT_LABEL\" TEXT," + // 2: dictLabel
"\"DICT_VALUE\" TEXT," + // 3: dictValue
"\"DICT_TYPE\" TEXT," + // 4: dictType
......@@ -83,11 +83,7 @@ public class DictEntityDao extends AbstractDao<DictEntity, Void> {
if (dictCode != null) {
stmt.bindString(1, dictCode);
}
String dictSort = entity.getDictSort();
if (dictSort != null) {
stmt.bindString(2, dictSort);
}
stmt.bindLong(2, entity.getDictSort());
String dictLabel = entity.getDictLabel();
if (dictLabel != null) {
......@@ -158,11 +154,7 @@ public class DictEntityDao extends AbstractDao<DictEntity, Void> {
if (dictCode != null) {
stmt.bindString(1, dictCode);
}
String dictSort = entity.getDictSort();
if (dictSort != null) {
stmt.bindString(2, dictSort);
}
stmt.bindLong(2, entity.getDictSort());
String dictLabel = entity.getDictLabel();
if (dictLabel != null) {
......@@ -234,7 +226,7 @@ public class DictEntityDao extends AbstractDao<DictEntity, Void> {
public DictEntity readEntity(Cursor cursor, int offset) {
DictEntity entity = new DictEntity( //
cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // dictCode
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // dictSort
cursor.getInt(offset + 1), // dictSort
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // dictLabel
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // dictValue
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // dictType
......@@ -254,7 +246,7 @@ public class DictEntityDao extends AbstractDao<DictEntity, Void> {
@Override
public void readEntity(Cursor cursor, DictEntity entity, int offset) {
entity.setDictCode(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
entity.setDictSort(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setDictSort(cursor.getInt(offset + 1));
entity.setDictLabel(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setDictValue(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
entity.setDictType(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
......
......@@ -20,7 +20,7 @@ public class DictEntity extends BaseObservable implements Parcelable {
private String dictCode;
/** 字典排序 */
private String dictSort;
private int dictSort;
/** 字典标签 */
private String dictLabel;
......@@ -63,7 +63,7 @@ public class DictEntity extends BaseObservable implements Parcelable {
protected DictEntity(Parcel in) {
dictCode = in.readString();
dictSort = in.readString();
dictSort = in.readInt();
dictLabel = in.readString();
dictValue = in.readString();
dictType = in.readString();
......@@ -78,8 +78,8 @@ public class DictEntity extends BaseObservable implements Parcelable {
remark = in.readString();
}
@Generated(hash = 517044936)
public DictEntity(String dictCode, String dictSort, String dictLabel,
@Generated(hash = 794533722)
public DictEntity(String dictCode, int dictSort, String dictLabel,
String dictValue, String dictType, String cssClass, String listClass,
String isDefault, String status, String createBy, String createTime,
String updateBy, String updateTime, String remark) {
......@@ -102,7 +102,7 @@ public class DictEntity extends BaseObservable implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(dictCode);
dest.writeString(dictSort);
dest.writeInt(dictSort);
dest.writeString(dictLabel);
dest.writeString(dictValue);
dest.writeString(dictType);
......@@ -142,11 +142,11 @@ public class DictEntity extends BaseObservable implements Parcelable {
this.dictCode = dictCode;
}
public String getDictSort() {
public int getDictSort() {
return dictSort;
}
public void setDictSort(String dictSort) {
public void setDictSort(int dictSort) {
this.dictSort = dictSort;
}
......
......@@ -81,6 +81,8 @@ public class PerformanceVM extends BaseViewModel<Repository> {
private List<PerformanceEntity> uploadData;
private int dictIndex = -1;
public PerformanceVM(@NonNull Application application, Repository model) {
super(application, model);
......@@ -253,6 +255,65 @@ public class PerformanceVM extends BaseViewModel<Repository> {
Gson gson = new Gson();
PerformanceEntity performanceEntity = gson.fromJson(jsonObject, PerformanceEntity.class);
checkWeightRational(performanceEntity);
}
//检验是否重量大于上一次性能测定的称重
private void checkWeightRational(PerformanceEntity performanceEntity) {
List<DictEntity> ageDicts = LoginInfoUtils.getDistList("zxgl_performance_age");
dictIndex = -1;
for (int i = 0; i < ageDicts.size(); i++) {
if (performanceEntity.getAge().equals(ageDicts.get(i).getDictValue())) {
dictIndex = i;
dictIndex--;
break;
}
}
if(dictIndex==-1){
checkExistedAge(performanceEntity);
return;
}
QueryBuilder<PerformanceEntity> builder =
DbUtil.getInstance().getQueryBuilder(PerformanceEntity.class)
.where(PerformanceEntityDao.Properties.Weight.isNotNull()
, PerformanceEntityDao.Properties.CattleresumeId.eq(Configs.tempUnid)
);
DbUtil.getInstance().queryAsyncAll(PerformanceEntity.class, builder, new DbQueryCallBack<PerformanceEntity>() {
@Override
public void onSuccess(List<PerformanceEntity> result) {
if (result != null && !result.isEmpty()) {
outer:
for (int j = dictIndex; j < ageDicts.size(); j--) {
for (int i = 0; i < result.size(); i++) {
if (result.get(i).getAge().equals(ageDicts.get(j).getDictValue())) {
if (result.get(i).getWeight() != null) {
if (result.get(i).getWeight() > performanceEntity.getWeight()) {
ToastUtils.showShort("性能测定月龄重量必须高于上次称重!");
return;
}
break outer;
}
}
}
}
}
checkExistedAge(performanceEntity);
}
@Override
public void onFailed() {
ToastUtils.showShort("性能测定月龄数据-数据库查询失败");
}
});
}
private void checkExistedAge(PerformanceEntity performanceEntity) {
//查询此月龄是否存在,存在拿出主键 做覆盖
QueryBuilder<PerformanceEntity> builder =
DbUtil.getInstance().getQueryBuilder(PerformanceEntity.class)
......@@ -263,7 +324,7 @@ public class PerformanceVM extends BaseViewModel<Repository> {
@Override
public void onSuccess(List<PerformanceEntity> result) {
if (result != null && result.size() > 0) {
if (result != null && !result.isEmpty()) {
isModify = true;
Configs.resumeId = result.get(0).getUnid();
performanceEntity.setUnid(result.get(0).getUnid());
......@@ -280,7 +341,6 @@ public class PerformanceVM extends BaseViewModel<Repository> {
ToastUtils.showShort("性能测定月龄数据-数据库查询失败");
}
});
}
private void savePerformance(PerformanceEntity performanceEntity) {
......
......@@ -10,6 +10,7 @@ import com.phlx.anchorcollect_p.Configs;
import com.phlx.anchorcollect_p.data.Repository;
import com.phlx.anchorcollect_p.db.DbUtil;
import com.phlx.anchorcollect_p.db.gen.CattleResumeEntityDao;
import com.phlx.anchorcollect_p.db.gen.DictEntityDao;
import com.phlx.anchorcollect_p.db.interf.DbQueryCallBack;
import com.phlx.anchorcollect_p.entity.CattleResumeEntity;
import com.phlx.anchorcollect_p.entity.DictEntity;
......@@ -35,8 +36,10 @@ public class MainVM extends MainBarVM<Repository> {
}
public void init() {
Configs.dictList = DbUtil.getInstance().queryAll(DictEntity.class);
QueryBuilder<DictEntity> builder =
DbUtil.getInstance().getQueryBuilder(DictEntity.class)
.orderAsc(DictEntityDao.Properties.DictSort);
Configs.dictList = DbUtil.getInstance().queryAll(DictEntity.class, builder);
Configs.frozenSemenList = DbUtil.getInstance().queryAll(FrozenSemenEntity.class);
}
......
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