|
@@ -117,6 +117,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
LeaveSheetMapper leaveSheetMapper;
|
|
|
@Resource
|
|
|
BusinessTripMapper businessTripMapper;
|
|
|
+ @Resource
|
|
|
+ BustripProjectMapper bustripProjectMapper;
|
|
|
|
|
|
@Resource
|
|
|
private HttpServletResponse response;
|
|
@@ -725,83 +727,132 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
//导出查询者所在公司每个项目的工时成本,包括项目人员明细统计
|
|
|
@Override
|
|
|
- public HttpRespMsg exportTimeCost(String startDate, String endDate,Integer projectId, String userId, Boolean projectSum, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg exportTimeCost(String startDate, String endDate,Integer projectId, String userId, Boolean projectSum,Integer type, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userId);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
- List<String> headList = new ArrayList<String>();
|
|
|
- headList.add("项目编号");
|
|
|
- headList.add("项目名称");
|
|
|
- headList.add("项目分类");
|
|
|
- headList.add("人员");
|
|
|
- headList.add("部门");
|
|
|
- headList.add("工时(h)");
|
|
|
- headList.add("成本(元)");
|
|
|
- List<List<String>> allList = new ArrayList<List<String>>();
|
|
|
- allList.add(headList);
|
|
|
- double totalCostTime = 0;
|
|
|
- for (Map<String, Object> map : list) {
|
|
|
- if (!map.containsKey("cost")) {
|
|
|
- map.put("cost", 0);
|
|
|
- }
|
|
|
- if (!map.containsKey("costMoney")) {
|
|
|
- map.put("costMoney", 0);
|
|
|
- } else {
|
|
|
- totalMoneyCost = totalMoneyCost.add((BigDecimal)map.get("costMoney"));
|
|
|
- }
|
|
|
- totalCostTime += (Double)map.get("cost");
|
|
|
- List<String> rowData = new ArrayList<String>();
|
|
|
- rowData.add((String)map.get("projectCode"));
|
|
|
- rowData.add((String)map.get("project"));
|
|
|
- rowData.add((String)map.get("categoryName"));
|
|
|
- rowData.add("");
|
|
|
- rowData.add("");
|
|
|
- rowData.add(((Double)map.get("cost")).toString());
|
|
|
- rowData.add(((BigDecimal)map.get("costMoney")).toString());
|
|
|
- if (projectSum != null && projectSum == true) {
|
|
|
- allList.add(rowData);
|
|
|
- }
|
|
|
-
|
|
|
- //统计每个项目中的人员时间成本投入
|
|
|
- int curProjectId = (Integer)map.get("id");
|
|
|
- List<Map<String, Object>> membList = projectMapper.getProjectCost(startDate, endDate, curProjectId, userId);
|
|
|
- map.put("membList", membList);
|
|
|
- for (Map<String, Object> membMap : membList) {
|
|
|
- List<String> membRowData = new ArrayList<String>();
|
|
|
- if (projectSum == null || projectSum == false) {
|
|
|
- membRowData.add((String)map.get("projectCode"));
|
|
|
- membRowData.add((String)map.get("project"));
|
|
|
- membRowData.add((String)map.get("categoryName"));
|
|
|
+ List<List<String>> allList=null ;
|
|
|
+ List<String> sumRow = null;
|
|
|
+ if(type==0){
|
|
|
+ List<String> headList = new ArrayList<String>();
|
|
|
+ headList.add("项目编号");
|
|
|
+ headList.add("项目名称");
|
|
|
+ headList.add("项目分类");
|
|
|
+ headList.add("人员");
|
|
|
+ headList.add("部门");
|
|
|
+ headList.add("工时(h)");
|
|
|
+ headList.add("成本(元)");
|
|
|
+ allList=new ArrayList<>();
|
|
|
+ allList.add(headList);
|
|
|
+ double totalCostTime = 0;
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ if (!map.containsKey("cost")) {
|
|
|
+ map.put("cost", 0);
|
|
|
+ }
|
|
|
+ if (!map.containsKey("costMoney")) {
|
|
|
+ map.put("costMoney", 0);
|
|
|
} else {
|
|
|
- membRowData.add("");
|
|
|
- membRowData.add("");
|
|
|
- membRowData.add("");
|
|
|
+ totalMoneyCost = totalMoneyCost.add((BigDecimal)map.get("costMoney"));
|
|
|
}
|
|
|
+ totalCostTime += (Double)map.get("cost");
|
|
|
+ List<String> rowData = new ArrayList<String>();
|
|
|
+ rowData.add((String)map.get("projectCode"));
|
|
|
+ rowData.add((String)map.get("project"));
|
|
|
+ rowData.add((String)map.get("categoryName"));
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add(((Double)map.get("cost")).toString());
|
|
|
+ rowData.add(((BigDecimal)map.get("costMoney")).toString());
|
|
|
+ if (projectSum != null && projectSum == true) {
|
|
|
+ allList.add(rowData);
|
|
|
+ }
|
|
|
+ //统计每个项目中的人员时间成本投入
|
|
|
+ int curProjectId = (Integer)map.get("id");
|
|
|
+ List<Map<String, Object>> membList = projectMapper.getProjectCost(companyId,startDate, endDate, curProjectId, userId);
|
|
|
+ map.put("membList", membList);
|
|
|
+ for (Map<String, Object> membMap : membList) {
|
|
|
+ List<String> membRowData = new ArrayList<String>();
|
|
|
+ if (projectSum == null || projectSum == false) {
|
|
|
+ membRowData.add((String)map.get("projectCode"));
|
|
|
+ membRowData.add((String)map.get("project"));
|
|
|
+ membRowData.add((String)map.get("categoryName"));
|
|
|
+ } else {
|
|
|
+ membRowData.add("");
|
|
|
+ membRowData.add("");
|
|
|
+ membRowData.add("");
|
|
|
+ }
|
|
|
|
|
|
- membRowData.add((String)membMap.get("name"));
|
|
|
- membRowData.add((String)membMap.get("departmentName"));
|
|
|
- membRowData.add(((Double)membMap.get("cost")).toString());
|
|
|
- membRowData.add(((BigDecimal)membMap.get("costMoney")).toString());
|
|
|
- allList.add(membRowData);
|
|
|
+ membRowData.add((String)membMap.get("name"));
|
|
|
+ membRowData.add((String)membMap.get("departmentName"));
|
|
|
+ membRowData.add(((Double)membMap.get("cost")).toString());
|
|
|
+ membRowData.add(((BigDecimal)membMap.get("costMoney")).toString());
|
|
|
+ allList.add(membRowData);
|
|
|
+ }
|
|
|
}
|
|
|
+ //合计
|
|
|
+ sumRow=new ArrayList<>();
|
|
|
+ sumRow.add("合计");
|
|
|
+ sumRow.add("");
|
|
|
+ sumRow.add("");
|
|
|
+ sumRow.add("");
|
|
|
+ sumRow.add("");
|
|
|
+ sumRow.add(""+new BigDecimal(totalCostTime).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
+ sumRow.add(totalMoneyCost.toString());
|
|
|
+ allList.add(sumRow);
|
|
|
+ }else{
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active", 1));
|
|
|
+ List<Object> projectNames = list.stream().map(mp -> mp.get("project")).collect(Collectors.toList());
|
|
|
+ List<Object> projectIds = list.stream().map(mp -> mp.get("id")).collect(Collectors.toList());
|
|
|
+ List<String> headList = new ArrayList<String>();
|
|
|
+ headList.add("人员");
|
|
|
+ projectNames.forEach(pn->{
|
|
|
+ headList.add(String.valueOf(pn)+"/工时");
|
|
|
+ headList.add(String.valueOf(pn)+"/成本");
|
|
|
+ });
|
|
|
+ allList=new ArrayList<>();
|
|
|
+ allList.add(headList);
|
|
|
+ //统计当前所有项目所有人的时间成本投入
|
|
|
+ List<Map<String, Object>> membList = projectMapper.getProjectCostGroupByProject(companyId,startDate, endDate, projectId);
|
|
|
+ double lineCostTime=0;
|
|
|
+ BigDecimal lineMoneyCost = BigDecimal.valueOf(0);
|
|
|
+ for (User user : userList) {
|
|
|
+ boolean flag=false;
|
|
|
+ List<Map<String, Object>> mapList = membList.stream().filter(mb -> mb.get("creatorId").equals(user.getId())).collect(Collectors.toList());
|
|
|
+ List<String> membRowData=new ArrayList<>();
|
|
|
+ membRowData.add(user.getName());
|
|
|
+ for(Map<String, Object> membMap :mapList){
|
|
|
+ for(Object i:projectIds){
|
|
|
+ if(membMap.get("projectId").equals(i)){
|
|
|
+ membRowData.add(String.valueOf(membMap.get("cost")));
|
|
|
+ membRowData.add(String.valueOf(membMap.get("costMoney")));
|
|
|
+ flag=true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lineCostTime += (Double)membMap.get("cost");
|
|
|
+ lineMoneyCost = lineMoneyCost.add((BigDecimal)membMap.get("costMoney"));
|
|
|
+ }
|
|
|
+ if(flag){
|
|
|
+ allList.add(membRowData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //合计
|
|
|
+ /*sumRow=new ArrayList<>();
|
|
|
+ sumRow.add("合计");
|
|
|
+ List<String> finalSumRow = sumRow;
|
|
|
+ BigDecimal finalLineMoneyCost = lineMoneyCost;
|
|
|
+ double finalLineCostTime = lineCostTime;
|
|
|
+ projectNames.forEach(pn->{
|
|
|
+ finalSumRow.add(""+new BigDecimal(String.valueOf(finalLineCostTime)).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
+ finalSumRow.add(finalLineMoneyCost.toString());
|
|
|
+ });
|
|
|
+ allList.add(sumRow);*/
|
|
|
}
|
|
|
- //合计
|
|
|
- List<String> sumRow = new ArrayList<String>();
|
|
|
- sumRow.add("合计");
|
|
|
- sumRow.add("");
|
|
|
- sumRow.add("");
|
|
|
- sumRow.add("");
|
|
|
- sumRow.add("");
|
|
|
- sumRow.add(""+new BigDecimal(totalCostTime).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
- sumRow.add(totalMoneyCost.toString());
|
|
|
- allList.add(sumRow);
|
|
|
//生成excel文件导出
|
|
|
- String fileName = "项目成本统计_"+System.currentTimeMillis();
|
|
|
+ String fileName = "项目成本工时统计_"+System.currentTimeMillis();
|
|
|
String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , allList, path);
|
|
|
-
|
|
|
httpRespMsg.data = resp;
|
|
|
} catch (NullPointerException e) {
|
|
|
httpRespMsg.setError("验证失败");
|
|
@@ -966,7 +1017,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
|
if (timeType.getFixMonthcost() == 0) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- List<Map<String, Object>> list = projectMapper.getProjectCost(startDate, endDate, projectId, null);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getProjectCost(companyId,startDate, endDate, projectId, null);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
for (Map<String, Object> map : list) {
|
|
|
if (!map.containsKey("costMoney")) {
|
|
@@ -983,7 +1034,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
endDate = endDate + "-31";
|
|
|
List<Map<String, Object>> userMonthTimeCostList = projectMapper.getUserMonthTimeCost(companyId, startDate+"-01", endDate+"-31");
|
|
|
|
|
|
- List<Map<String, Object>> list = projectMapper.getProjectCost(startDate, endDate, projectId, null);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getProjectCost(companyId,startDate, endDate, projectId, null);
|
|
|
|
|
|
//检查财务表中是否已经导入成本
|
|
|
List<Finance> financeList = financeMapper.selectList(new QueryWrapper<Finance>().eq("ymonth", startDate).eq("company_id", companyId));
|
|
@@ -1402,6 +1453,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
User user = userMapper.selectById(token);
|
|
|
List<String> userIds = new ArrayList<>();
|
|
|
List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部项目");
|
|
|
+ List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
|
|
|
+ List<User> AllUser = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
|
|
|
if (functionList.size() == 0) {
|
|
|
//看看是部门经理还是项目负责人
|
|
|
if (user.getManageDeptId() != null && user.getManageDeptId() != 0) {
|
|
@@ -1464,10 +1517,32 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
btQueryWrapper.le("start_date", endDate).ge("end_date", startDate);
|
|
|
}
|
|
|
List<BusinessTrip> businessTripList = businessTripMapper.selectList(btQueryWrapper);
|
|
|
+ for(Department department:departmentList){
|
|
|
+ GanttDataItem parent = new GanttDataItem();
|
|
|
+ parent.id=department.getDepartmentId().toString();
|
|
|
+ parent.time = 0;
|
|
|
+ parent.text=department.getDepartmentName();
|
|
|
+ parent.type="";
|
|
|
+ if(department.getSuperiorId()!=null){
|
|
|
+ parent.parent=String.valueOf(department.getSuperiorId());
|
|
|
+ parent.type="milestone";
|
|
|
+ }
|
|
|
+ Set set=new HashSet();
|
|
|
+ if(set.add(parent.id)){
|
|
|
+ itemList.add(parent);
|
|
|
+ }
|
|
|
+ }
|
|
|
for(int i=0;i<leaveSheetList.size();i++){
|
|
|
GanttDataItem curItem = new GanttDataItem();;
|
|
|
if (!leaveSheetList.get(i).getOwnerId().equals(lsLastItemId)) {
|
|
|
//抽取父级对象,人员名称
|
|
|
+ int finalI = i;
|
|
|
+ Optional<User> first = AllUser.stream().filter(us -> us.getId().equals(leaveSheetList.get(finalI).getOwnerId())).findFirst();
|
|
|
+ Integer departmentId =null;
|
|
|
+ if(first.isPresent()){
|
|
|
+ departmentId=first.get().getDepartmentId();
|
|
|
+ }
|
|
|
+ System.out.println("====================="+departmentId+"======================");
|
|
|
GanttDataItem parent = new GanttDataItem();
|
|
|
parent.id = leaveSheetList.get(i).getOwnerId();
|
|
|
parent.userId = leaveSheetList.get(i).getOwnerId();
|
|
@@ -1476,10 +1551,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
parent.start_date = leaveSheetList.get(i).getStartDate().toString();
|
|
|
parent.end_date = leaveSheetList.get(i).getEndDate().toString();
|
|
|
parent.time = 0;
|
|
|
+ parent.parent=String.valueOf(departmentId);
|
|
|
itemList.add(parent);
|
|
|
lsLastItemId =leaveSheetList.get(i).getOwnerId();
|
|
|
}
|
|
|
-
|
|
|
curItem.id = "请假_"+leaveSheetList.get(i).getId();
|
|
|
curItem.userId = leaveSheetList.get(i).getOwnerId();
|
|
|
curItem.text = "请假";
|
|
@@ -1494,6 +1569,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
GanttDataItem curItem = new GanttDataItem();;
|
|
|
if (!businessTripList.get(i).getOwnerId().equals(btLastItemId)) {
|
|
|
//抽取父级对象,人员名称
|
|
|
+ int finalI = i;
|
|
|
+ Optional<User> first = AllUser.stream().filter(us -> us.getId().equals(businessTripList.get(finalI).getOwnerId())).findFirst();
|
|
|
+ Integer departmentId =null;
|
|
|
+ if(first.isPresent()){
|
|
|
+ departmentId=first.get().getDepartmentId();
|
|
|
+ }
|
|
|
GanttDataItem parent = new GanttDataItem();
|
|
|
parent.id = businessTripList.get(i).getOwnerId();
|
|
|
parent.userId = businessTripList.get(i).getOwnerId();
|
|
@@ -1502,6 +1583,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
parent.start_date = businessTripList.get(i).getStartDate().toString();
|
|
|
parent.end_date = businessTripList.get(i).getEndDate().toString();
|
|
|
parent.time = 0;
|
|
|
+ parent.parent=String.valueOf(departmentId);
|
|
|
itemList.add(parent);
|
|
|
btLastItemId =businessTripList.get(i).getOwnerId();
|
|
|
}
|
|
@@ -1516,43 +1598,56 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
btLastItemId = businessTripList.get(i).getOwnerId();
|
|
|
}
|
|
|
} else {
|
|
|
+ //按照项目获取
|
|
|
String btLastItemId = null;
|
|
|
GanttDataItem btLastParentItem=null;
|
|
|
ganttData = projectMapper.getTaskPlanByProject(projectIds, startDate ,endDate, user.getCompanyId());
|
|
|
QueryWrapper<BusinessTrip> btQueryWrapper =new QueryWrapper<>();
|
|
|
+ QueryWrapper<BustripProject> bpQueryWrapper =new QueryWrapper<>();
|
|
|
btQueryWrapper.in("owner_id", userIds);
|
|
|
if (startDate != null && endDate != null) {
|
|
|
- btQueryWrapper.le("start_date", endDate).ge("end_date", startDate);
|
|
|
+ bpQueryWrapper.le("start_date", endDate).ge("end_date", startDate);
|
|
|
+ }
|
|
|
+ List<Integer> btIdList=new ArrayList<>();
|
|
|
+ List<BusinessTrip> businessTripList = businessTripMapper.selectList(btQueryWrapper);
|
|
|
+ if(businessTripList.size()>0){
|
|
|
+ businessTripList.forEach(bt->{
|
|
|
+ btIdList.add(bt.getId());
|
|
|
+ });
|
|
|
+ bpQueryWrapper.in("bustrip_id", btIdList);
|
|
|
+ }
|
|
|
+ List<BustripProject> bustripProjectList = bustripProjectMapper.selectList(bpQueryWrapper);
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()));
|
|
|
+ for(BusinessTrip businessTrip:businessTripList){
|
|
|
+ List<BustripProject> collect = bustripProjectList.stream().filter(bp -> bp.getBustripId().equals(businessTrip.getId())).collect(Collectors.toList());
|
|
|
+ for(BustripProject bustripProject:collect){
|
|
|
+ GanttDataItem curItem = new GanttDataItem();
|
|
|
+ if(bustripProject.getProjectId()!=null) {
|
|
|
+ Project project = projectList.stream().filter(pro -> pro.getId().equals(bustripProject.getProjectId())).collect(Collectors.toList()).get(0);
|
|
|
+ if (!bustripProject.getProjectId().equals(btLastItemId)) {
|
|
|
+ //抽取父级对象,项目名称
|
|
|
+ GanttDataItem parent = new GanttDataItem();
|
|
|
+ parent.id = String.valueOf(bustripProject.getProjectId());
|
|
|
+ parent.userId = businessTrip.getOwnerId();
|
|
|
+ parent.text = project.getProjectName();
|
|
|
+ parent.render = "split";
|
|
|
+ parent.start_date = bustripProject.getStartDate().toString();
|
|
|
+ parent.end_date = bustripProject.getEndDate().toString();
|
|
|
+ parent.time = 0;
|
|
|
+ itemList.add(parent);
|
|
|
+ btLastItemId = String.valueOf(bustripProject.getProjectId());
|
|
|
+ }
|
|
|
+ curItem.id = "出差_" + businessTrip.getId();
|
|
|
+ curItem.userId = businessTrip.getOwnerId();
|
|
|
+ curItem.text = "出差/" + businessTrip.getOwnerName();
|
|
|
+ curItem.start_date = bustripProject.getStartDate().toString();
|
|
|
+ curItem.end_date = bustripProject.getEndDate().toString();
|
|
|
+ curItem.parent = btLastItemId;
|
|
|
+ itemList.add(curItem);
|
|
|
+ btLastItemId = String.valueOf(bustripProject.getProjectId());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-// List<BusinessTrip> businessTripList = businessTripMapper.selectList(btQueryWrapper);
|
|
|
-// for(int i=0;i<businessTripList.size();i++){
|
|
|
-// GanttDataItem curItem = new GanttDataItem();
|
|
|
-// if(businessTripList.get(i).getProjectId()!=null) {
|
|
|
-// Project project = projectMapper.selectById(businessTripList.get(i).getProjectId());
|
|
|
-// businessTripList.get(i).setProjectName(project.getProjectName());
|
|
|
-// if (!businessTripList.get(i).getProjectId().equals(btLastItemId)) {
|
|
|
-// //抽取父级对象,项目名称
|
|
|
-// GanttDataItem parent = new GanttDataItem();
|
|
|
-// parent.id = String.valueOf(businessTripList.get(i).getProjectId());
|
|
|
-// parent.userId = businessTripList.get(i).getOwnerId();
|
|
|
-// parent.text = businessTripList.get(i).getProjectName();
|
|
|
-// parent.render = "split";
|
|
|
-// parent.start_date = businessTripList.get(i).getStartDate().toString();
|
|
|
-// parent.end_date = businessTripList.get(i).getEndDate().toString();
|
|
|
-// parent.time = 0;
|
|
|
-// itemList.add(parent);
|
|
|
-// btLastItemId = String.valueOf(businessTripList.get(i).getProjectId());
|
|
|
-// }
|
|
|
-// curItem.id = "出差_" + businessTripList.get(i).getId();
|
|
|
-// curItem.userId = businessTripList.get(i).getOwnerId();
|
|
|
-// curItem.text = "出差/" + businessTripList.get(i).getOwnerName();
|
|
|
-// curItem.start_date = businessTripList.get(i).getStartDate().toString();
|
|
|
-// curItem.end_date = businessTripList.get(i).getEndDate().toString();
|
|
|
-// curItem.parent = btLastItemId;
|
|
|
-// itemList.add(curItem);
|
|
|
-// btLastItemId = String.valueOf(businessTripList.get(i).getProjectId());
|
|
|
-// }
|
|
|
-// }
|
|
|
}
|
|
|
String lastItemId = null;
|
|
|
GanttDataItem lastParentItem = null;
|
|
@@ -1560,10 +1655,17 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
for (int i=0;i<ganttData.size(); i++) {
|
|
|
Map map = ganttData.get(i);
|
|
|
String userId = (String) map.get("user_id");
|
|
|
+ List<Map> finalGanttData = ganttData;
|
|
|
+ int finalI = i;
|
|
|
+ Optional<User> first = AllUser.stream().filter(us -> us.getId().equals(finalGanttData.get(finalI).get("user_id"))).findFirst();
|
|
|
+ Integer departmentId =null;
|
|
|
+ if(first.isPresent()){
|
|
|
+ departmentId=first.get().getDepartmentId();
|
|
|
+ }
|
|
|
String start_date = sdf.format((Date) map.get("start_date"));
|
|
|
String end_date = sdf.format((Date) map.get("end_date"));
|
|
|
String projectId = ""+ (Integer) map.get("id");
|
|
|
- String exeId = ""+ (Integer) map.get("exe_id");
|
|
|
+ String exeId = "任务"+ (Integer) map.get("exe_id");
|
|
|
String taskId = ""+ (Integer) map.get("task_id");
|
|
|
|
|
|
GanttDataItem curItem = new GanttDataItem();;
|
|
@@ -1578,6 +1680,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
parent.start_date = start_date;
|
|
|
parent.end_date = end_date;
|
|
|
parent.time = 0;
|
|
|
+ parent.parent=String.valueOf(departmentId);
|
|
|
itemList.add(parent);
|
|
|
lastItemId = userId;
|
|
|
lastParentItem = parent;
|
|
@@ -1817,18 +1920,22 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
//项目编号 项目名称 参与人 负责人 级别 开始日期 截止日期 合同金额
|
|
|
XSSFCell codeCell = row.getCell(0);
|
|
|
- XSSFCell nameCell = row.getCell(1);
|
|
|
- XSSFCell subNameCell = row.getCell(2);
|
|
|
- XSSFCell participatorCell = row.getCell(3);
|
|
|
- XSSFCell inchargerCell = row.getCell(4);
|
|
|
- XSSFCell levelCell = row.getCell(5);
|
|
|
- XSSFCell startDateCell = row.getCell(6);
|
|
|
- XSSFCell endDateCell = row.getCell(7);
|
|
|
- XSSFCell amountCell = row.getCell(8);
|
|
|
- XSSFCell isPublicCell = row.getCell(9);
|
|
|
+ XSSFCell categoryCell = row.getCell(1);
|
|
|
+ XSSFCell isPublicCell = row.getCell(2);
|
|
|
+ XSSFCell nameCell = row.getCell(3);
|
|
|
+ XSSFCell subNameCell = row.getCell(4);
|
|
|
+ XSSFCell participatorCell = row.getCell(5);
|
|
|
+ XSSFCell inchargerCell = row.getCell(6);
|
|
|
+ XSSFCell levelCell = row.getCell(7);
|
|
|
+ XSSFCell startDateCell = row.getCell(8);
|
|
|
+ XSSFCell endDateCell = row.getCell(9);
|
|
|
+ XSSFCell amountCell = row.getCell(10);
|
|
|
+
|
|
|
|
|
|
if (codeCell != null)codeCell.setCellType(CellType.STRING);
|
|
|
if (nameCell != null)nameCell.setCellType(CellType.STRING);
|
|
|
+ if (categoryCell != null)categoryCell.setCellType(CellType.STRING);
|
|
|
+ if (isPublicCell != null)isPublicCell.setCellType(CellType.STRING);
|
|
|
if (subNameCell != null)subNameCell.setCellType(CellType.STRING);
|
|
|
if (participatorCell != null)participatorCell.setCellType(CellType.STRING);
|
|
|
if (inchargerCell != null)inchargerCell.setCellType(CellType.STRING);
|
|
@@ -1836,11 +1943,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if (startDateCell != null)startDateCell.setCellType(CellType.NUMERIC);
|
|
|
if (endDateCell != null)endDateCell.setCellType(CellType.NUMERIC);
|
|
|
if (amountCell != null)amountCell.setCellType(CellType.STRING);
|
|
|
- if (isPublicCell != null)isPublicCell.setCellType(CellType.STRING);
|
|
|
if (nameCell == null) {//项目名称为空的直接跳过
|
|
|
throw new Exception("项目名称不能为空");
|
|
|
}
|
|
|
-
|
|
|
Project project = new Project();
|
|
|
if (codeCell != null) {
|
|
|
String code = codeCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
@@ -1852,6 +1957,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
//跳过第一行标题
|
|
|
continue;
|
|
|
}
|
|
|
+ //检查项目是否存在
|
|
|
+ List<ProjectCategory> projectCategoryList = projectCategoryMapper.selectList(new QueryWrapper<ProjectCategory>().eq("company_id", user.getCompanyId()));
|
|
|
+ Optional<ProjectCategory> category = projectCategoryList.stream().filter(pc -> pc.getName().equals(categoryCell.getStringCellValue())).findFirst();
|
|
|
+ if(!category.isPresent()){
|
|
|
+ throw new Exception("项目分类["+categoryCell.getStringCellValue()+"]不存在");
|
|
|
+ }
|
|
|
+ project.setCategory(category.get().getId());
|
|
|
+ project.setCategoryName(categoryCell.getStringCellValue());
|
|
|
//检查编号是否已经存在
|
|
|
if (!StringUtils.isEmpty(code)) {
|
|
|
int cnt = projectMapper.selectCount(new QueryWrapper<Project>().eq("project_code", code).eq("company_id", user.getCompanyId()));
|
|
@@ -1861,7 +1974,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
project.setProjectCode(code);
|
|
|
}
|
|
|
-
|
|
|
String name = nameCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
|
project.setCompanyId(user.getCompanyId());
|
|
|
project.setCreatorId(userId);
|
|
@@ -1991,6 +2103,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
Company company = companyMapper.selectById(user.getCompanyId());
|
|
|
List<String> headList = new ArrayList<String>();
|
|
|
headList.add("项目编号");
|
|
|
+ headList.add("项目分类");
|
|
|
+ headList.add("是否为公共项目");
|
|
|
headList.add("项目名称");
|
|
|
headList.add("负责人");
|
|
|
headList.add("参与人");
|
|
@@ -2017,6 +2131,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
for (Map<String, Object> map : list) {
|
|
|
List<String> rowData = new ArrayList<>();
|
|
|
rowData.add((String)map.get("project_code"));
|
|
|
+ rowData.add((String)map.get("category_name"));
|
|
|
+ rowData.add(("1".equals(map.get("is_public").toString())?"是":"否"));
|
|
|
rowData.add((String)map.get("project_name"));
|
|
|
rowData.add((String)map.get("incharger_name"));
|
|
|
rowData.add((String)map.get("participators"));
|