|
@@ -1,6 +1,7 @@
|
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.management.platform.entity.Project;
|
|
|
import com.management.platform.entity.Report;
|
|
|
import com.management.platform.entity.User;
|
|
@@ -14,6 +15,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -47,6 +50,22 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
+ //分页获取项目列表
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getProjectPage(Integer pageIndex, Integer pageSize, HttpServletRequest request) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ try {
|
|
|
+ //通过公司id获取该公司所有的项目列表
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ httpRespMsg.data = projectMapper.selectPage(new Page<Project>(pageIndex, pageSize),
|
|
|
+ new QueryWrapper<Project>().eq("company_id", companyId));
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ httpRespMsg.setError("验证失败");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
//添加或编辑项目
|
|
|
@Override
|
|
|
public HttpRespMsg editProject(Integer id, String name, HttpServletRequest request) {
|
|
@@ -86,4 +105,43 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
+
|
|
|
+ //获取查询者所在公司每个项目的工时成本
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getTimeCost(HttpServletRequest request) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ try {
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ List<Map<String, Object>> resultList = projectMapper.getTimeCost(companyId);
|
|
|
+ for (Map<String, Object> map : resultList) {
|
|
|
+ if (!map.containsKey("cost")) {
|
|
|
+ map.put("cost", 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ httpRespMsg.data = resultList;
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ httpRespMsg.setError("验证失败");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取某个项目每个人分别需要的工时
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getProjectCost(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.setError("无权查看其他公司的项目详情");
|
|
|
+ } else {
|
|
|
+ httpRespMsg.data = projectMapper.getProjectCost(projectId);
|
|
|
+ }
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ httpRespMsg.setError("验证失败");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
}
|