浏览代码

教育培训任务代码提交

jingyuanchao 2 年之前
父节点
当前提交
0afe3ee512

+ 6 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/edu/vo/CoreEduTrainingPlanPageVo.java

@@ -5,6 +5,8 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * @author jingyuanchao
  * @date 2023/8/24 15:30
@@ -68,4 +70,8 @@ public class CoreEduTrainingPlanPageVo {
     private int createByTopOrg;
 
     private String planRoleNameList;
+
+    private Boolean hasChildren;
+
+    private List<CoreEduTrainingPlanPageVo> children;
 }

+ 0 - 136
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/utils/BeanHelper.java

@@ -1,136 +0,0 @@
-package com.xunmei.common.core.utils;
-
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.BeanWrapper;
-import org.springframework.beans.PropertyAccessorFactory;
-
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-import java.util.*;
-
-/**
- * Tkk
- */
-public class BeanHelper {
-
-    /**
-     * 主要过滤 null 值
-     *
-     * @param target
-     * @param source
-     */
-    public static void copyProperties(Object target, Object source) {
-        BeanUtils.copyProperties(source, target, getNullPropertyNames(source));
-    }
-
-    /**
-     * 主要过滤 null 值
-     *
-     * @param oldValue
-     * @param newValue
-     */
-    public static void copyProperties(Object oldValue, Object newValue, String... exclude) {
-        BeanUtils.copyProperties(newValue, oldValue, getNullPropertyNames(newValue, exclude));
-    }
-
-    /**
-     * 忽略为null的数据
-     *
-     * @param source
-     * @return
-     */
-    public static String[] getNullPropertyNames(Object source, String... ignores) {
-        BeanWrapper beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(source);
-        PropertyDescriptor[] pds = beanWrapper.getPropertyDescriptors();
-        List<String> ignoreList = new LinkedList<>();
-        for (PropertyDescriptor pd : pds) {
-            if (pd.getWriteMethod() == null) {
-                continue;
-            }
-            Object srcValue = beanWrapper.getPropertyValue(pd.getName());
-            if (srcValue == null) {
-                ignoreList.add(pd.getName());
-            }
-        }
-        String[] result = ignoreList.toArray(new String[ignoreList.size()]);
-        return ignores == null ? result : ArrayUtils.addAll(result, ignores);
-    }
-
-
-    public static void setNullPropertiesDefValue(Object obj) {
-        //获取实体类的所有属性,返回Field数组
-        // Field[] fields = obj.getClass().getDeclaredFields();
-        Field[] fields = getAllFields(obj.getClass());
-        //遍历所有属性
-        for (int j = 0; j < fields.length; j++) {
-            Field field = fields[j];
-            String type = field.getGenericType().toString();
-            field.setAccessible(true);
-            Object value = null;
-            try {
-                value = field.get(obj);
-                if (value != null && StringUtils.isNotBlank(value.toString())) {
-                    continue;
-                }
-                //如果type是类类型,则前面包含"class ",后面跟类名
-                switch (type) {
-                    case "class java.lang.String":
-                        field.set(obj, StringUtils.EMPTY);
-                        break;
-                    case "class java.math.BigDecimal":
-                        field.set(obj, BigDecimal.ZERO);
-                        break;
-                    case "class java.util.Date":
-                        field.set(obj, new Date());
-                        break;
-                    case "class java.lang.Integer":
-                        field.set(obj, 0);
-                        break;
-                    case "class java.lang.Character":
-                        field.set(obj, '0');
-                        break;
-                    case "class java.lang.Short":
-                        field.set(obj, Short.valueOf((short) 0));
-                        break;
-                    case "class java.lang.Byte":
-                        field.set(obj, Byte.valueOf((byte) 0));
-                        break;
-                    case "class java.lang.Double":
-                        field.set(obj, 0D);
-                        break;
-                    case "class java.lang.Float":
-                        field.set(obj, 0F);
-                        break;
-                    case "class java.lang.Long":
-                        field.set(obj, 0L);
-                        break;
-                    case "class java.lang.Boolean":
-                        field.set(obj, false);
-                        break;
-                    default:
-                        break;
-                }
-            } catch (IllegalAccessException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-    /**
-     * 获取本类及其父类的属性的方法
-     *
-     * @param clazz 当前类对象
-     * @return 字段数组
-     */
-    private static Field[] getAllFields(Class<?> clazz) {
-        List<Field> fieldList = new ArrayList<>();
-        while (clazz != null) {
-            fieldList.addAll(new ArrayList<>(Arrays.asList(clazz.getDeclaredFields())));
-            clazz = clazz.getSuperclass();
-        }
-        Field[] fields = new Field[fieldList.size()];
-        return fieldList.toArray(fields);
-    }
-}

+ 24 - 9
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/impl/CoreEduTrainingPlanServiceImpl.java

@@ -21,6 +21,7 @@ import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanDetailVo;
 import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanPageVo;
 import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanRoleVo;
 import com.xunmei.common.core.exception.SystemException;
+import com.xunmei.common.core.util.BeanHelper;
 import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.security.utils.SecurityUtils;
@@ -86,17 +87,12 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
         //获取数据
         Page<CoreEduTrainingPlanPageVo> page = coreEduTrainingPlanMapper.selectPageData(request.getPage(), request);
         SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectTopOrg(SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
-        for (CoreEduTrainingPlanPageVo record : page.getRecords()) {
-            record.setNo(page.getRecords().indexOf(record) + 1);
-            if (ObjectUtil.equal(record.getCreateOrgId(), sysOrg.getId())) {
-                record.setCreateByTopOrg(1);
-            }
-            String roleNameList = coreEduTrainingPlanToRoleMapper.selectRoleNameByPlanId(record.getId()).stream().map(CoreEduTrainingPlanRoleVo::getRoleName).collect(Collectors.joining(","));
-            record.setPlanRoleNameList(roleNameList);
-
+        List<CoreEduTrainingPlanPageVo> records = page.getRecords();
+        for (CoreEduTrainingPlanPageVo record : records) {
+            dealData(record, records, sysOrg.getId());
         }
         //抓换为TableDataInfo适配前端
-        TableDataInfo tableDataInfo = new TableDataInfo();
+        TableDataInfo<CoreEduTrainingPlanPageVo> tableDataInfo = new TableDataInfo();
         tableDataInfo.setMsg("操作成功");
         tableDataInfo.setCode(200);
         tableDataInfo.setTotal(page.getTotal());
@@ -106,6 +102,25 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 
     }
 
+    private void dealData(CoreEduTrainingPlanPageVo record, List<CoreEduTrainingPlanPageVo> records, Long orgId) {
+        record.setNo(records.indexOf(record) + 1);
+        if (ObjectUtil.equal(record.getCreateOrgId(), orgId)) {
+            record.setCreateByTopOrg(1);
+        }
+        String roleNameList = coreEduTrainingPlanToRoleMapper.selectRoleNameByPlanId(record.getId()).stream().map(CoreEduTrainingPlanRoleVo::getRoleName).collect(Collectors.joining(","));
+        record.setPlanRoleNameList(roleNameList);
+        List<CoreEduTrainingPlan> planList = coreEduTrainingPlanMapper.selectList(new LambdaQueryWrapper<CoreEduTrainingPlan>().eq(CoreEduTrainingPlan::getParentId, record.getId()));
+        List<CoreEduTrainingPlanPageVo> children = BeanHelper.copyProperties(planList, CoreEduTrainingPlanPageVo.class);
+        record.setChildren(children);
+        record.setHasChildren(ObjectUtil.isNotEmpty(children));
+        for (CoreEduTrainingPlanPageVo child : children) {
+            if (ObjectUtil.equal(child.getCreateOrgId(), orgId)) {
+                child.setCreateByTopOrg(1);
+            }
+            record.setPlanRoleNameList(roleNameList);
+        }
+    }
+
 
     /**
      * 查询教育培训计划

+ 1 - 1
soc-modules/soc-modules-core/src/main/resources/mapper/edu/CoreEduTrainingPlanMapper.xml

@@ -403,7 +403,7 @@
             left join (select id from core_edu_training_plan p1 inner join core_edu_training_plan_to_role r1 on p1.id =
             r1.plan_id where r1.role_id = #{request.planRoleId} and p1.deleted=0) t on p.id = t.id and p.deleted=0
         </if>
-        where p.deleted = 0
+        where p.deleted = 0 and p.create_org_id=p.belong_org_id
 
         <if test="request.execOrgType!=null">
             and p.exec_org_type = #{request.execOrgType}