dangsn
2024-12-03 d0ae279ff3b83358d1c07f4481a041c4ad335026
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
package com.vci.web.controller;
 
import com.vci.corba.common.PLException;
import com.vci.dto.DeleteDataDTO;
import com.vci.dto.DeleteLinkDataDTO;
import com.vci.dto.FormDataDTO;
import com.vci.dto.FormLinkDataDTO;
import com.vci.starter.web.annotation.controller.VciUnCheckRight;
import com.vci.starter.web.annotation.log.VciBusinessLog;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.*;
import com.vci.pagemodel.ReferConfigVO;
import com.vci.pagemodel.UIFormDataVO;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.query.UIDataGridQuery;
import com.vci.query.UIFormQuery;
import com.vci.query.UITreeQuery;
import com.vci.web.service.UIDataServiceI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
 
import java.util.Arrays;
import java.util.List;
import java.util.Map;
 
/**
 * ui定义的数据查询
 * @author weidy
 * @date 2021/3/3
 */
@RestController
@RequestMapping("/uiDataController")
@VciBusinessLog(modelName="UI上下文")
public class WebUIDataController {
 
    /**
     * 界面的数据服务
     */
    @Autowired
    private UIDataServiceI uiDataService;
 
    /**
     * 日志
     */
    private Logger logger = LoggerFactory.getLogger(getClass());
 
    /**
     * 列表查询
     * @param dataGridQuery 查询对象
     * @return 列表数据
     */
    @PostMapping("/dataGridQuery")
    @VciUnCheckRight
    @VciBusinessLog(operateName = "列表数据的查询",description = "${param.btmname}里的${param.tableDefineId}")
    public DataGrid dataGrid(UIDataGridQuery dataGridQuery) throws PLException {
        return uiDataService.getDataForGrid(dataGridQuery);
    }
 
    /**
     * 表单的数据查询
     * @param formQuery 表单查询对象
     * @return 表单的数据
     */
    @PostMapping("/dataFormQuery")
    @VciUnCheckRight
    @VciBusinessLog(operateName = "表单的查询",description = "${param.btmname}里的${param.formDefineId}")
    public BaseResult<UIFormDataVO> getDataForForm(UIFormQuery formQuery){
        try {
            return BaseResult.success(uiDataService.getDataForForm(formQuery));
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "表单数据查询时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
 
    /**
     * 树的数据查询
     * @param treeQuery 树查询对象
     * @return 树的数据
     */
    @PostMapping("/getDataForTree")
    @VciUnCheckRight
    @VciBusinessLog(operateName = "树的查询",description = "${param.btmname}")
    public BaseResult getDataForTree(UITreeQuery treeQuery){
        try {
            return BaseResult.tree(uiDataService.getDataForTree(treeQuery));
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "树的数据查询出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
 
    /**
     * 根据查询模板查询数据,返回值按照页面定义
     * @param treeQuery 树查询对象
     * @return 树的数据
     */
    @PostMapping("/getDataByTemp")
    @VciUnCheckRight
    @VciBusinessLog(operateName = "查询")
    public BaseResult getDataByTemp(UITreeQuery treeQuery){
        try {
            return uiDataService.getDataByTemp(treeQuery);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "数据查询出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
 
    /**
     * 添加数据。前端使用JSON提交
     * @param formDataDTO 表单
     * @return 执行的结果
     */
    @PostMapping("/addSave")
    @VciUnCheckRight
    @VciBusinessLog(operateName = "添加数据",description = "${param.btmname}")
    public BaseResult<Map<String,Object>> addSave(@RequestBody FormDataDTO formDataDTO){
        try {
            return uiDataService.addSave(formDataDTO);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "添加数据时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
 
    /**
     * 添加链接类型数据。前端使用JSON提交
     * @param formLinkDataDTO 表单数据
     * @return 执行的结果
     */
    @PostMapping("/linkAddSave")
    @VciBusinessLog(operateName = "添加链接数据",description = "${param.linkType}")
    public BaseResult<String> linkAddSave(@RequestBody FormLinkDataDTO formLinkDataDTO){
        try {
            return uiDataService.linkAddSave(formLinkDataDTO);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "添加链接类型数据时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
 
    /**
     * 修改数据,前端使用JSON提交
     * @param formDataDTO 表单
     * @return 执行的结果
     */
    @PutMapping("/editSave")
    @VciUnCheckRight
    @VciBusinessLog(operateName = "修改数据",description = "${param.btmname}里的${param.oid}")
    public BaseResult<Map<String,Object>> editSave(@RequestBody FormDataDTO formDataDTO){
        try {
            return uiDataService.editSave(formDataDTO);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "修改数据时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
 
    /**
     * 修改链接类型的数据,前端使用JSON提交
     * @param formLinkDataDTO 表单的数据对象
     * @return 执行结果
     */
    @VciBusinessLog(operateName = "修改链接类型数据",description = "${param.linkType}里的${param.oid}")
    @PutMapping("/linkEditSave")
    public BaseResult linkEditSave(@RequestBody FormLinkDataDTO formLinkDataDTO){
        try {
            return uiDataService.linkEditSave(formLinkDataDTO);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "修改链接类型的数据时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
 
    /**
     * 数据升版本/次,前端使用JSON提交
     * @param formDataDTO 表单数据
     * @return 执行的结果
     */
    @PutMapping("/upRevision")
    @VciBusinessLog(operateName = "数据升版",description = "${param.btmname}里的${param.copyFromVersion}")
    public BaseResult<Map<String, Object>> upRevision(@RequestBody FormDataDTO formDataDTO) throws PLException {
        return uiDataService.upRevision(formDataDTO);
    }
 
    /**
     * 数据升版本/次,前端使用JSON提交
     * @param btmname 业务类型的信息
     * @param oid 业务数据的主键
     * @param type 1:版次对象;2:版本对象;3:主对象
     * @return 执行的结果
     */
    @DeleteMapping("/deleteBusinessObject")
    public BaseResult deleteBusinessObject(String btmname , String oid, int type) {
        try {
            return uiDataService.deleteBusinessObject(btmname, oid, type);
        }catch (PLException e){
            BaseResult<Object> objectBaseResult = new BaseResult<>();
            objectBaseResult.setCode(Integer.parseInt(e.code));
            objectBaseResult.setMsg(Arrays.toString(e.messages));
            return objectBaseResult;
        }
    }
 
    /**
     * 删除数据
     * @param deleteDataDTO 删除的数据,需要有oid和ts
     * @return 执行的结果
     */
    @DeleteMapping("/deleteData")
    //@VciUnCheckRight
    @VciBusinessLog(operateName = "删除数据",description = "${param.dataList.0.btmname}的${param.dataList.${join}.oid}")
    public BaseResult deleteData(@RequestBody DeleteDataDTO deleteDataDTO){
        try {
            return uiDataService.batchDelete(deleteDataDTO);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "删除数据时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
 
    /**
     * 删除链接类型数据
     * @param deleteLinkDataDTO 删除的数据
     * @return 执行的结果
     */
    @DeleteMapping("/linkDeleteData")
    @VciBusinessLog(operateName = "删除数据",description = "${param.dataList.0.linkType}的${param.dataList.${join}.oid}")
    public BaseResult linkDeleteData(@RequestBody DeleteLinkDataDTO deleteLinkDataDTO){
        return uiDataService.batchLinkDelete(deleteLinkDataDTO);
    }
 
    /**
     * 默认的参照列表
     * @param referConfigVO 参照的配置信息
     * @return 执行的结果
     */
    @GetMapping("/defaultReferDataGrid")
    @VciBusinessLog(operateName = "获取参照的列表数据",description = "")
    public DataGrid defaultReferDataGrid(ReferConfigVO referConfigVO,PageHelper pageHelper){
        try {
            return uiDataService.referDataGrid(referConfigVO,pageHelper);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "默认的参照列表时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
 
    /**
     * 默认的树形参照列表
     * @param referConfigVO 参照的配置信息
     * @return 执行的结果
     */
    @VciBusinessLog(operateName = "获取参照的树形数据",description = "")
    @GetMapping("/defaultReferTree")
    public List<Tree> defaultReferTree(ReferConfigVO referConfigVO){
        return uiDataService.referTree(referConfigVO);
    }
 
    /**
     * 表单的数据查询
     * @param btmname 业务类型的信息
     * @param oid 业务数据的主键
     * @return 业务数据的属性信息
     */
    @GetMapping("/getDataAttr")
    @VciBusinessLog(operateName = "获取当前业务数据的全部属性",description = "")
    public BaseResult getDataAttr(String btmname , String oid){
        List<Map<String,String>> dataMapList = uiDataService.getDataAttr(btmname, oid);
        if (CollectionUtils.isEmpty(dataMapList)){
            return BaseResult.fail("查询数据为空");
        }
        BaseResult re = BaseResult.success();
        re.setData(dataMapList);
        return re;
    }
    /**
     * 变更所有者
     * @param btmname 业务类型
     * @param oid 主键
     * @return 执行的结果
     */
    @PutMapping("/changeBusinessObjectOwner")
    public BaseResult changeBusinessObjectOwner(String btmname , String oid) {
        try {
            return uiDataService.changeBusinessObjectOwner(btmname, oid);
        } catch (PLException e) {
            BaseResult<Object> objectBaseResult = new BaseResult<>();
            objectBaseResult.setCode(Integer.parseInt(e.code));
            objectBaseResult.setMsg(Arrays.toString(e.messages));
            return objectBaseResult;
        }
    }
 
    /**
     * 状态跃迁
     * @param btmname 业务类型
     * @param oid 主键
     * @param releaseStatus 发布状态
     * @return 执行的结果
     */
    @PutMapping("/transferBusinessObject")
    public BaseResult transferBusinessObject(String btmname , String oid, String toStatus, String releaseStatus) {
        try {
            return uiDataService.transferBusinessObject(btmname, oid, toStatus, releaseStatus);
        } catch (PLException e) {
            BaseResult<Object> objectBaseResult = new BaseResult<>();
            objectBaseResult.setCode(Integer.parseInt(e.code));
            objectBaseResult.setMsg(Arrays.toString(e.messages));
            return objectBaseResult;
        }
    }
}