Jelajahi Sumber

项目 项目与人员的关联

Reiskuchen 5 tahun lalu
induk
melakukan
540758ab2a

+ 9 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/DepartmentController.java

@@ -33,6 +33,15 @@ public class DepartmentController {
         return departmentService.getDepartmentList(request);
     }
 
+    /**
+     * 获取不带有层级的部门列表
+     */
+    @RequestMapping("/normalList")
+    public HttpRespMsg getDepartmentNormal(HttpServletRequest request) {
+        return departmentService.getNormalDepartmentList(request);
+    }
+
+
     /**
      * 新增部门
      * name 部门名称

+ 36 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ParticipationController.java

@@ -0,0 +1,36 @@
+package com.management.platform.controller;
+
+
+import com.management.platform.service.ParticipationService;
+import com.management.platform.util.HttpRespMsg;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * <p>
+ * 人员参与项目的情况 前端控制器
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2020-02-12
+ */
+@RestController
+@RequestMapping("/participation")
+public class ParticipationController {
+    @Autowired
+    private ParticipationService participationService;
+
+    @RequestMapping("/get")
+    public HttpRespMsg getParticipation(Integer projectId, HttpServletRequest request) {
+        return participationService.getParticipation(projectId, request);
+    }
+
+    @RequestMapping("/edit")
+    public HttpRespMsg editParticipation(Integer projectId, String[] userId, HttpServletRequest request) {
+        return participationService.editParticipation(projectId, userId, request);
+    }
+}
+

+ 51 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Participation.java

@@ -0,0 +1,51 @@
+package com.management.platform.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 人员参与项目的情况
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2020-02-12
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class Participation extends Model<Participation> {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 用户表主键
+     */
+    @TableField("user_id")
+    private String userId;
+
+    /**
+     * 项目表主键
+     */
+    @TableField("project_id")
+    private Integer projectId;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+}

+ 19 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ParticipationMapper.java

@@ -0,0 +1,19 @@
+package com.management.platform.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.management.platform.entity.Participation;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 人员参与项目的情况 Mapper 接口
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2020-02-12
+ */
+public interface ParticipationMapper extends BaseMapper<Participation> {
+    List<String> getParticipator(@Param("projectId") Integer projectId);
+}

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/DepartmentService.java

@@ -22,5 +22,7 @@ public interface DepartmentService extends IService<Department> {
 
     HttpRespMsg deleteDepartment(Integer departmentId, HttpServletRequest request);
 
+    HttpRespMsg getNormalDepartmentList(HttpServletRequest request);
+
     HttpRespMsg getDepartmentList(HttpServletRequest request);
 }

+ 21 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ParticipationService.java

@@ -0,0 +1,21 @@
+package com.management.platform.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.management.platform.entity.Participation;
+import com.management.platform.util.HttpRespMsg;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * <p>
+ * 人员参与项目的情况 服务类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2020-02-12
+ */
+public interface ParticipationService extends IService<Participation> {
+    HttpRespMsg getParticipation(Integer projectId, HttpServletRequest request);
+
+    HttpRespMsg editParticipation(Integer projectId, String[] userIds, HttpServletRequest request);
+}

+ 16 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DepartmentServiceImpl.java

@@ -127,6 +127,21 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
         return httpRespMsg;
     }
 
+    //获取不带层级的部门列表
+    @Override
+    public HttpRespMsg getNormalDepartmentList(HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        try {
+            Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
+            httpRespMsg.data = departmentMapper.selectList(new QueryWrapper<Department>()
+                    .eq("company_id", companyId));
+        } catch (NullPointerException e) {
+            httpRespMsg.setError("验证失败");
+            return httpRespMsg;
+        }
+        return httpRespMsg;
+    }
+
     //查看有无子节点
     private boolean checkBranch(Integer id) {
         return departmentMapper.selectCount(new QueryWrapper<Department>().eq("superior_id", id)) > 0;
@@ -140,7 +155,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             //筛选公司下所有的部门
             Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
             List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>()
-                    .eq("company_id", companyId).orderByDesc("department_id"));
+                    .eq("company_id", companyId));
             //结果列表
             List<DepartmentVO> list = new ArrayList<>();
             Stack<DepartmentVO>

+ 72 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ParticipationServiceImpl.java

@@ -0,0 +1,72 @@
+package com.management.platform.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.management.platform.entity.Participation;
+import com.management.platform.mapper.ParticipationMapper;
+import com.management.platform.mapper.ProjectMapper;
+import com.management.platform.mapper.UserMapper;
+import com.management.platform.service.ParticipationService;
+import com.management.platform.util.HttpRespMsg;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * <p>
+ * 人员参与项目的情况 服务实现类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2020-02-12
+ */
+@Service
+public class ParticipationServiceImpl extends ServiceImpl<ParticipationMapper, Participation> implements ParticipationService {
+
+    @Resource
+    private UserMapper userMapper;
+    @Resource
+    private ProjectMapper projectMapper;
+    @Resource
+    private ParticipationMapper participationMapper;
+
+    //获取某个项目的所有参与者id
+    @Override
+    public HttpRespMsg getParticipation(Integer projectId, HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        try {
+            Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
+            if (projectMapper.selectById(projectId).getCompanyId().equals(companyId)) {
+                httpRespMsg.data = participationMapper.getParticipator(projectId);
+            } else {
+                httpRespMsg.setError("无法查看其他公司的项目");
+            }
+        } catch (NullPointerException e) {
+            httpRespMsg.setError("验证失败");
+            return httpRespMsg;
+        }
+        return httpRespMsg;
+    }
+
+    //编辑某个项目的参与者id
+    @Override
+    public HttpRespMsg editParticipation(Integer projectId, String[] userIds, HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        try {
+            Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
+            if (projectMapper.selectById(projectId).getCompanyId().equals(companyId)) {
+                participationMapper.delete(new QueryWrapper<Participation>().eq("project_id", projectId));
+                for (String userId : userIds) {
+                    participationMapper.insert(new Participation().setProjectId(projectId).setUserId(userId));
+                }
+            } else {
+                httpRespMsg.setError("无法编辑其他公司的项目");
+            }
+        } catch (NullPointerException e) {
+            httpRespMsg.setError("验证失败");
+            return httpRespMsg;
+        }
+        return httpRespMsg;
+    }
+}

+ 2 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -154,7 +154,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         } else {
             httpRespMsg.data = user;
         }
-
         return httpRespMsg;
     }
 
@@ -185,8 +184,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
-            Integer total = 0;
-            List<Map<String, Object>> list = new ArrayList<>();
+            Integer total;
+            List<Map<String, Object>> list;
             Page<User> page = new Page<>(pageIndex, pageSize);
             if (departmentId == -1) {
                 //单独查找全部

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/CodeGenerator.java

@@ -204,7 +204,7 @@ public class CodeGenerator {
         //若想要生成的实体类继承某个Controller,则可打开下面注释。写上需要继承的Controller的位置即可
 //        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
         //此处user是表名,多个英文逗号分割
-        strategy.setInclude("user", "department");
+        strategy.setInclude("participation");
 //        strategy.setExclude();//数据库表全生成
 //        strategy.setInclude(scanner("user").split(","));//表名,多个英文逗号分割
         strategy.setControllerMappingHyphenStyle(true);

+ 24 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ParticipationMapper.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.management.platform.mapper.ParticipationMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.management.platform.entity.Participation">
+        <id column="id" property="id"/>
+        <result column="user_id" property="userId"/>
+        <result column="project_id" property="projectId"/>
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, user_id, project_id
+    </sql>
+
+    <!--获取查询者所在公司每个项目的工时成本-->
+    <select id="getParticipator" resultType="java.lang.String">
+        SELECT user_id
+        FROM participation
+        WHERE project_id = #{projectId}
+    </select>
+
+</mapper>