Browse Source

获取候选人

Gogs 4 years ago
parent
commit
5121c0554f

+ 14 - 4
boman-api/boman-domain/src/main/java/com.boman.domain/dto/AjaxResult.java

@@ -15,6 +15,9 @@ public class AjaxResult extends HashMap<String, Object>
     /** 状态码 */
     public static final String CODE_TAG = "code";
 
+    /** 兼容流程服务器 */
+    public static final String RESULT_CODE_TAG = "resultCode";
+
     /** 返回内容 */
     public static final String MSG_TAG = "msg";
 
@@ -47,12 +50,19 @@ public class AjaxResult extends HashMap<String, Object>
      * @param msg 返回内容
      * @param data 数据对象
      */
-    public AjaxResult(int code, String msg, Object data)
-    {
+    public AjaxResult(int code, String msg, Object data) {
+        super.put(CODE_TAG, code);
+        super.put(MSG_TAG, msg);
+        if (null != data) {
+            super.put(DATA_TAG, data);
+        }
+    }
+
+    public AjaxResult(int code, int resultCode, String msg, Object data) {
         super.put(CODE_TAG, code);
+        super.put(RESULT_CODE_TAG, resultCode);
         super.put(MSG_TAG, msg);
-        if (null != data)
-        {
+        if (null != data) {
             super.put(DATA_TAG, data);
         }
     }

+ 23 - 0
boman-api/boman-domain/src/main/java/com.boman.domain/dto/FormDataDto.java

@@ -14,6 +14,10 @@ import java.util.List;
 public class FormDataDto implements Serializable {
 
     private static final long serialVersionUID = -8653990707913725671L;
+
+    @JSONField(name = "id")
+    private Long id;
+
     @JSONField(name = "objId")
     private Long objId;
 
@@ -23,6 +27,9 @@ public class FormDataDto implements Serializable {
     @JSONField(name = "table")
     private String table;
 
+    @JSONField(name = "tableName")
+    private String tableName;
+
     /**
      * 逻辑删除,数据库对应的属性名称
      */
@@ -235,6 +242,22 @@ public class FormDataDto implements Serializable {
     public void setSubmitSource(String submitSource) {
         this.submitSource = submitSource;
     }
+
+    public String getTableName() {
+        return tableName;
+    }
+
+    public void setTableName(String tableName) {
+        this.tableName = tableName;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
 }
 
 

+ 19 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/ObjController.java

@@ -1,5 +1,6 @@
 package com.boman.web.core.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.domain.dto.FormDataDto;
 import com.boman.web.core.service.TableServiceCmdService;
@@ -124,6 +125,24 @@ public class ObjController {
         return tableServiceCmdService.getObjectAllColumns(condition);
     }
 
+    /**
+     * 功能描述: 获取候选人数据
+     *
+     * eg:{
+     * "table": "sys_config",
+     * "fixedData": {
+     * "id": 20
+     * }
+     * }
+     *
+     * @param condition condition
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @ApiOperation(value = "获取候选人数据")
+    @PostMapping("/getBusinessCandidators")
+    public AjaxResult getBusinessCandidators(@RequestBody FormDataDto condition) {
+        return tableServiceCmdService.getBusinessCandidators(condition);
+    }
 
     /**
      * 功能描述: 获取表单列表数据

+ 29 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/StandardlyMapper.java

@@ -107,6 +107,10 @@ public interface StandardlyMapper {
     JSONObject selectById(@Param("tableName") String tableName
             , @Param("pkName") String pkName, @Param("id") Long id,  @Param("other") String other);
 
+    @SelectProvider(type = SqlProvider.class, method = "selectCandidatorsById")
+    List<JSONObject> selectCandidatorsById(@Param("tableName") String tableName
+            , @Param("pkName") String pkName, @Param("ids") List<Long> ids, @Param("type") int type);
+
     /**
      * 功能描述: 根据id查所有
      * {@link SqlProvider#selectByIdList(Map)}
@@ -638,6 +642,31 @@ public interface StandardlyMapper {
             return sqlBuilder.toString();
         }
 
+        public String selectCandidatorsById(Map<String, Object> params) {
+            String tableName = (String) params.get("tableName");
+            String pkName = (String) params.get("pkName");
+            List<Long> ids = (List<Long>) params.get("ids");
+            int type = (Integer) params.get("type");
+
+            // TODO 部门暂未定
+            StringBuilder sqlBuilder = new StringBuilder();
+            sqlBuilder.append("select id,user_name as name, ").append(type).append(" as type ").append(" from ")
+                    .append(tableName).append(" t ")
+                    .append(" where ")
+                    .append("t.").append(pkName).append(" in ").append("(");
+
+            for(int i = 0;i < ids.size();i++) {
+                if(i < ids.size() - 1) {
+                    sqlBuilder.append(ids.get(i)).append(",");
+                }else {
+                    sqlBuilder.append(ids.get(i));
+                }
+            }
+
+            sqlBuilder.append(")");
+            return sqlBuilder.toString();
+        }
+
         /**
          * 功能描述: 判断传过来的值是否需要转义
          *

+ 60 - 0
boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java

@@ -437,6 +437,66 @@ public class TableServiceCmdService {
 
     }
 
+    /**
+     * 功能描述: 获取单表单所有数据
+     *
+     * @param dto condition
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    public AjaxResult getBusinessCandidators(FormDataDto dto) {
+        String tableName = dto.getTableName();
+        GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, tableName);
+        List<GenTableColumn> columns = genTable.getColumns();
+        // 获取候选人字段
+        JSONObject jsonObject = selectService.selectById(tableName, IdUtils.getPkName(genTable.getColumns()), dto.getId(), dto.getOther());
+        String candidator = "";
+        String candidatorDepart = "";
+        for (GenTableColumn column : columns) {
+            String columnName = column.getColumnName();
+            if(columnName.equals("check_user_id")) {
+                candidator = jsonObject.getString(column.getColumnName());
+                break;
+            }
+            if(columnName.equals("check_group_id")) {
+                candidatorDepart = jsonObject.getString(column.getColumnName());
+                break;
+            }
+        }
+        if(StringUtils.isEmpty(candidator) && StringUtils.isEmpty(candidatorDepart)) {
+            return AjaxResult.error(-1, "没有候选人或者组!");
+        }
+        int type =  0;
+        List<Long> ids = new ArrayList<>();
+        // 候选人
+        if(StringUtils.isNotEmpty(candidator)) {
+            type = 1;
+            String[] idArrs = candidator.split(",");
+            for(String idArr : idArrs) {
+                ids.add(Long.valueOf(idArr));
+            }
+        }
+        // 候选组
+        if(StringUtils.isNotEmpty(candidatorDepart)) {
+            type = 2;
+            String[] idArrs = candidatorDepart.split(",");
+            for(String idArr : idArrs) {
+                ids.add(Long.valueOf(idArr));
+            }
+        }
+
+        List<JSONObject> jsonObjects = null;
+        if(type == 1) {
+            jsonObjects = selectService.selectCandidatorsById("sys_user", IdUtils.getPkName(genTable.getColumns()), ids, type);
+        }
+        JSONObject result = new JSONObject();
+        if( jsonObjects == null) {
+            return AjaxResult.error(-1, "没有候选人或组!");
+        }
+        result.put("approvers", jsonObjects);
+        return new AjaxResult(1, 0, "", result);
+
+    }
+
     /**
      * 判断hr字段里面是否有值
      *

+ 16 - 0
boman-web-core/src/main/java/com/boman/web/core/service/select/BaseSelectServiceImpl.java

@@ -124,6 +124,22 @@ public class BaseSelectServiceImpl implements IBaseSelectService {
         return mapper.selectById(tableName, pkName, id, other);
     }
 
+    /**
+     * 功能描述: 根据id查所有,不支持自定义查询列
+     *
+     * @param tableName 表名
+     * @param pkName    主键名称
+     * @param ids        主键值
+     * @return com.alibaba.fastjson.JSONObject
+     */
+    @Override
+    public List<JSONObject> selectCandidatorsById(String tableName, String pkName, List<Long> ids, int type) {
+        requireNonNull(tableName, "表名为空");
+        requireNonNull(pkName, "主键名称为空");;
+        requireNonNull(ids, "selectCandidatorsById id is empty");
+        return mapper.selectCandidatorsById(tableName, pkName, ids, type);
+    }
+
     /**
      * 功能描述: 根据id查所有,不支持自定义查询列
      *

+ 6 - 0
boman-web-core/src/main/java/com/boman/web/core/service/select/IBaseSelectService.java

@@ -64,6 +64,12 @@ public interface IBaseSelectService {
      */
     JSONObject selectById(String tableName, String pkName, Long id, String other);
 
+    /**
+     * 根据id查候选人id和名称
+     * @return
+     */
+    List<JSONObject> selectCandidatorsById(String tableName, String pkName, List<Long> ids, int type);
+
     /**
      * 功能描述: 根据id查所有,不支持自定义查询列
      *