anderx пре 2 година
родитељ
комит
272725aa65

+ 15 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ProjectTaskController.java

@@ -3,10 +3,12 @@ package com.ruoyi.web.controller.project;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.file.MimeTypeUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.project.bo.ProjectListInput;
 import com.ruoyi.project.bo.ProjectStaffRecordInput;
 import com.ruoyi.project.bo.ProjectStaffRecordOut;
@@ -22,6 +24,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
 import java.awt.print.Pageable;
 import java.util.List;
 
@@ -165,6 +168,18 @@ public class ProjectTaskController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 导出项目列表
+     * @param response
+     */
+    @PostMapping("/export")
+    public void export(HttpServletResponse response,ProjectListInput in)
+    {
+        List<ProjectTaskListOut> list=projectTaskService.list(in);
+        ExcelUtil<ProjectTaskListOut> util = new ExcelUtil<>(ProjectTaskListOut.class);
+        util.exportExcel(response, list, "项目列表");
+    }
+
 
     /**
      * 上传项目文件

+ 3 - 3
ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java

@@ -11,7 +11,7 @@ import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
 
 /**
  * 自定义导出Excel数据注解
- * 
+ *
  * @author ruoyi
  */
 @Retention(RetentionPolicy.RUNTIME)
@@ -39,7 +39,7 @@ public @interface Excel
     public String dictType() default "";
 
     /**
-     * 读取内容转表达式 (如: 0=男,1=女,2=未知)
+     * 读取内容转表达式 (如: 0=男,1=女,2=未知)
      */
     public String readConverterExp() default "";
 
@@ -184,4 +184,4 @@ public @interface Excel
             return this.value;
         }
     }
-}
+}

+ 34 - 34
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java

@@ -87,7 +87,7 @@ import com.ruoyi.common.utils.reflect.ReflectUtils;
 
 /**
  * Excel相关处理
- * 
+ *
  * @author ruoyi
  */
 public class ExcelUtil<T>
@@ -284,7 +284,7 @@ public class ExcelUtil<T>
 
     /**
      * 对excel表单默认第一个索引名转换成list
-     * 
+     *
      * @param is 输入流
      * @return 转换后集合
      */
@@ -309,7 +309,7 @@ public class ExcelUtil<T>
 
     /**
      * 对excel表单默认第一个索引名转换成list
-     * 
+     *
      * @param is 输入流
      * @param titleNum 标题占用行数
      * @return 转换后集合
@@ -321,7 +321,7 @@ public class ExcelUtil<T>
 
     /**
      * 对excel表单指定表格索引名转换成list
-     * 
+     *
      * @param sheetName 表格索引名
      * @param titleNum 标题占用行数
      * @param is 输入流
@@ -500,7 +500,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @param list 导出数据集合
      * @param sheetName 工作表的名称
      * @return 结果
@@ -512,7 +512,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @param list 导出数据集合
      * @param sheetName 工作表的名称
      * @param title 标题
@@ -526,7 +526,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @param response 返回数据
      * @param list 导出数据集合
      * @param sheetName 工作表的名称
@@ -539,7 +539,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @param response 返回数据
      * @param list 导出数据集合
      * @param sheetName 工作表的名称
@@ -556,7 +556,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @param sheetName 工作表的名称
      * @return 结果
      */
@@ -567,7 +567,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @param sheetName 工作表的名称
      * @param title 标题
      * @return 结果
@@ -580,7 +580,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @param sheetName 工作表的名称
      * @return 结果
      */
@@ -591,7 +591,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @param sheetName 工作表的名称
      * @param title 标题
      * @return 结果
@@ -606,7 +606,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @return 结果
      */
     public void exportExcel(HttpServletResponse response)
@@ -628,7 +628,7 @@ public class ExcelUtil<T>
 
     /**
      * 对list数据源将其里面的数据导入到excel表单
-     * 
+     *
      * @return 结果
      */
     public AjaxResult exportExcel()
@@ -696,7 +696,7 @@ public class ExcelUtil<T>
 
     /**
      * 填充excel数据
-     * 
+     *
      * @param index 序号
      * @param row 单元格行
      */
@@ -767,7 +767,7 @@ public class ExcelUtil<T>
 
     /**
      * 创建表格样式
-     * 
+     *
      * @param wb 工作薄对象
      * @return 样式列表
      */
@@ -820,7 +820,7 @@ public class ExcelUtil<T>
 
     /**
      * 根据Excel注解创建表格头样式
-     * 
+     *
      * @param wb 工作薄对象
      * @return 自定义样式列表
      */
@@ -853,7 +853,7 @@ public class ExcelUtil<T>
 
     /**
      * 根据Excel注解创建表格列样式
-     * 
+     *
      * @param wb 工作薄对象
      * @return 自定义样式列表
      */
@@ -915,7 +915,7 @@ public class ExcelUtil<T>
 
     /**
      * 设置单元格信息
-     * 
+     *
      * @param value 单元格值
      * @param attr 注解相关
      * @param cell 单元格信息
@@ -1084,7 +1084,7 @@ public class ExcelUtil<T>
 
     /**
      * 设置 POI XSSFSheet 单元格提示或选择框
-     * 
+     *
      * @param sheet 表单
      * @param textlist 下拉框显示的内容
      * @param promptContent 提示内容
@@ -1121,7 +1121,7 @@ public class ExcelUtil<T>
 
     /**
      * 设置某些列的值只能输入预制的数据,显示下拉框(兼容超出一定数量的下拉框).
-     * 
+     *
      * @param sheet 要设置的sheet.
      * @param textlist 下拉框显示的内容
      * @param promptContent 提示内容
@@ -1173,7 +1173,7 @@ public class ExcelUtil<T>
 
     /**
      * 解析导出值 0=男,1=女,2=未知
-     * 
+     *
      * @param propertyValue 参数值
      * @param converterExp 翻译注解
      * @param separator 分隔符
@@ -1210,7 +1210,7 @@ public class ExcelUtil<T>
 
     /**
      * 反向解析值 男=0,女=1,未知=2
-     * 
+     *
      * @param propertyValue 参数值
      * @param converterExp 翻译注解
      * @param separator 分隔符
@@ -1247,7 +1247,7 @@ public class ExcelUtil<T>
 
     /**
      * 解析字典值
-     * 
+     *
      * @param dictValue 字典值
      * @param dictType 字典类型
      * @param separator 分隔符
@@ -1260,7 +1260,7 @@ public class ExcelUtil<T>
 
     /**
      * 反向解析值字典值
-     * 
+     *
      * @param dictLabel 字典标签
      * @param dictType 字典类型
      * @param separator 分隔符
@@ -1273,7 +1273,7 @@ public class ExcelUtil<T>
 
     /**
      * 数据处理器
-     * 
+     *
      * @param value 数据值
      * @param excel 数据注解
      * @return
@@ -1350,7 +1350,7 @@ public class ExcelUtil<T>
 
     /**
      * 获取下载路径
-     * 
+     *
      * @param filename 文件名称
      */
     public String getAbsoluteFile(String filename)
@@ -1366,7 +1366,7 @@ public class ExcelUtil<T>
 
     /**
      * 获取bean中的属性值
-     * 
+     *
      * @param vo 实体对象
      * @param field 字段
      * @param excel 注解
@@ -1397,7 +1397,7 @@ public class ExcelUtil<T>
 
     /**
      * 以类的属性的get方法方法形式获取值
-     * 
+     *
      * @param o
      * @param name
      * @return value
@@ -1503,7 +1503,7 @@ public class ExcelUtil<T>
 
     /**
      * 创建工作表
-     * 
+     *
      * @param sheetNo sheet数量
      * @param index 序号
      */
@@ -1520,7 +1520,7 @@ public class ExcelUtil<T>
 
     /**
      * 获取单元格值
-     * 
+     *
      * @param row 获取的行
      * @param column 获取单元格列号
      * @return 单元格值
@@ -1580,7 +1580,7 @@ public class ExcelUtil<T>
 
     /**
      * 判断是否是空行
-     * 
+     *
      * @param row 判断的行
      * @return
      */
@@ -1668,7 +1668,7 @@ public class ExcelUtil<T>
 
     /**
      * 格式化不同类型的日期对象
-     * 
+     *
      * @param dateFormat 日期格式
      * @param val 被格式化的日期对象
      * @return 格式化后的日期字符
@@ -1734,7 +1734,7 @@ public class ExcelUtil<T>
 
     /**
      * 获取对象的子列表方法
-     * 
+     *
      * @param name 名称
      * @param pojoClass 类对象
      * @return 子列表方法

+ 9 - 1
ruoyi-system/src/main/java/com/ruoyi/project/bo/ProjectListInput.java

@@ -5,12 +5,20 @@ public class ProjectListInput {
     private String name;
     private String startTime;
     private String endTime;
-    private Long rolesId;
+    private Long rolesId,companyId;
     private Long headId;
     private Long staffId;
     private String projectNumber,projectYear;
     private Integer crossYear,projectStatus;
 
+    public Long getCompanyId() {
+        return companyId;
+    }
+
+    public void setCompanyId(Long companyId) {
+        this.companyId = companyId;
+    }
+
     public String getProjectNumber() {
         return projectNumber;
     }

+ 147 - 0
ruoyi-system/src/main/java/com/ruoyi/project/bo/ProjectTaskListOut.java

@@ -1,10 +1,157 @@
 package com.ruoyi.project.bo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.project.domain.ProjectTask;
 
+import java.util.Date;
+
 
 public class ProjectTaskListOut extends ProjectTask {
 
 
+    /**
+     * 项目编号
+     */
+    @Excel(name = "项目编号")
+    private Long id;
+
+    /**
+     * 项目年份
+     */
+    @Excel(name = "项目年份",dateFormat = "yyyy")
+    @JsonFormat(pattern = "yyyy")
+    private Object projectYear;
+
+    /**
+     * 0=非跨年,1=跨年
+     */
+    @Excel(name = "项目年份",readConverterExp = "0=否,1=是")
+    private Integer crossYear;
+    /**
+     * 项目名称
+     */
+    @Excel(name = "项目名称")
+    private String name;
+
+    /**
+     * 负责人名称
+     */
+    @Excel(name = "负责人")
+    private String adminName;
+
+    /**
+     * 成员名称
+     */
+    @Excel(name = "参与研发人员")
+    private String staffName;
+    /**
+     * 项目状态
+     */
+    @Excel(name = "项目状态",readConverterExp = "0=未启动,1=进行中")
+    private Integer projectStatus;
+    /**
+     * 创建年份
+     */
+    @Excel(name = "创建年份",dateFormat = "yyyy")
+    @JsonFormat(pattern = "yyyy")
+    private Object createYear;
+
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间",dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+
+    @Override
+    public Long getId() {
+        return id;
+    }
+
+    @Override
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    @Override
+    public Object getProjectYear() {
+        return projectYear;
+    }
+
+    @Override
+    public void setProjectYear(Object projectYear) {
+        this.projectYear = projectYear;
+    }
+
+    @Override
+    public Integer getCrossYear() {
+        return crossYear;
+    }
+
+    @Override
+    public void setCrossYear(Integer crossYear) {
+        this.crossYear = crossYear;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String getAdminName() {
+        return adminName;
+    }
+
+    @Override
+    public void setAdminName(String adminName) {
+        this.adminName = adminName;
+    }
+
+    @Override
+    public String getStaffName() {
+        return staffName;
+    }
+
+    @Override
+    public void setStaffName(String staffName) {
+        this.staffName = staffName;
+    }
+
+    @Override
+    public Integer getProjectStatus() {
+        return projectStatus;
+    }
+
+    @Override
+    public void setProjectStatus(Integer projectStatus) {
+        this.projectStatus = projectStatus;
+    }
+
+    @Override
+    public Object getCreateYear() {
+        return createYear;
+    }
+
+    @Override
+    public void setCreateYear(Object createYear) {
+        this.createYear = createYear;
+    }
+
+    @Override
+    public Date getCreateTime() {
+        return createTime;
+    }
 
+    @Override
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
 }

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectTaskServiceImpl.java

@@ -13,6 +13,7 @@ import com.ruoyi.project.domain.ProjectTask;
 import com.ruoyi.project.mapper.ProjectStaffMapper;
 import com.ruoyi.project.mapper.ProjectTaskMapper;
 import com.ruoyi.project.service.ProjectTaskService;
+import com.ruoyi.system.service.ISysDeptService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -25,6 +26,8 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
     private ProjectTaskMapper projectTaskMapper;
     @Autowired
     private ProjectStaffMapper projectStaffMapper;
+    @Autowired
+    private ISysDeptService deptService;
 
     @Override
     public AjaxResult addProjectTask(ProjectTask projectTask) {
@@ -63,6 +66,8 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
         }else if(SecurityUtils.hashRoles(UserRolesType.COMMON.getCode())){
             in.setRolesId(UserRolesType.COMMON.getCode());
         }
+        Long companyId = deptService.selectCompanyByDeptId();
+        if (companyId!=null)in.setCompanyId(companyId);
         if (in.getEndTime()!=null)in.setEndTime(in.getEndTime()+" 23:59:59");
         return projectTaskMapper.selectList(in);
     }

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java

@@ -122,5 +122,5 @@ public interface ISysDeptService
      */
     public int deleteDeptById(Long deptId);
 
-    public Long selectCompanyByDeptId(Long deptId);
+    public Long selectCompanyByDeptId();
 }

+ 7 - 4
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java

@@ -46,6 +46,7 @@ public class SysDeptServiceImpl implements ISysDeptService
     @DataScope(deptAlias = "d")
     public List<SysDept> selectDeptList(SysDept dept)
     {
+        dept.setAncestors(SecurityUtils.getDeptId().toString());
         return deptMapper.selectDeptList(dept);
     }
 
@@ -58,6 +59,7 @@ public class SysDeptServiceImpl implements ISysDeptService
     @Override
     public List<TreeSelect> selectDeptTreeList(SysDept dept)
     {
+        dept.setAncestors(SecurityUtils.getDeptId().toString());
         List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
         return buildDeptTreeSelect(depts);
     }
@@ -295,11 +297,12 @@ public class SysDeptServiceImpl implements ISysDeptService
     }
 
     @Override
-    public Long selectCompanyByDeptId(Long deptId) {
-        SysDept sysDept = deptMapper.selectDeptById(deptId);
+    public Long selectCompanyByDeptId() {
+        SysDept sysDept = deptMapper.selectDeptById(SecurityUtils.getDeptId());
         String[] split = sysDept.getAncestors().split(",");
-        if (split.length<3)return null;
-        return Long.valueOf(split[2]);
+        if (split.length==2)return Long.valueOf(split[1]);
+        if (split.length>2)return Long.valueOf(split[2]);
+        return null;
     }
 
     /**

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -71,7 +71,7 @@ public class SysUserServiceImpl implements ISysUserService
     @DataScope(deptAlias = "d", userAlias = "u")
     public List<SysUser> selectUserList(SysUser user)
     {
-        Long companyId = deptService.selectCompanyByDeptId(SecurityUtils.getDeptId());
+        Long companyId = deptService.selectCompanyByDeptId();
         if (companyId!=null)user.setCompanyId(companyId);
         return userMapper.selectUserList(user);
     }

+ 7 - 1
ruoyi-system/src/main/resources/mapper/project/ProjectTaskMapper.xml

@@ -196,6 +196,10 @@
     <if test="rolesId ==2">
       left join (select pid from project_staff where aid= #{uid}) b on a.id=b.pid
     </if>
+    <if test="companyId !=null">
+      left join sys_user c on a.aid=c.user_id
+      left join sys_dept d on c.dept_id=d.dept_id
+    </if>
     where 1=1
       <if test="rolesId ==3">
         and a.aid = #{uid}
@@ -225,6 +229,8 @@
     <if test="projectStatus !=null ">
       and a.project_status =#{projectStatus}
     </if>
-
+    <if test="companyId !=null">
+     and (d.dept_id= #{companyId} or find_in_set(#{companyId},d.ancestors))
+    </if>
   </select>
 </mapper>

+ 20 - 17
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -21,12 +21,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="updateBy"   column="update_by"   />
 		<result property="updateTime" column="update_time" />
 	</resultMap>
-	
+
 	<sql id="selectDeptVo">
-        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time 
+        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
         from sys_dept d
     </sql>
-    
+
 	<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
         <include refid="selectDeptVo"/>
         where d.del_flag = '0'
@@ -42,11 +42,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<if test="status != null and status != ''">
 			AND status = #{status}
 		</if>
+		<if test="ancestors !=null">
+			and (dept_id= #{ancestors} or find_in_set(#{ancestors},ancestors))
+		</if>
 		<!-- 数据范围过滤 -->
 		${params.dataScope}
 		order by d.parent_id, d.order_num
     </select>
-    
+
     <select id="selectDeptListByRoleId" resultType="Long">
 		select d.dept_id
 		from sys_dept d
@@ -57,36 +60,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </if>
 		order by d.parent_id, d.order_num
 	</select>
-    
+
     <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
 		select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
 			(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
 		from sys_dept d
 		where d.dept_id = #{deptId}
 	</select>
-    
+
     <select id="checkDeptExistUser" parameterType="Long" resultType="int">
 		select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
 	</select>
-	
+
 	<select id="hasChildByDeptId" parameterType="Long" resultType="int">
 		select count(1) from sys_dept
 		where del_flag = '0' and parent_id = #{deptId} limit 1
 	</select>
-	
+
 	<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
 		select * from sys_dept where find_in_set(#{deptId}, ancestors)
 	</select>
-	
+
 	<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
 		select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)
 	</select>
-	
+
 	<select id="checkDeptNameUnique" resultMap="SysDeptResult">
 	    <include refid="selectDeptVo"/>
 		where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
 	</select>
-    
+
     <insert id="insertDept" parameterType="SysDept">
  		insert into sys_dept(
  			<if test="deptId != null and deptId != 0">dept_id,</if>
@@ -114,7 +117,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			sysdate()
  		)
 	</insert>
-	
+
 	<update id="updateDept" parameterType="SysDept">
  		update sys_dept
  		<set>
@@ -131,7 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  		</set>
  		where dept_id = #{deptId}
 	</update>
-	
+
 	<update id="updateDeptChildren" parameterType="java.util.List">
 	    update sys_dept set ancestors =
 	    <foreach collection="depts" item="item" index="index"
@@ -144,16 +147,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	        #{item.deptId}
 	    </foreach>
 	</update>
-	 
+
 	<update id="updateDeptStatusNormal" parameterType="Long">
- 	    update sys_dept set status = '0' where dept_id in 
+ 	    update sys_dept set status = '0' where dept_id in
  	    <foreach collection="array" item="deptId" open="(" separator="," close=")">
         	#{deptId}
         </foreach>
 	</update>
-	
+
 	<delete id="deleteDeptById" parameterType="Long">
 		update sys_dept set del_flag = '2' where dept_id = #{deptId}
 	</delete>
 
-</mapper> 
+</mapper>

+ 1 - 1
ruoyi-ui/.env.development

@@ -1,5 +1,5 @@
 # 页面标题
-VUE_APP_TITLE = 若依管理系统
+VUE_APP_TITLE = 管理系统
 
 # 开发环境配置
 ENV = 'development'