数据初始化修改
parent
6919173bc3
commit
ac7c0e5ef7
|
|
@ -20,8 +20,6 @@ public class InitDataController extends Controller {
|
|||
public void initData(){
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
|
||||
Integer supermarket_type = getInt("supermarket_type",0);
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
if (tokenuser == null) {
|
||||
|
|
@ -29,7 +27,7 @@ public class InitDataController extends Controller {
|
|||
return;
|
||||
}
|
||||
|
||||
renderJson(InitDataSyncService.me.syncData(supermarket_id,supermarket_type));
|
||||
renderJson(InitDataSyncService.me.syncData(supermarket_id));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class InitDataSyncService extends BaseSyncService {
|
|||
tableMap.put("product_price_modify", "商品单价修改-包括砂站商品单价和客户自定义单价");
|
||||
tableMap.put("stock", "订单相关 - 销售点库存量");
|
||||
tableMap.put("stock_modify_log", "订单相关 - 手动修改库存记录");
|
||||
tableMap.put("supermarket", "基础配置 - 销售点(超市)");
|
||||
// tableMap.put("supermarket", "基础配置 - 销售点(超市)");
|
||||
tableMap.put("supermarket_customer_distance", "基础配置 - 超市到客户的距离");
|
||||
tableMap.put("supermarket_product", "基础配置 - 超市关联 product 表");
|
||||
tableMap.put("supermarket_receiver_distance", "基础配置 - 客户收获地址到每个超市的距离");
|
||||
|
|
@ -79,7 +79,7 @@ public class InitDataSyncService extends BaseSyncService {
|
|||
tableIdMap.put("truck_weight_limit", "truck_license");
|
||||
}
|
||||
|
||||
public String syncData(Integer supermarketId,Integer supermarket_type) {
|
||||
public String syncData(Integer supermarketId) {
|
||||
log.info("超市%s开始初始化数据", supermarketId);
|
||||
StringBuilder str = new StringBuilder();
|
||||
|
||||
|
|
@ -90,34 +90,39 @@ public class InitDataSyncService extends BaseSyncService {
|
|||
try {
|
||||
// 需要查询的表名
|
||||
Set<String> tables = tableMap.keySet();
|
||||
StringBuilder str = new StringBuilder();
|
||||
// 遍历每个表,查询数据
|
||||
for (String table : tables) {
|
||||
// 查询表中的数据
|
||||
List<Record> records = Db.find("SELECT * FROM " + table);
|
||||
|
||||
if (!records.isEmpty()) {
|
||||
JSONObject tableData = new JSONObject();
|
||||
tableData.put("pks", tableIdMap.containsKey(table) ? tableIdMap.get(table) : "id");
|
||||
tableData.put("data", records.stream().map(Record::getColumns).collect(Collectors.toList()));
|
||||
JSONObject saveData = new JSONObject();
|
||||
saveData.put(table, tableData);
|
||||
|
||||
// 创建 sync_task 记录
|
||||
SyncTask syncTask = new SyncTask();
|
||||
syncTask.setSupermarketId(supermarketId);
|
||||
syncTask.setSaveData(saveData.toJSONString());
|
||||
|
||||
SyncTaskService.me.save(syncTask, supermarketId);
|
||||
}
|
||||
// 将结果追加到局部变量 str 中
|
||||
str.append("同步" + tableMap.get(table) + "数据" + records.size() + TIAO);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (ret) {
|
||||
return str.toString();
|
||||
} else {
|
||||
return "同步失败";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return "同步失败";
|
||||
|
|
|
|||
Loading…
Reference in New Issue