田源
2025-01-16 a13255b4129ee8a7a7b7e1ecd8e02dd2c78f7c17
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebUIDataController.java
@@ -1,26 +1,32 @@
package com.vci.web.controller;
import com.alibaba.fastjson.JSON;
import com.vci.corba.common.PLException;
import com.vci.corba.query.data.KV;
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.web.query.UIDataGridQuery;
import com.vci.web.query.UIFormQuery;
import com.vci.web.query.UITreeQuery;
import com.vci.web.service.UIDataServiceI;
import com.vci.starter.web.util.Lcm.Func;
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.uidataservice.UIDataCommonServiceI;
import com.vci.web.util.PlatformClientUtil;
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;
import java.util.*;
/**
 * ui定义的数据查询
@@ -36,7 +42,12 @@
     * 界面的数据服务
     */
    @Autowired
    private UIDataServiceI uiDataService;
    private UIDataCommonServiceI uiDataService;
    /**
     * 日志
     */
    private Logger logger = LoggerFactory.getLogger(getClass());
    /**
     * 列表查询
@@ -44,10 +55,17 @@
     * @return 列表数据
     */
    @PostMapping("/dataGridQuery")
    @VciUnCheckRight
    //@VciUnCheckRight
    @VciBusinessLog(operateName = "列表数据的查询",description = "${param.btmname}里的${param.tableDefineId}")
    public DataGrid dataGrid(UIDataGridQuery dataGridQuery){
        return uiDataService.getDataForGrid(dataGridQuery);
    public BaseResult dataGrid(UIDataGridQuery dataGridQuery) throws Exception {
        try {
            return BaseResult.dataGrid(uiDataService.getDataForGrid(dataGridQuery));
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "表单数据查询时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
    /**
@@ -56,10 +74,17 @@
     * @return 表单的数据
     */
    @PostMapping("/dataFormQuery")
    @VciUnCheckRight
    //@VciUnCheckRight
    @VciBusinessLog(operateName = "表单的查询",description = "${param.btmname}里的${param.formDefineId}")
    public BaseResult<UIFormDataVO> getDataForForm(UIFormQuery formQuery){
        return BaseResult.success(uiDataService.getDataForForm(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);
        }
    }
    /**
@@ -68,10 +93,66 @@
     * @return 树的数据
     */
    @PostMapping("/getDataForTree")
    @VciUnCheckRight
    //@VciUnCheckRight
    @VciBusinessLog(operateName = "树的查询",description = "${param.btmname}")
    public List<Tree> getDataForTree(UITreeQuery treeQuery){
        return uiDataService.getDataForTree(treeQuery);
    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);
        }
    }
    /**
     * 测试自定义URL方式查询
     * @param dataGridQuery
     * @return
     */
    @PostMapping("/getTestPartQueryList")
    public BaseResult getTestPartQueryList(UIDataGridQuery dataGridQuery) throws PLException {
        PlatformClientUtil platformClientUtil = new PlatformClientUtil();
        String sql = "select * from " + VciBaseUtil.getTableName(dataGridQuery.getBtmName())
                + " where oid in ('D5DFA9D3-D2AF-4D1D-850F-73B102532740','BCE5B0E3-A49C-2453-8E62-8F4C7F4BEDF2','257BB15B-12CF-68D2-FCFE-1FA3E29DBD1E')";
        KV[][] kvs = platformClientUtil.getQueryService().queryBySql(sql);
        List<Map<String, Object>> resulListMap = new ArrayList<>();
        for (KV[] kvArray : kvs) {
            Map<String, Object> map = new HashMap<>();
            for (KV kv : kvArray) {
                if (kv.key != null && kv.value != null) {
                    //返回全小写的
                    map.put(kv.key.toLowerCase(Locale.ROOT), kv.value);
                }
            }
            resulListMap.add(map);
        }
        DataGrid dataGrid = new DataGrid();
        dataGrid.setData(resulListMap);
        dataGrid.setTotal(resulListMap.size());
        // TODO: 2024/12/5 Ludc 这儿还可以按照dataGridQuery.getTableDefineId()来查询表格定义的内容,
        //  然后根据配置的页面信息来处理要查询条件或列以及返回的参数
        return BaseResult.dataGrid(dataGrid);
    }
    /**
     * 根据查询模板查询数据,返回值按照页面定义
     * @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);
        }
    }
    /**
@@ -80,10 +161,17 @@
     * @return 执行的结果
     */
    @PostMapping("/addSave")
    @VciUnCheckRight
    //@VciUnCheckRight
    @VciBusinessLog(operateName = "添加数据",description = "${param.btmname}")
    public BaseResult<Map<String,Object>> addSave(@RequestBody FormDataDTO formDataDTO){
        return uiDataService.addSave(formDataDTO);
        try {
            return uiDataService.addSave(formDataDTO);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "添加数据时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
    /**
@@ -94,7 +182,14 @@
    @PostMapping("/linkAddSave")
    @VciBusinessLog(operateName = "添加链接数据",description = "${param.linkType}")
    public BaseResult<String> linkAddSave(@RequestBody FormLinkDataDTO formLinkDataDTO){
        return uiDataService.linkAddSave(formLinkDataDTO);
        try {
            return uiDataService.linkAddSave(formLinkDataDTO);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "添加链接类型数据时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
    /**
@@ -106,7 +201,14 @@
    @VciUnCheckRight
    @VciBusinessLog(operateName = "修改数据",description = "${param.btmname}里的${param.oid}")
    public BaseResult<Map<String,Object>> editSave(@RequestBody FormDataDTO formDataDTO){
        return uiDataService.editSave(formDataDTO);
        try {
            return uiDataService.editSave(formDataDTO);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "修改数据时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
    /**
@@ -117,7 +219,14 @@
    @VciBusinessLog(operateName = "修改链接类型数据",description = "${param.linkType}里的${param.oid}")
    @PutMapping("/linkEditSave")
    public BaseResult linkEditSave(@RequestBody FormLinkDataDTO formLinkDataDTO){
        return uiDataService.linkEditSave(formLinkDataDTO);
        try {
            return uiDataService.linkEditSave(formLinkDataDTO);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "修改链接类型的数据时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
    /**
@@ -156,10 +265,17 @@
     * @return 执行的结果
     */
    @DeleteMapping("/deleteData")
    @VciUnCheckRight
    //@VciUnCheckRight
    @VciBusinessLog(operateName = "删除数据",description = "${param.dataList.0.btmname}的${param.dataList.${join}.oid}")
    public BaseResult deleteData(@RequestBody DeleteDataDTO deleteDataDTO){
        return uiDataService.batchDelete(deleteDataDTO);
        try {
            return uiDataService.batchDelete(deleteDataDTO);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "删除数据时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
    /**
@@ -181,7 +297,14 @@
    @GetMapping("/defaultReferDataGrid")
    @VciBusinessLog(operateName = "获取参照的列表数据",description = "")
    public DataGrid defaultReferDataGrid(ReferConfigVO referConfigVO,PageHelper pageHelper){
        return uiDataService.referDataGrid(referConfigVO,pageHelper);
        try {
            return uiDataService.referDataGrid(referConfigVO,pageHelper);
        }catch (Exception e){
            e.printStackTrace();
            String errorMsg = "默认的参照列表时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e);
            logger.error(errorMsg);
            throw new VciBaseException(errorMsg);
        }
    }
    /**
@@ -212,6 +335,7 @@
        re.setData(dataMapList);
        return re;
    }
    /**
     * 变更所有者
     * @param btmname 业务类型
@@ -248,4 +372,5 @@
            return objectBaseResult;
        }
    }
}