|
@@ -4379,7 +4379,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg importNewData(Integer companyId, Integer withCheckIn, MultipartFile multipartFile, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg importNewData(Integer companyId, MultipartFile multipartFile, HttpServletRequest request) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
@@ -4434,7 +4434,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
|
|
|
|
|
|
List<String> userNameList=new ArrayList<>();
|
|
|
- boolean hasDept = false;
|
|
|
for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
|
|
|
Row row = sheet.getRow(rowIndex);
|
|
|
if (row == null) {
|
|
@@ -4443,13 +4442,9 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
|
continue;
|
|
|
}
|
|
|
- String username = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(2).getStringCellValue().trim();
|
|
|
+ String username = row.getCell(1).getStringCellValue().trim();
|
|
|
|
|
|
if (rowIndex == 0) {
|
|
|
- String deptName = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(3).getStringCellValue().trim();
|
|
|
- if ("部门".equals(deptName)) {
|
|
|
- hasDept = true;
|
|
|
- }
|
|
|
if(username.equals("员工")){
|
|
|
continue;
|
|
|
}
|
|
@@ -4458,9 +4453,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
userNameList.add(username);
|
|
|
}
|
|
|
}
|
|
|
- int deptColumnExtra = (hasDept?1:0);
|
|
|
//下标从0开始
|
|
|
- int projectNameStartIndex = (withCheckIn==null?2:(6 + deptColumnExtra));
|
|
|
HttpRespMsg respMsg=new HttpRespMsg();
|
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
|
|
|
respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
|
|
@@ -4480,55 +4473,9 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
|
continue;
|
|
|
}
|
|
|
- if (rowIndex == 0) {
|
|
|
- //第一行是标题,获取项目名称
|
|
|
- int pIndex = projectNameStartIndex;
|
|
|
- boolean projectNotExists = false;
|
|
|
- String neProjectName = null;
|
|
|
- boolean subPNotExists = false;
|
|
|
- String neSubPName = null;
|
|
|
- while(pIndex < row.getLastCellNum() && row.getCell(pIndex).getCellTypeEnum() != CellType._NONE && row.getCell(pIndex).getCellTypeEnum() != CellType.BLANK) {
|
|
|
- row.getCell(pIndex).setCellType(CellType.STRING);
|
|
|
- String stringCellValue = row.getCell(pIndex).getStringCellValue().trim();
|
|
|
- final String projectName = stringCellValue.contains("/")?stringCellValue.split("/")[0].trim():stringCellValue;
|
|
|
- projectList.add(projectName);
|
|
|
- String subProject = stringCellValue.contains("/")?stringCellValue.split("/")[1].trim():"";
|
|
|
-
|
|
|
- subProjectList.add(subProject);
|
|
|
- if (!allProjectList.stream().filter(p->p.getProjectName().equals(projectName)||(p.getProjectCode()!=null&&p.getProjectCode().equals(projectName))).findAny().isPresent()) {
|
|
|
- projectNotExists = true;
|
|
|
- neProjectName = projectName;
|
|
|
- break;
|
|
|
- }
|
|
|
- //检查子项目是否存在
|
|
|
- if (!StringUtils.isEmpty(subProject) && !allSubProjectList.stream().anyMatch(subp->subp.getName().equals(subProject)||(subp.getCode()!=null&&subp.getCode().equals(subProject)))) {
|
|
|
- subPNotExists = true;
|
|
|
- neSubPName = subProject;
|
|
|
- break;
|
|
|
- }
|
|
|
- pIndex++;
|
|
|
- }
|
|
|
- if (projectNotExists) {
|
|
|
- //返回错误提示
|
|
|
- //msg.setError("项目["+neProjectName+"]不存在,请先在项目管理中添加或导入。");
|
|
|
- msg.setError(MessageUtils.message("project.noExist",neProjectName));
|
|
|
- return msg;
|
|
|
- }
|
|
|
- if (subPNotExists) {
|
|
|
- //返回错误提示
|
|
|
- //msg.setError("子项目["+neSubPName+"]不存在,请先在项目管理中添加或导入。");
|
|
|
- msg.setError(MessageUtils.message("project.sonNoExist",neSubPName));
|
|
|
- return msg;
|
|
|
- }
|
|
|
- } else {
|
|
|
+ if (rowIndex > 0) {
|
|
|
dataCount++;
|
|
|
//数据行
|
|
|
- for (int i=1;i<projectNameStartIndex+projectList.size(); i++) {
|
|
|
- if (row.getCell(i) != null) {
|
|
|
- row.getCell(i).setCellType(CellType.STRING);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if (row.getCell(0) == null) {
|
|
|
//msg.setError("第"+dataCount+"行缺少日期");
|
|
|
msg.setError(MessageUtils.message("data.NullErrorByRow",dataCount));
|
|
@@ -4541,7 +4488,16 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
msg.setError(MessageUtils.message("data.NullErrorByRow",dataCount));
|
|
|
return msg;
|
|
|
}
|
|
|
- String username = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(2).getStringCellValue().trim();
|
|
|
+ for (int i=1;i<=7;i++) {
|
|
|
+ if (row.getCell(i) != null) {
|
|
|
+ row.getCell(i).setCellType(CellType.STRING);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String username = row.getCell(1) != null?row.getCell(1).getStringCellValue().trim():null;
|
|
|
+ if (StringUtils.isEmpty(username)) {
|
|
|
+ msg.setError("员工姓名不能为空");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
//检查人员是否存在
|
|
|
Optional<User> any;
|
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
@@ -4556,49 +4512,87 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
return msg;
|
|
|
}
|
|
|
User reportCreator = any.get();
|
|
|
- for (int i=projectNameStartIndex; i < projectNameStartIndex + projectList.size(); i++) {
|
|
|
- if (row.getCell(i) == null) {
|
|
|
- continue;
|
|
|
+
|
|
|
+
|
|
|
+ String pCode = row.getCell(3)==null?null:row.getCell(3).getStringCellValue();
|
|
|
+ String pName = row.getCell(4)==null?null:row.getCell(4).getStringCellValue();
|
|
|
+ Project project = null;
|
|
|
+ if (StringUtils.isEmpty(pCode) && StringUtils.isEmpty(pName)) {
|
|
|
+ msg.setError("项目编码和名称至少填写一项");
|
|
|
+ return msg;
|
|
|
+ } else if (!StringUtils.isEmpty(pCode)) {
|
|
|
+ //优先按编码匹配
|
|
|
+ Optional<Project> first = allProjectList.stream().filter(p -> pCode.equals(p.getProjectCode())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ project = first.get();
|
|
|
}
|
|
|
- String stringCellValue = row.getCell(i).getStringCellValue();
|
|
|
- double time = 0;
|
|
|
- if (!StringUtils.isEmpty(stringCellValue)) {
|
|
|
- time = Double.parseDouble(stringCellValue);
|
|
|
- if (time > 0) {
|
|
|
- String pName = projectList.get(i-projectNameStartIndex);
|
|
|
- Project project = allProjectList.stream().filter(p -> p.getProjectName().equals(pName)||(p.getProjectCode()!=null&&p.getProjectCode().equals(pName))).findFirst().get();
|
|
|
- String subPName = subProjectList.get(i-projectNameStartIndex);
|
|
|
- Report report = new Report();
|
|
|
- report.setCompanyId(companyId);
|
|
|
- report.setCreatorId(reportCreator.getId());
|
|
|
- report.setDeptId(reportCreator.getDepartmentId());
|
|
|
- report.setProjectId(project.getId());
|
|
|
- //子项目
|
|
|
- if (!StringUtils.isEmpty(subPName)) {
|
|
|
- Optional<SubProject> first = allSubProjectList.stream()
|
|
|
- .filter(sub -> sub.getProjectId().equals(project.getId()) &&( sub.getName().equals(subPName)||(sub.getCode()!=null&&sub.getCode().equals(subPName)))).findFirst();
|
|
|
- if (first.isPresent()) {
|
|
|
- report.setSubProjectId(first.get().getId());
|
|
|
- }
|
|
|
- }
|
|
|
- report.setReportTimeType(1);
|
|
|
- report.setWorkingTime(time);
|
|
|
- report.setMultiWorktime(timeType.getMultiWorktime());
|
|
|
- report.setFillUserid(user.getId());
|
|
|
- if (timeType.getNeedDeptAudit() == 0) {
|
|
|
- report.setState(1);//导入的直接算审核通过
|
|
|
- } else {
|
|
|
- report.setState(-1);//待部门上级审核员审核
|
|
|
- report.setDepartmentAuditState(1);//部门已审核,到上层领导审核
|
|
|
- }
|
|
|
- report.setCreateDate(LocalDate.parse(reportDate, dtf));
|
|
|
- report.setCost(reportCreator.getCost()==null?new BigDecimal(0) : reportCreator.getCost().multiply(new BigDecimal(time)));
|
|
|
- reportList.add(report);
|
|
|
- } else if (time < 0) {
|
|
|
- //msg.setError(username + "的工时存在负数,请检查修改");
|
|
|
- msg.setError(MessageUtils.message("report.negativeError",username));
|
|
|
- return msg;
|
|
|
+ } else if (!StringUtils.isEmpty(pName)) {
|
|
|
+ Optional<Project> first = allProjectList.stream().filter(p -> pName.equals(p.getProjectName())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ project = first.get();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (project == null) {
|
|
|
+ msg.setError(MessageUtils.message("project.noExist","编码:"+pCode+"/名称:"+pName));
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ //检查子项目是否填写是否存在
|
|
|
+ String subPName = row.getCell(5) == null?null:row.getCell(5).getStringCellValue();
|
|
|
+ Integer projectId = project.getId();
|
|
|
+ Integer subProjectId = null;
|
|
|
+ if (!StringUtils.isEmpty(subPName)) {
|
|
|
+ Optional<SubProject> first = allSubProjectList.stream().filter(sub -> subPName.equals(sub.getName()) && sub.getProjectId().equals(projectId)).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ subProjectId = first.get().getId();
|
|
|
+ }
|
|
|
+ if (subProjectId == null) {
|
|
|
+ msg.setError("子项目:"+subPName+"在项目["+pCode+"/"+pName+"]下不存在,请检查");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //解析任务分组
|
|
|
+ String taskGroupName = row.getCell(6)==null?null:row.getCell(6).getStringCellValue();
|
|
|
+ Integer groupId = null;
|
|
|
+ if (!StringUtils.isEmpty(taskGroupName)) {
|
|
|
+ List<TaskGroup> taskGroupList = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().eq("project_id", projectId).eq("name", taskGroupName));
|
|
|
+ if (taskGroupList.size() > 0) {
|
|
|
+ TaskGroup taskGroup = taskGroupList.get(0);
|
|
|
+ groupId = taskGroup.getId();
|
|
|
+ } else {
|
|
|
+ msg.setError("任务分组:"+taskGroupName+"在项目["+pCode+"/"+pName+"]下不存在,请检查");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String stringCellValue = row.getCell(7)==null?null:row.getCell(7).getStringCellValue();
|
|
|
+ double time = 0;
|
|
|
+ if (!StringUtils.isEmpty(stringCellValue)) {
|
|
|
+ time = Double.parseDouble(stringCellValue);
|
|
|
+ if (time > 0) {
|
|
|
+ Report report = new Report();
|
|
|
+ report.setCompanyId(companyId);
|
|
|
+ report.setCreatorId(reportCreator.getId());
|
|
|
+ report.setDeptId(reportCreator.getDepartmentId());
|
|
|
+ report.setProjectId(project.getId());
|
|
|
+ //子项目
|
|
|
+ report.setSubProjectId(subProjectId);
|
|
|
+ report.setGroupId(groupId);
|
|
|
+ report.setReportTimeType(1);
|
|
|
+ report.setWorkingTime(time);
|
|
|
+ report.setMultiWorktime(timeType.getMultiWorktime());
|
|
|
+ report.setFillUserid(user.getId());
|
|
|
+ if (timeType.getNeedDeptAudit() == 0) {
|
|
|
+ report.setState(1);//导入的直接算审核通过
|
|
|
+ } else {
|
|
|
+ report.setState(-1);//待部门上级审核员审核
|
|
|
+ report.setDepartmentAuditState(1);//部门已审核,到上层领导审核
|
|
|
}
|
|
|
+ report.setCreateDate(LocalDate.parse(reportDate, dtf));
|
|
|
+ report.setCost(reportCreator.getCost()==null?new BigDecimal(0) : reportCreator.getCost().multiply(new BigDecimal(time)));
|
|
|
+ reportList.add(report);
|
|
|
+ } else if (time < 0) {
|
|
|
+ msg.setError(MessageUtils.message("report.negativeError",username));
|
|
|
+ return msg;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -6964,38 +6958,43 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
if (collect.size() > 0) {
|
|
|
projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", collect));
|
|
|
//获取项目的任务分组列表
|
|
|
- List<TaskGroup> taskGroups = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().in("project_id", collect));
|
|
|
- //获取负责人的用户集合
|
|
|
- List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", taskGroups.stream().map(TaskGroup::getInchargerId).collect(Collectors.toList())));
|
|
|
- reportList.forEach(r->{
|
|
|
- r.setTaskGroups(taskGroups.stream().filter(tg->tg.getProjectId().equals(r.getProjectId())).collect(Collectors.toList()));
|
|
|
- for (TaskGroup gp : r.getTaskGroups()) {
|
|
|
- if (!StringUtils.isEmpty(gp.getInchargerId()) ) {
|
|
|
- if (gp.getInchargerId().equals(userId)) {
|
|
|
- //自己担任任务分组的负责人,自己的审核人是项目经理
|
|
|
- gp.setInchargerId(projectMapper.selectById(r.getProjectId()).getInchargerId());
|
|
|
- //如果自己就是项目经理,审核人变成自己的部门负责人
|
|
|
+ //需要是他参与的任务分组
|
|
|
+ List<GroupParticipator> groupParticipatorList = groupParticipatorMapper.selectList(new QueryWrapper<GroupParticipator>().eq("user_id", userId));
|
|
|
+ List<Integer> joinGroupList = groupParticipatorList.stream().map(GroupParticipator::getGroupId).collect(Collectors.toList());
|
|
|
+ if (joinGroupList.size() > 0) {
|
|
|
+ List<TaskGroup> taskGroups = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().in("project_id", collect).in("id", joinGroupList));
|
|
|
+ //获取负责人的用户集合
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", taskGroups.stream().map(TaskGroup::getInchargerId).collect(Collectors.toList())));
|
|
|
+ reportList.forEach(r->{
|
|
|
+ r.setTaskGroups(taskGroups.stream().filter(tg->tg.getProjectId().equals(r.getProjectId())).collect(Collectors.toList()));
|
|
|
+ for (TaskGroup gp : r.getTaskGroups()) {
|
|
|
+ if (!StringUtils.isEmpty(gp.getInchargerId()) ) {
|
|
|
if (gp.getInchargerId().equals(userId)) {
|
|
|
- Integer dpId = user.getDepartmentId();
|
|
|
- if (dpId != null && dpId > 0) {
|
|
|
- Department department = departmentMapper.selectById(dpId);
|
|
|
- if (department != null) {
|
|
|
- gp.setInchargerId(department.getManagerId());
|
|
|
+ //自己担任任务分组的负责人,自己的审核人是项目经理
|
|
|
+ gp.setInchargerId(projectMapper.selectById(r.getProjectId()).getInchargerId());
|
|
|
+ //如果自己就是项目经理,审核人变成自己的部门负责人
|
|
|
+ if (gp.getInchargerId().equals(userId)) {
|
|
|
+ Integer dpId = user.getDepartmentId();
|
|
|
+ if (dpId != null && dpId > 0) {
|
|
|
+ Department department = departmentMapper.selectById(dpId);
|
|
|
+ if (department != null) {
|
|
|
+ gp.setInchargerId(department.getManagerId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ //不存在的话,加上项目经理
|
|
|
+ if (!userList.stream().anyMatch(u->u.getId().equals(gp.getInchargerId()))) {
|
|
|
+ userList.add(userMapper.selectById(gp.getInchargerId()));
|
|
|
+ }
|
|
|
}
|
|
|
- //不存在的话,加上项目经理
|
|
|
- if (!userList.stream().anyMatch(u->u.getId().equals(gp.getInchargerId()))) {
|
|
|
- userList.add(userMapper.selectById(gp.getInchargerId()));
|
|
|
+ Optional<User> first = userList.stream().filter(u -> u.getId().equals(gp.getInchargerId())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ gp.setInchargerName(first.get().getName());
|
|
|
}
|
|
|
}
|
|
|
- Optional<User> first = userList.stream().filter(u -> u.getId().equals(gp.getInchargerId())).findFirst();
|
|
|
- if (first.isPresent()) {
|
|
|
- gp.setInchargerName(first.get().getName());
|
|
|
- }
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
reportMap.put("projectList", projectList);
|