lmw
2024-09-04 a3bc6aa4fa3bad787c9fc366d6904f60265eec3b
app/src/main/java/com/lotaai/canguiayw/sqllitedb/SqlliteDbManage.java
@@ -1,7 +1,6 @@
package com.lotaai.canguiayw.sqllitedb;
import com.blankj.utilcode.util.LogUtils;
import com.lotaai.canguiayw.application.ActivityLifecycleApplcation;
import com.lotaai.canguiayw.application.App;
import com.lotaai.canguiayw.device.service.CrontrolGridModel;
import org.greenrobot.greendao.query.QueryBuilder;
@@ -23,7 +22,7 @@
    }
    private DaoSession getDaoSession() {
        DaoSession daoSession = ActivityLifecycleApplcation.getInstance().getDaoSession();
        DaoSession daoSession = App.getInstance().getDaoSession();
        return daoSession;
    }
@@ -35,6 +34,21 @@
    public void insertOrderInfo(Order model) {
        DaoSession daoSession = getDaoSession();
        daoSession.insertOrReplace(model);
    }
    public void deleteFromOrderByGridNo(String gridNo){
        DaoSession daoSession = getDaoSession();
        QueryBuilder<Order> qb = daoSession.queryBuilder(Order.class);
        QueryBuilder<Order> queryBuilder
                = qb.where(OrderDao.Properties.GridNo.eq(gridNo)).orderAsc(OrderDao.Properties.TakeCode);
        List<Order> ordersList = queryBuilder.list();
        if (ordersList!=null && ordersList.size()>0){
            for (int i = 0; i < ordersList.size(); i++){
                Order order = ordersList.get(i);
                daoSession.delete(order);
            }
        }
    }
    /**
@@ -225,6 +239,23 @@
        return gridModels;
    }
    public void updateGridByStr(String gridNo,int state){
        CrontrolGridModel model = new CrontrolGridModel();
        model.ChangeGrid(gridNo);
        DaoSession daoSession = getDaoSession();
        QueryBuilder<GridModel> qb = daoSession.queryBuilder(GridModel.class);
        QueryBuilder<GridModel> queryBuilder
                = qb.where(GridModelDao.Properties.GridNo.eq(model.getGridNo()),GridModelDao.Properties.GuiHao.eq(model.getGuiNo())).orderAsc(GridModelDao.Properties.GuiHao);
        List<GridModel> gridModels = queryBuilder.list();
        if (gridModels != null || gridModels.size() > 0) {
             for (int i = 0; i < gridModels.size();i++){
                 GridModel mm = gridModels.get(i);
                 mm.setState(state);
                 daoSession.update(mm);
             }
        }
    }
    public GridModel  selectFreeGrid(){
        DaoSession daoSession = getDaoSession();
        QueryBuilder<GridModel> qb = daoSession.queryBuilder(GridModel.class);