|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
package com.dsideal.QingLong.Collect.Controller;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.dsideal.QingLong.Collect.Model.CollectModel;
|
|
|
|
|
import com.dsideal.QingLong.Interceptor.IsLoginInterface;
|
|
|
|
|
import com.dsideal.QingLong.Interceptor.IsNumericInterface;
|
|
|
|
@ -146,8 +148,46 @@ public class CollectController extends Controller {
|
|
|
|
|
*/
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@IsLoginInterface({})
|
|
|
|
|
public void saveSheet() {
|
|
|
|
|
|
|
|
|
|
public void saveSheet(String json) {
|
|
|
|
|
JSONArray ja;
|
|
|
|
|
try {
|
|
|
|
|
ja = JSONArray.parseArray(json);
|
|
|
|
|
} catch (Exception err) {
|
|
|
|
|
Kv kv = Kv.create();
|
|
|
|
|
kv.set("success", false);
|
|
|
|
|
kv.set("message", "上报的json数据格式不正确,请检查后重传!");
|
|
|
|
|
renderJson(kv);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//遍历每行数据,根据data_type_id+ t_collect_datatype 表 ,修改 pg_data_type,web_data_type,excel_data_type三个属性
|
|
|
|
|
//然后再保存
|
|
|
|
|
List<Record> writeList = new ArrayList<>();
|
|
|
|
|
for (Object o : ja) {
|
|
|
|
|
JSONObject jo = (JSONObject) o;
|
|
|
|
|
int job_id = jo.getInteger("job_id");
|
|
|
|
|
int sheet_index = jo.getInteger("sheet_index");
|
|
|
|
|
int column_index = jo.getInteger("column_index");
|
|
|
|
|
int data_type_id = jo.getInteger("data_type_id");
|
|
|
|
|
String column_name = jo.getString("column_name");
|
|
|
|
|
String original_name = jo.getString("original_name");
|
|
|
|
|
boolean allow_blank = jo.getBoolean("allow_blank");
|
|
|
|
|
String options = jo.getString("options");
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
record.set("job_id", job_id);
|
|
|
|
|
record.set("sheet_index", sheet_index);
|
|
|
|
|
record.set("column_index", column_index);
|
|
|
|
|
record.set("data_type_id", data_type_id);
|
|
|
|
|
record.set("column_name", column_name);
|
|
|
|
|
record.set("original_name", original_name);
|
|
|
|
|
record.set("allow_blank", allow_blank);
|
|
|
|
|
record.set("options", options);
|
|
|
|
|
writeList.add(record);
|
|
|
|
|
}
|
|
|
|
|
cm.saveSheet(writeList);
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
map.put("success", true);
|
|
|
|
|
map.put("message", "保存成功!");
|
|
|
|
|
renderJson(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|