package com.xjrsoft.module.hikvision.util;

import cn.hutool.db.Db;
import com.alibaba.druid.sql.visitor.functions.Trim;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.xjrsoft.module.base.entity.BaseClass;
import com.xjrsoft.module.base.entity.BaseGrade;
import com.xjrsoft.module.organization.entity.Department;
import com.xjrsoft.module.personnel.entity.CarMessageApply;
import com.xjrsoft.module.system.entity.DictionaryDetail;
import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
import lombok.extern.slf4j.Slf4j;
import lombok.var;
import org.apache.velocity.runtime.directive.Foreach;
import org.springframework.beans.factory.annotation.Autowired;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @author dzx
 * @date 2024/5/10
 */
@Slf4j
public class DataUtil {
    /**
     * 同步组织数据
     * 只有批量添加接口，需要一个层级一个层级的添加
     */
    public Map<String, String> insertDepartment(Db db, String tableName, Map<String, String> tableData) throws Exception {
        String sql = "SELECT DISTINCT LENGTH(hierarchy) FROM " + tableName + " WHERE delete_mark = 0";
        List<Integer[]> list = db.query(sql, Integer[].class);
        Set<Integer> levelSet = new HashSet<>();
        for (Integer[] strings : list) {
            levelSet.add(strings[0]);
        }

        sql = "SELECT * FROM " + tableName + " WHERE delete_mark = 0 ORDER BY LENGTH(hierarchy)";
        List<Department> dataList = db.query(sql, Department.class);
        String apiPath = "/api/resource/v1/org/batch/add";
        Map<String, String> idMap = new HashMap<>();
        JsonParser jsonParser = new JsonParser();
        ApiUtil apiUtil = new ApiUtil();

        Map<String, String> idCodeMap = new HashMap<>();
        for (Integer level : levelSet) {
            JsonArray dataArray = new JsonArray();
            for (Department department : dataList) {
                if(tableData != null && tableData.containsKey(department.getId().toString())){
                    continue;
                }
                if(department.getHierarchy().length() == level){
                    JsonObject paramJson = new JsonObject();
                    paramJson.addProperty("clientId", department.getCode());
                    paramJson.addProperty("orgIndexCode", department.getId().toString());
                    paramJson.addProperty("orgName", department.getName());
                    paramJson.addProperty("parentIndexCode", department.getParentId().toString());
                    if(department.getParentId() == 0){
                        paramJson.addProperty("parentIndexCode", "root000000");
                    }
                    paramJson.addProperty("orgCode", department.getCode());
                    dataArray.add(paramJson);
                    idCodeMap.put(department.getCode(), department.getId().toString());
                }
            }
            String result = apiUtil.doPost(apiPath, dataArray.toString(), null, null);
            JsonElement parse = jsonParser.parse(result);

            JsonObject resultJson = parse.getAsJsonObject();
            if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
                JsonArray array = resultJson.get("data").getAsJsonObject().get("successes").getAsJsonArray();
                for (JsonElement jsonElement : array) {
                    JsonObject jsonObject = jsonElement.getAsJsonObject();
                    idMap.put(idCodeMap.get(jsonObject.get("clientId").getAsString()), jsonObject.get("orgIndexCode").getAsString());
                }
            }
        }
        //插入记录表
        insertRecord(db, tableName, idMap);
        return idMap;
    }

    /**
     * 推送学生班级信息
     */
    public Map<String, String> insertClass(Db db, String tableName, Map<String, String> tableData) throws SQLException {
        Map<String, String> idMap = new HashMap<>();
        //1、查询字典，将走读住读、班级类型先推送过去
        String sql = "SELECT * FROM xjr_dictionary_detail WHERE delete_mark = 0 AND item_id = 2023000000000000030";
        List<DictionaryDetail> detailList = db.query(sql, DictionaryDetail.class);

        String apiPath = "/api/resource/v1/org/batch/add";
        JsonParser jsonParser = new JsonParser();
        ApiUtil apiUtil = new ApiUtil();
        int clientId = 1;
        Map<Integer, String> idCodeMap = new HashMap<>();
        JsonArray dataArray = new JsonArray();

        Set<String> stduyStatus = new HashSet<>();

        for (DictionaryDetail dict : detailList) {
            if(tableData != null && tableData.containsKey(dict.getId().toString())){
                stduyStatus.add(dict.getId().toString());
                continue;
            }
            JsonObject paramJson = new JsonObject();
            paramJson.addProperty("clientId", clientId);
            paramJson.addProperty("orgIndexCode", dict.getCode());
            paramJson.addProperty("orgName", dict.getName() + "学生");
            paramJson.addProperty("parentIndexCode", "root000000");
            paramJson.addProperty("orgCode", dict.getCode());
            dataArray.add(paramJson);
            idCodeMap.put(clientId, dict.getCode());
            clientId ++;
        }
        String result = apiUtil.doPost(apiPath, dataArray.toString(), null, null);
        JsonElement parse = jsonParser.parse(result);

        JsonObject resultJson = parse.getAsJsonObject();
        if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
            JsonArray array = resultJson.get("data").getAsJsonObject().get("successes").getAsJsonArray();
            for (JsonElement jsonElement : array) {
                JsonObject jsonObject = jsonElement.getAsJsonObject();
                idMap.put(idCodeMap.get(jsonObject.get("clientId").getAsInt()), jsonObject.get("orgIndexCode").getAsString());
                stduyStatus.add(jsonObject.get("orgIndexCode").getAsString());
            }
        }
        //推送班级类型
        sql = "SELECT * FROM xjr_dictionary_detail WHERE delete_mark = 0 AND item_id = 2023000000000000039";
        detailList = db.query(sql, DictionaryDetail.class);
        dataArray = new JsonArray();
        Set<String> classTypeSet = new HashSet<>();
        for (String status : stduyStatus) {
            for (DictionaryDetail dict : detailList) {
                if(tableData != null && tableData.containsKey(dict.getCode())){
                    classTypeSet.add(dict.getCode());
                    continue;
                }
                JsonObject paramJson = new JsonObject();
                paramJson.addProperty("clientId", clientId);
                paramJson.addProperty("orgIndexCode", dict.getCode() + "-" + status);
                paramJson.addProperty("orgName", dict.getName());
                paramJson.addProperty("parentIndexCode", status);
                paramJson.addProperty("orgCode", dict.getCode());
                dataArray.add(paramJson);
                idCodeMap.put(clientId, dict.getCode() + "-" + status);
                clientId ++;
            }
        }

        result = apiUtil.doPost(apiPath, dataArray.toString(), null, null);
        parse = jsonParser.parse(result);
        resultJson = parse.getAsJsonObject();
        if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
            JsonArray array = resultJson.get("data").getAsJsonObject().get("successes").getAsJsonArray();
            for (JsonElement jsonElement : array) {
                JsonObject jsonObject = jsonElement.getAsJsonObject();
                idMap.put(idCodeMap.get(jsonObject.get("clientId").getAsInt()), jsonObject.get("orgIndexCode").getAsString());
                classTypeSet.add(jsonObject.get("orgIndexCode").getAsString());
            }
        }

        //推送年级
        sql = "SELECT * FROM base_grade WHERE delete_mark = 0 AND STATUS = 1";
        List<BaseGrade> gradeList = db.query(sql, BaseGrade.class);
        Map<Long, String> gradeNameMap = new HashMap<>();
        dataArray = new JsonArray();
        for (String classType : classTypeSet) {
            for (BaseGrade baseGrade : gradeList) {
                gradeNameMap.put(baseGrade.getId(), baseGrade.getName().replaceAll("级", ""));
                if(tableData != null && tableData.containsKey(baseGrade.getId().toString())){
                    continue;
                }
                JsonObject paramJson = new JsonObject();
                paramJson.addProperty("clientId", clientId);
                paramJson.addProperty("orgIndexCode", baseGrade.getName().replaceAll("级", "") + "-" + classType);
                paramJson.addProperty("orgName", baseGrade.getName());
                paramJson.addProperty("parentIndexCode", classType);
                paramJson.addProperty("orgCode", clientId);
                dataArray.add(paramJson);
                idCodeMap.put(clientId, baseGrade.getName().replaceAll("级", "") + "-" + classType);
                clientId ++;
            }
        }

        result = apiUtil.doPost(apiPath, dataArray.toString(), null, null);
        parse = jsonParser.parse(result);
        Set<String> gradeSet = new HashSet<>();
        resultJson = parse.getAsJsonObject();
        if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
            JsonArray array = resultJson.get("data").getAsJsonObject().get("successes").getAsJsonArray();
            for (JsonElement jsonElement : array) {
                JsonObject jsonObject = jsonElement.getAsJsonObject();
                idMap.put(idCodeMap.get(jsonObject.get("clientId").getAsInt()), jsonObject.get("orgIndexCode").getAsString());
                gradeSet.add(jsonObject.get("orgIndexCode").getAsString());
            }
        }

        //推送班级
        sql = "SELECT * FROM base_class WHERE delete_mark = 0 AND is_graduate = 1 AND class_type IS NOT NULL";
        List<BaseClass> classList = db.query(sql, BaseClass.class);

        dataArray = new JsonArray();
        for (String grade : gradeSet) {
            String[] gradeGroup = grade.split("-");
            for (BaseClass baseClass : classList) {
                if(tableData != null && tableData.containsKey(baseClass.getId().toString())){
                    continue;
                }
                String gradeName = gradeNameMap.get(baseClass.getGradeId());
                if(!gradeGroup[0].equals(gradeName)){
                    continue;
                }

                if(!gradeGroup[1].equals(baseClass.getClassType())){
                    continue;
                }
                JsonObject paramJson = new JsonObject();
                paramJson.addProperty("clientId", clientId);
                paramJson.addProperty("orgIndexCode", baseClass.getId() + "-" + grade);
                paramJson.addProperty("orgName", baseClass.getName());
                paramJson.addProperty("parentIndexCode", grade);
                paramJson.addProperty("orgCode", clientId);
                dataArray.add(paramJson);
                idCodeMap.put(clientId, baseClass.getId() + "-" + grade);
                clientId ++;
            }
        }

        result = apiUtil.doPost(apiPath, dataArray.toString(), null, null);
        parse = jsonParser.parse(result);
        resultJson = parse.getAsJsonObject();
        if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
            JsonArray array = resultJson.get("data").getAsJsonObject().get("successes").getAsJsonArray();
            for (JsonElement jsonElement : array) {
                JsonObject jsonObject = jsonElement.getAsJsonObject();
                idMap.put(idCodeMap.get(jsonObject.get("clientId").getAsInt()), jsonObject.get("orgIndexCode").getAsString());
            }
        }

        //插入记录表
        insertRecord(db, tableName, idMap);

        return idMap;
    }

    public Map<String, String> insertStudentOne(Db db, String tableName, Map<String, String> tableData) throws Exception {
        String sql = "SELECT t1.id,t1.name,CONCAT(t3.id,'-',replace(t4.name,'级',''),'-',t3.class_type,'-',t2.stduy_status)," +
                " t1.user_name,t1.gender,DATE_FORMAT(t1.birth_date, '%Y-%m-%d'),t1.mobile,t1.email,t1.credential_type,t1.credential_number FROM xjr_user t1" +
                " INNER JOIN base_student_school_roll t2 ON t1.id = t2.user_id" +
                " INNER JOIN base_class t3 ON t2.class_id = t3.id" +
                " INNER JOIN base_grade t4 ON t3.grade_id = t4.id" +
                " WHERE t1.delete_mark = 0 AND t2.delete_mark = 0 AND t3.class_type IS NOT NULL";
        List<String[]> list = db.query(sql, String[].class);
        Map<Integer, String> clientMap = new HashMap<>();

        String apiPath = "/api/resource/v2/person/single/add";
        Map<String, String> idMap = new HashMap<>();
        JsonParser jsonParser = new JsonParser();
        ApiUtil apiUtil = new ApiUtil();
        Map<String, String> header = new HashMap<>();
        header.put("tagId", "insert_student");

        for(int i = 1; i < list.size(); i ++){
            String[] el = list.get(i);
            if(tableData != null && tableData.containsKey(el[0])){
                continue;
            }
            JsonObject paramJson = new JsonObject();
            paramJson.addProperty("clientId", i);
            paramJson.addProperty("personId", el[0]);
            paramJson.addProperty("personName", el[1]);
            paramJson.addProperty("orgIndexCode", el[2]);
            paramJson.addProperty("phoneNo", el[6]);
            paramJson.addProperty("jobNo", el[3]);
            paramJson.addProperty("birthday", el[5]);
            paramJson.addProperty("personType", 2);

            int gender;
            switch (el[4]) {
                case "SB10001":
                    gender = 1;
                    break;
                case "SB10002":
                    gender = 2;
                    break;
                default:
                    gender = 0;
                    break;
            }
            paramJson.addProperty("gender", gender);

            clientMap.put(i, el[0]);
            System.out.println("入参：" + paramJson.toString());
            String result = apiUtil.doPost(apiPath, paramJson.toString(), null, header);
            JsonElement parse = jsonParser.parse(result);
            JsonObject resultJson = parse.getAsJsonObject();
            if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
                JsonObject array = resultJson.get("data").getAsJsonObject();
                idMap.put(el[0], array.get("personId").getAsString());
            }
        }

        //插入记录表
        insertRecord(db, tableName, idMap);
        return idMap;
    }

    public Map<String, String> insertStudent(Db db, String tableName, Map<String, String> tableData) throws Exception {
        String sql = "SELECT t1.id,t1.name,CONCAT(t3.id,'-',t4.name,'-',t3.class_type,'-',t2.stduy_status)," +
                " t1.user_name,t1.gender,t1.birth_date,t1.mobile,t1.email,t1.credential_type,t1.credential_number FROM xjr_user t1" +
                " INNER JOIN base_student_school_roll t2 ON t1.id = t2.user_id" +
                " INNER JOIN base_class t3 ON t2.class_id = t3.id" +
                " INNER JOIN base_grade t4 ON t3.grade_id = t4.id" +
                " WHERE t1.delete_mark = 0 AND t2.delete_mark = 0 AND t3.class_type IS NOT NULL ";
        List<String[]> list = db.query(sql, String[].class);
        Map<Integer, String> clientMap = new HashMap<>();

        String apiPath = "/api/resource/v1/person/batch/add";
        Map<String, String> idMap = new HashMap<>();
        JsonParser jsonParser = new JsonParser();
        ApiUtil apiUtil = new ApiUtil();
        Map<String, String> header = new HashMap<>();
        header.put("tagId", "insert_student");

        int maxCount = 100;

        int frequency = list.size() / maxCount;
        for(int index = 0; index < frequency; index ++){
            JsonArray paramArray = new JsonArray();

            for(int i = (index * maxCount); i < ((index + 1) * maxCount); i ++){
                if(i >= list.size()){
                    continue;
                }
                String[] el = list.get(i);
                if(tableData != null && tableData.containsKey(el[0])){
                    continue;
                }
                JsonObject paramJson = new JsonObject();
                paramJson.addProperty("clientId", i);
                paramJson.addProperty("personId", el[0]);
                paramJson.addProperty("personName", el[1]);
                paramJson.addProperty("orgIndexCode", el[2]);
                paramJson.addProperty("phoneNo", el[6]);
                paramJson.addProperty("jobNo", el[3]);
                paramJson.addProperty("birthday", el[5]);
                paramJson.addProperty("personType", 2);

                int gender;
                switch (el[4]) {
                    case "SB10001":
                        gender = 1;
                        break;
                    case "SB10002":
                        gender = 2;
                        break;
                    default:
                        gender = 0;
                        break;
                }
                paramJson.addProperty("gender", gender);
                paramArray.add(paramJson);

                clientMap.put(i, el[0]);
            }

            String result = apiUtil.doPost(apiPath, paramArray.toString(), null, header);
            JsonElement parse = jsonParser.parse(result);
            JsonObject resultJson = parse.getAsJsonObject();
            if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
                JsonArray array = resultJson.get("data").getAsJsonObject().get("successes").getAsJsonArray();
                for (JsonElement jsonElement : array) {
                    JsonObject jsonObject = jsonElement.getAsJsonObject();
                    idMap.put(clientMap.get(jsonObject.get("clientId").getAsInt()), jsonObject.get("personId").getAsString());
                }
            }
        }

        //插入记录表
        insertRecord(db, tableName, idMap);
        return idMap;
    }

    public Map<String, String> insertTeacher(Db db, String tableName, Map<String, String> tableData, Map<String, String> deptMap) throws Exception {
        String sql = "SELECT t1.id,t1.name,t1.gender,t3.dept_id,t1.birth_date,t1.mobile,t1.email,t1.credential_type,t1.credential_number,t1.user_name FROM xjr_user t1" +
                " INNER JOIN " + tableName + " t2 ON t1.id = t2.user_id" +
                " INNER JOIN xjr_user_dept_relation t3 ON t1.id = t3.user_id" +
                " INNER JOIN xjr_department t4 ON t3.dept_id = t4.id " +
                " WHERE t1.delete_mark = 0 AND t2.delete_mark = 0 AND t4.delete_mark = 0";
        List<String[]> list = db.query(sql, String[].class);
        JsonArray paramArray = new JsonArray();
        Map<Integer, String> clientMap = new HashMap<>();
        for(int i = 0; i < list.size(); i ++){
            String[] el = list.get(i);
            if(tableData != null && tableData.containsKey(el[0])){
                continue;
            }
            JsonObject paramJson = new JsonObject();
            paramJson.addProperty("clientId", i);
            paramJson.addProperty("personId", el[0]);
            paramJson.addProperty("personName", el[1]);
            paramJson.addProperty("orgIndexCode", deptMap.get(el[3]));
            paramJson.addProperty("phoneNo", el[5]);
            paramJson.addProperty("jobNo", el[9]);
            paramJson.addProperty("birthday", el[4]);
            paramJson.addProperty("personType", 1);

            int gender;
            switch (el[2]) {
                case "SB10001":
                    gender = 1;
                    break;
                case "SB10002":
                    gender = 2;
                    break;
                default:
                    gender = 0;
                    break;
            }
            paramJson.addProperty("gender", gender);
            paramArray.add(paramJson);

            clientMap.put(i, el[0]);
        }

        String apiPath = "/api/resource/v1/person/batch/add";
        Map<String, String> idMap = new HashMap<>();
        JsonParser jsonParser = new JsonParser();
        ApiUtil apiUtil = new ApiUtil();
        Map<String, String> header = new HashMap<>();
        header.put("tagId", "insert_teacher");

        String result = apiUtil.doPost(apiPath, paramArray.toString(), null, header);
        JsonElement parse = jsonParser.parse(result);
        JsonObject resultJson = parse.getAsJsonObject();
        if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
            JsonArray array = resultJson.get("data").getAsJsonObject().get("successes").getAsJsonArray();
            for (JsonElement jsonElement : array) {
                JsonObject jsonObject = jsonElement.getAsJsonObject();
                idMap.put(clientMap.get(jsonObject.get("clientId").getAsInt()), jsonObject.get("personId").getAsString());
            }
        }else{

        }
        //插入记录表
        insertRecord(db, tableName, idMap);
        return idMap;
    }

    /*同步车辆数据*/
    public Map<Long, String> insertCar(Db db, String tableName, Map<String, String> tableData, FaceImportMapper faceImportMapper) throws Exception {
        String sql = "SELECT * FROM " + tableName + " WHERE delete_mark = 0 and status = 1";
        List<CarMessageApply> dataList = db.query(sql, CarMessageApply.class);
        String apiPath = "/api/resource/v1/vehicle/batch/add";
        String apiPathTime = "/api/pms/v1/car/charge";
        Map<Long, String> idMap = new HashMap<>();
        JsonParser jsonParser = new JsonParser();
        ApiUtil apiUtil = new ApiUtil();

        Map<Integer, Long> clientMap = new HashMap<>();
        Map<String, String> tagMap = new HashMap<>();
        tagMap.put("tagId", "frs");

        String existingPlatesSql = "SELECT source_id FROM hikvision_data";
        List<String> existingPlates = db.query(existingPlatesSql, String.class);

        JsonArray dataArray = new JsonArray();
        String result = null;
        int clientId = 1;
        for (CarMessageApply carMessageApply : dataList) {
            if(existingPlates.contains(carMessageApply.getId() + "")){
                continue;
            }

            JsonObject paramJson = new JsonObject();
            paramJson.addProperty("clientId", clientId);
            paramJson.addProperty("plateNo", carMessageApply.getCarNumber().trim());
            paramJson.addProperty("personId", faceImportMapper.GetHikvisonPersonId(carMessageApply.getId().toString()));

            int vehicleTypeNum;
            switch (carMessageApply.getVehicleType()) {
                case "小型车":
                    vehicleTypeNum = 1;
                    break;
                case "大型车":
                    vehicleTypeNum = 2;
                    break;
                case "摩托车":
                    vehicleTypeNum = 3;
                    break;
                default:
                    vehicleTypeNum = 0;
                    break;
            }
            paramJson.addProperty("vehicleType", vehicleTypeNum);
            clientMap.put(clientId, carMessageApply.getId());
            dataArray.add(paramJson);
            clientId++;
        }
        result = apiUtil.doPost(apiPath, dataArray.toString(), tagMap, null);

        for (CarMessageApply carMessageApply : dataList) {
            JsonObject paramJsonTime = new JsonObject();
            paramJsonTime.addProperty("parkSyscode", "c69f2a7c48a74216bcab7d65f24d4a09");
            paramJsonTime.addProperty("plateNo", carMessageApply.getCarNumber().trim());
            paramJsonTime.addProperty("startTime", String.valueOf(carMessageApply.getStartTime()));
            paramJsonTime.addProperty("endTime", String.valueOf(carMessageApply.getEndTime()));
            apiUtil.doPost(apiPathTime, String.valueOf(paramJsonTime), tagMap, null);
        }

        JsonElement parse = jsonParser.parse(result);
        JsonObject resultJson = parse.getAsJsonObject();
        if ("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())) {
            JsonArray array = resultJson.get("data").getAsJsonObject().get("successes").getAsJsonArray();
            for (JsonElement jsonElement : array) {
                JsonObject jsonObject = jsonElement.getAsJsonObject();
                int responseClientId = jsonObject.get("clientId").getAsInt();
                Long sourceId = clientMap.get(responseClientId);
                if (sourceId != null) {
                    idMap.put(sourceId, jsonObject.get("vehicleId").getAsString());
                } else {
                    System.err.println("No matching clientId found in clientMap for: " + responseClientId);
                }
            }
            insertRecord(db, tableName, idMap);
        } else {
            System.err.println("API call failed: " + resultJson.get("msg").getAsString());
        }
        return idMap;
    }

    void insertRecord(Db db, String tableName, Map<?, String> idsMap) throws SQLException {
        if (idsMap.isEmpty()) {
            return;
        }
        var sqls = new ArrayList<String>();
        for (var entry : idsMap.entrySet()) {
            var sourceId = entry.getKey();
            var sql = "INSERT INTO hikvision_data(create_date, table_name, source_id, hikvision_id) " +
                    "VALUES(now(), '" + tableName + "', '" + sourceId + "', '" + entry.getValue() + "')";
            sqls.add(sql);
        }
        db.executeBatch(sqls);
    }

//    void insertRecord(Db db, String tableName, Map<Long, String> idsMap) throws SQLException {
//        if(idsMap.isEmpty()){
//            return;
//        }
//        List<String> sqls = new ArrayList<>();
//        for (Long sourceId : idsMap.keySet()) {
//            String sql = "INSERT INTO hikvision_data(create_date,table_name,source_id,hikvision_id) value(now(),'"
//                    + tableName + "'," + sourceId + ",'" + idsMap.get(sourceId) + "')";
//            sqls.add(sql);
//        }
//        db.executeBatch(sqls);
//    };
}
