许鹏程
6 天以前 929e9fedb97a88ef122100e03f775fedae79c474
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package om.product.mobile.test;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
 
import com.product.admin.config.SystemCode;
import com.product.common.lang.StringUtils;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.mobile.core.service.ApplicationsService;
import com.product.mobile.core.service.SystemTableMetaService;
import com.product.module.sys.version.ApiVersion;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONArray;
 
/**
 * App指定表结构信息
 *
 * @author shicf
 */
@RequestMapping("/api/mobile")
@RestController
public class SystemTableMetaController extends AbstractBaseController {
    @Autowired
    SystemTableMetaService systemTableMetaService;
 
    /**
     * 获取指定表的数据结构信息
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/system/table/list-meta/{version}", method = RequestMethod.POST)
    @ApiVersion(2)
    public String tableMetaList(HttpServletRequest request) {
        FieldSetEntity fse = null;
        Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
        if (bean != null) {
            RequestParameterEntity reqp = (RequestParameterEntity) bean;
            fse = reqp.getFormData();
        }
        if (bean == null || fse == null) {
            SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
        }
        return this.OK_List(systemTableMetaService.getSystemTableMeta(fse));
    }
    
    /**
     * 返回数据库初始表
     * @return
     */
    public static String initTableMeta() {
        
        JSONObject data=new JSONObject();
        data.put("message", "成功");
        data.put("~table~", "product_sys_datamodel_field");
        data.put("success", true);
        JSONArray devices=new JSONArray();
        data.put("device_archives", devices);
        
        JSONObject device_name=new JSONObject();
        devices.add(device_name);
        device_name.put("field_name","device_name");
        device_name.put("field_show_name", "设备名称");
        device_name.put("field_reference", "");
        device_name.put("field_type", "string");
        device_name.put("field_length", 200);
        device_name.put("is_more_value", 0);
        
        JSONObject device_number=new JSONObject();
        devices.add(device_number);
        device_number.put("field_name","device_number");
        device_number.put("field_show_name", "设备编码");
        device_number.put("field_reference", "");
        device_number.put("field_type", "string");
        device_number.put("field_length", 100);
        device_number.put("is_more_value", 0);
        
        JSONObject specification_model=new JSONObject();
        devices.add(specification_model);
        specification_model.put("field_name","specification_model");
        specification_model.put("field_show_name", "规格型号");
        specification_model.put("field_reference", "");
        specification_model.put("field_type", "string");
        specification_model.put("field_length", 200);
        specification_model.put("is_more_value", 0);
        
        JSONObject run_status=new JSONObject();
        devices.add(run_status);
        run_status.put("field_name","run_status");
        run_status.put("field_show_name", "运行状态");
        run_status.put("field_reference", "《DEVICE-RUN-STATUS》");//code------
        run_status.put("field_type", "int");
        run_status.put("field_length", 200);
        run_status.put("is_more_value", 0);
        
        JSONObject status=new JSONObject();
        devices.add(status);
        status.put("field_name","status");
        status.put("field_show_name", "设备状态");
        status.put("field_reference", "《DEVICE-STATUS》"); //code------
        status.put("field_type", "int");
        status.put("field_length", 200);
        status.put("is_more_value", 0);
        
        JSONObject company_id=new JSONObject();
        devices.add(company_id);
        company_id.put("field_name","company_id");
        company_id.put("field_show_name", "所属公司");
        company_id.put("field_reference", "orgs");  //code------
        company_id.put("field_type", "int");
        company_id.put("field_length", 300);
        company_id.put("is_more_value", 0);
        
        JSONObject use_dept_id=new JSONObject();
        devices.add(use_dept_id);
        use_dept_id.put("field_name","use_dept_id");
        use_dept_id.put("field_show_name", "使用部门");
        use_dept_id.put("field_reference", "orgss"); //code------
        use_dept_id.put("field_type", "int");
        use_dept_id.put("field_length", 300);
        use_dept_id.put("is_more_value", 0);
        
        JSONObject plant=new JSONObject();
        devices.add(plant);
        plant.put("field_name","plant");
        plant.put("field_show_name", "所属工厂");
        plant.put("field_reference", "orgs"); //code------
        plant.put("field_type", "int");
        plant.put("field_length", 300);
        plant.put("is_more_value", 0);
        
        JSONObject workshop=new JSONObject();
        devices.add(workshop);
        workshop.put("field_name","workshop");
        workshop.put("field_show_name", "车间");
        workshop.put("field_reference", "orgs");  //------
        workshop.put("field_type", "int");
        workshop.put("field_length", 300);
        workshop.put("is_more_value", 0);
        
        JSONObject device_manager=new JSONObject();
        devices.add(device_manager);
        device_manager.put("field_name","device_manager");
        device_manager.put("field_show_name", "设备管理员");
        device_manager.put("field_reference", "users");  //------
        device_manager.put("field_type", "int");
        device_manager.put("field_length", 300);
        device_manager.put("is_more_value", 0);
        
        
        
        
        return data.toJSONString();
    }
}