main
黄海 1 year ago
parent fa61f8a0b5
commit 0708a7f59b

@ -42,8 +42,9 @@ public class CollectModel {
* @return
*/
public int IS_THIRD_PARTY() {
GlobalModel model = new GlobalModel();
return Integer.parseInt(model.getGlobalValueByKey("third_party_base_data"));
//GlobalModel model = new GlobalModel();
//return Integer.parseInt(model.getGlobalValueByKey("third_party_base_data"));
return 0;
}
/**

@ -9,6 +9,16 @@ import java.util.List;
public class GlobalModel {
/**
*
*
* @return
*/
public String getInstallArea() {
String sql = "select COALESCE(global_value,'') as global_value from t_base_global where global_code = 'install_area'";
return Db.findFirst(sql).getStr("global_value");
}
/**
* KEYVALUE
*
@ -16,17 +26,13 @@ public class GlobalModel {
* @return
*/
public String getGlobalValueByKey(String key) {
String result = "";
try {
String sql = Db.getSql("global.getGlobalValueByKey");
List<Record> list = Db.find(sql, key);
if (list.size() > 0) {
result = list.get(0).getStr("global_value");
}
} catch (Exception e) {
e.printStackTrace();
String install_area = getInstallArea();
if (key.equals("install_area")) {//如果是获取安装地区
return install_area;
}
return result;
//获取当前安装地区,然后组装出查询条件
String sql = "select global_value from t_base_global where install_area=? and global_code=?";
return Db.findFirst(sql, install_area, key).getStr("global_value");
}
/**
@ -62,8 +68,9 @@ public class GlobalModel {
* @return
*/
public int checkGlobalCodeCount(String global_id, String globalCode) {
String sql = Db.getSql("global.checkGlobalCodeCount");
Record record = Db.find(sql, Integer.parseInt(global_id), globalCode).get(0);
String install_area = getInstallArea();
String sql = "select count(1) as c from t_base_global where global_id<>? and global_code=? and install_area=?";
Record record = Db.find(sql, Integer.parseInt(global_id), globalCode, install_area).getFirst();
return record.getInt("c");
}
@ -84,7 +91,7 @@ public class GlobalModel {
*/
public void updateGlobalById(String global_id, String global_type_id, String global_code, String global_value, String global_name, int sort_id) {
String sql = Db.getSql("global.updateGlobalById");
Db.update(sql,Integer.parseInt(global_type_id), global_code, global_value, global_name, sort_id, Integer.parseInt(global_id));
Db.update(sql, Integer.parseInt(global_type_id), global_code, global_value, global_name, sort_id, Integer.parseInt(global_id));
}
/**
@ -120,11 +127,12 @@ public class GlobalModel {
* @return
*/
public List<Record> getGlobalByCodes(String global_codesString) {
String install_area = getInstallArea();
List<Record> returnRecords = new ArrayList<>();
String sql = Db.getSql("global.getGlobalByCodes");
String[] global_codes = global_codesString.split(",");
for (int i = 0; i < global_codes.length; i++) {
List<Record> ilist = Db.find(sql, global_codes[i]);
List<Record> ilist = Db.find(sql, global_codes[i], install_area);
for (int j = 0; j < ilist.size(); j++) {
returnRecords.add(ilist.get(j));
}

@ -11,11 +11,6 @@
select global_id,global_type_id,global_code,global_value,global_name,sort_id from t_base_global order by sort_id
#end
-- 检查一个globalCode是不是重复
#sql("checkGlobalCodeCount")
select count(1) as c from t_base_global where global_id<>? and global_code=?
#end
-- 增加一个全局变量设置
#sql("addGlobal")
insert into t_base_global(global_type_id,global_code,global_value,global_name,sort_id) values(?,?,?,?,?)
@ -38,7 +33,7 @@
-- 传入一组global_code 返回对应的数据
#sql("getGlobalByCodes")
select global_id,global_type_id,global_code,global_value,global_name from t_base_global where global_code=?
select global_id,global_type_id,global_code,global_value,global_name from t_base_global where global_code=? and install_area=?
#end
-- 获取area_id通过area_name

Loading…
Cancel
Save