|
@@ -2492,7 +2492,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,departmentId,deptIds);
|
|
|
+ List<Integer> branchDepartment =null;
|
|
|
+ if(departmentId!=null){
|
|
|
+ branchDepartment = getBranchDepartment(departmentId, allDepartmentList);
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,branchDepartment,deptIds);
|
|
|
boolean hasViewSalary = sysFunctionService.hasPriviledge(user.getRoleId(), "查看加班成本");
|
|
|
if (!hasViewSalary) {
|
|
|
//去掉权限
|
|
@@ -4435,7 +4439,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,start,size,departmentId,deptIds);
|
|
|
+ //获取筛选部门 子部门数据
|
|
|
+ List<Integer> branchDepartment =null;
|
|
|
+ if(departmentId!=null){
|
|
|
+ branchDepartment = getBranchDepartment(departmentId, allDepartmentList);
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,start,size,branchDepartment,deptIds);
|
|
|
long total=projectMapper.findCountWithUser(userId, user.getCompanyId(), startDate, endDate, projectId,null,null,departmentId,deptIds);
|
|
|
list.forEach(li->{
|
|
|
double isPublic = (double) li.get("isPublic");
|
|
@@ -4535,8 +4544,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<Map<String,Object>> reportList=reportMapper.getUserReportTimelinessRate(targetUser.getCompanyId(),startDate,endDate);
|
|
|
QueryWrapper<User> queryWrapper=new QueryWrapper();
|
|
|
queryWrapper.eq("company_id",targetUser.getCompanyId());
|
|
|
+ List<Integer> branchDepartment =null;
|
|
|
if(departmentId!=null){
|
|
|
- queryWrapper.eq("department_id",departmentId);
|
|
|
+ branchDepartment = getBranchDepartment(departmentId, allDepartmentList);
|
|
|
+ }
|
|
|
+ if(branchDepartment!=null&&branchDepartment.size()>0){
|
|
|
+ queryWrapper.in("department_id",branchDepartment);
|
|
|
}
|
|
|
if(userId!=null){
|
|
|
queryWrapper.eq("id",userId);
|
|
@@ -4779,14 +4792,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
long total;
|
|
|
List<Map<String,Object>> resultList;
|
|
|
+ List<Integer> branchDepartment =null;
|
|
|
+ if(departmentId!=null){
|
|
|
+ branchDepartment = getBranchDepartment(departmentId, allDepartmentList);
|
|
|
+ }
|
|
|
if(pageIndex!=null&&pageSize!=null){
|
|
|
Integer size=pageSize;
|
|
|
Integer start=(pageIndex-1)*size;
|
|
|
- resultList=projectMapper.getUserWorkingTimeStatic(targetUser.getCompanyId(),startDate,endDate,start,size,userId,departmentId,deptIds);
|
|
|
- total=projectMapper.findCountWithUserWorkingTime(targetUser.getCompanyId(),startDate,endDate,start,size,userId,departmentId,deptIds);
|
|
|
+ resultList=projectMapper.getUserWorkingTimeStatic(targetUser.getCompanyId(),startDate,endDate,start,size,userId,branchDepartment,deptIds);
|
|
|
+ total=projectMapper.findCountWithUserWorkingTime(targetUser.getCompanyId(),startDate,endDate,start,size,userId,branchDepartment,deptIds);
|
|
|
}else{
|
|
|
- resultList=projectMapper.getUserWorkingTimeStatic(targetUser.getCompanyId(),startDate,endDate,null,null,userId,departmentId,deptIds);
|
|
|
- total=projectMapper.findCountWithUserWorkingTime(targetUser.getCompanyId(),startDate,endDate,null,null,userId,departmentId,deptIds);
|
|
|
+ resultList=projectMapper.getUserWorkingTimeStatic(targetUser.getCompanyId(),startDate,endDate,null,null,userId,branchDepartment,deptIds);
|
|
|
+ total=projectMapper.findCountWithUserWorkingTime(targetUser.getCompanyId(),startDate,endDate,null,null,userId,branchDepartment,deptIds);
|
|
|
}
|
|
|
for (Map<String, Object> map : resultList) {
|
|
|
BigDecimal phBigDecimal =new BigDecimal(String.valueOf(map.get("planHours")==null?0:map.get("planHours")));
|
|
@@ -5365,8 +5382,191 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg importPersonnelWithGroup(MultipartFile file, HttpServletRequest request) {
|
|
|
- return null;
|
|
|
+ public HttpRespMsg importPersonnelWithGroup(MultipartFile multipartFile, HttpServletRequest request) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
|
|
|
+ //然后处理文件
|
|
|
+ String fileName = multipartFile.getOriginalFilename();
|
|
|
+ File file = new File(fileName == null ? "file" : fileName);
|
|
|
+ InputStream inputStream = null;
|
|
|
+ OutputStream outputStream = null;
|
|
|
+ try {
|
|
|
+ inputStream = multipartFile.getInputStream();
|
|
|
+ outputStream = new FileOutputStream(file);
|
|
|
+ byte[] buffer = new byte[4096];
|
|
|
+ int temp = 0;
|
|
|
+ while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
|
|
|
+ outputStream.write(buffer, 0, temp);
|
|
|
+ }
|
|
|
+ inputStream.close();
|
|
|
+ outputStream.close();
|
|
|
+ //然后解析表格
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook(file);
|
|
|
+ //我们只需要第一个sheet
|
|
|
+ XSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
+ //由于第一行需要指明列对应的标题
|
|
|
+ int rowNum = sheet.getLastRowNum();
|
|
|
+ int importCount = 0;
|
|
|
+ for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
|
|
|
+ XSSFRow row = sheet.getRow(rowIndex);
|
|
|
+ if (row == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //跳过空行
|
|
|
+ if (ExcelUtil.isRowEmpty(row)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //项目编号 项目名称 参与人 负责人 级别 开始日期 截止日期 合同金额
|
|
|
+ XSSFCell codeCell = row.getCell(0);
|
|
|
+ XSSFCell nameCell = row.getCell(1);
|
|
|
+ XSSFCell groupCell = row.getCell(2);
|
|
|
+ XSSFCell inchargerCell = row.getCell(3);
|
|
|
+ XSSFCell participatorCell = row.getCell(4);
|
|
|
+
|
|
|
+
|
|
|
+ if (codeCell != null) codeCell.setCellType(CellType.STRING);
|
|
|
+ if (nameCell != null) nameCell.setCellType(CellType.STRING);
|
|
|
+ if (groupCell !=null) groupCell.setCellType(CellType.STRING);
|
|
|
+ if (inchargerCell != null) inchargerCell.setCellType(CellType.STRING);
|
|
|
+ if (participatorCell != null) participatorCell.setCellType(CellType.STRING);
|
|
|
+
|
|
|
+ if (codeCell != null) {
|
|
|
+ String code = codeCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
|
+ if (code.equals("项目编号") && rowIndex == 0) {
|
|
|
+ //跳过第一行标题
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //检查编号是否已经存在
|
|
|
+ if (!StringUtils.isEmpty(code)) {
|
|
|
+ int cnt = projectMapper.selectCount(new QueryWrapper<Project>().eq("project_code", code).eq("company_id", user.getCompanyId()));
|
|
|
+ if (cnt <= 0) {
|
|
|
+ msg.setError("项目编号["+code+"]不存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("project_code", code).eq("company_id", user.getCompanyId()));
|
|
|
+ if(projectList.size()>0){
|
|
|
+ Project project = projectList.get(0);
|
|
|
+ if(nameCell!=null){
|
|
|
+ String name = nameCell.getStringCellValue();
|
|
|
+ if(StringUtils.isEmpty(name)){
|
|
|
+ msg.setError("项目编号为["+code+"]的项目名称为["+name+"]的项目不存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(groupCell!=null){
|
|
|
+ List<TaskGroup> groupList = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().eq("project_id", project.getId()).eq("name", groupCell.getStringCellValue()));
|
|
|
+ if(groupList.size()<=0){
|
|
|
+ msg.setError("项目名称为["+project.getProjectName()+"]的任务分组["+groupCell.getStringCellValue()+"]不存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ TaskGroup taskGroup = groupList.get(0);
|
|
|
+ if(inchargerCell!=null){
|
|
|
+ String incharger = inchargerCell.getStringCellValue();
|
|
|
+ Optional<User> first = userList.stream().filter(ul -> ul.getName().equals(incharger)).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ taskGroup.setInchargerId(first.get().getId());
|
|
|
+ }
|
|
|
+ taskGroupMapper.updateById(taskGroup);
|
|
|
+ if(participatorCell!=null){
|
|
|
+ String participator = participatorCell.getStringCellValue();
|
|
|
+ String[] split = participator.split(",");
|
|
|
+ List<String> list = Arrays.asList(split);
|
|
|
+ groupParticipatorMapper.delete(new QueryWrapper<GroupParticipator>().eq("group_id", taskGroup.getId()));
|
|
|
+ for (String s : list) {
|
|
|
+ Optional<User> optionalUser = userList.stream().filter(ul -> ul.getName().equals(s)).findFirst();
|
|
|
+ if(optionalUser.isPresent()){
|
|
|
+ GroupParticipator groupParticipator=new GroupParticipator();
|
|
|
+ groupParticipator.setUserId(optionalUser.get().getId());
|
|
|
+ groupParticipator.setGroupId(taskGroup.getId());
|
|
|
+ groupParticipatorMapper.insert(groupParticipator);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ importCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(nameCell!=null){
|
|
|
+ String name = nameCell.getStringCellValue();
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("project_name", name).eq("company_id", user.getCompanyId()));
|
|
|
+ Project project = projectList.get(0);
|
|
|
+ if(StringUtils.isEmpty(name)){
|
|
|
+ msg.setError("项目名称为["+name+"]的项目不存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ if(groupCell!=null){
|
|
|
+ List<TaskGroup> groupList = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().eq("project_id", project.getId()).eq("name", groupCell.getStringCellValue()));
|
|
|
+ if(groupList.size()<=0){
|
|
|
+ msg.setError("项目名称为["+project.getProjectName()+"]的任务分组["+groupCell.getStringCellValue()+"]不存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ TaskGroup taskGroup = groupList.get(0);
|
|
|
+ if(inchargerCell!=null){
|
|
|
+ String incharger = inchargerCell.getStringCellValue();
|
|
|
+ Optional<User> first = userList.stream().filter(ul -> ul.getName().equals(incharger)).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ taskGroup.setInchargerId(first.get().getId());
|
|
|
+ }
|
|
|
+ taskGroupMapper.updateById(taskGroup);
|
|
|
+ if(participatorCell!=null){
|
|
|
+ String participator = participatorCell.getStringCellValue();
|
|
|
+ String[] split = participator.split(",");
|
|
|
+ List<String> list = Arrays.asList(split);
|
|
|
+ groupParticipatorMapper.delete(new QueryWrapper<GroupParticipator>().eq("group_id", taskGroup.getId()));
|
|
|
+ for (String s : list) {
|
|
|
+ Optional<User> optionalUser = userList.stream().filter(ul -> ul.getName().equals(s)).findFirst();
|
|
|
+ if(optionalUser.isPresent()){
|
|
|
+ GroupParticipator groupParticipator=new GroupParticipator();
|
|
|
+ groupParticipator.setUserId(optionalUser.get().getId());
|
|
|
+ groupParticipator.setGroupId(taskGroup.getId());
|
|
|
+ groupParticipatorMapper.insert(groupParticipator);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ importCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ msg.data = "成功导入" + importCount + "条数据。";
|
|
|
+ }catch(IOException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ msg.setError("文件处理出错");
|
|
|
+ return msg;
|
|
|
+ } catch(NullPointerException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ msg.setError("数据格式有误或存在空数据 导入失败");
|
|
|
+ return msg;
|
|
|
+ }catch(InvalidFormatException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ msg.setError("文件格式错误,如果安装了加密软件需要先解密再上传");
|
|
|
+ }catch(EncryptedDocumentException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ msg.setError("文件加密状态,需要先解除加密状态再上传");
|
|
|
+ return msg;
|
|
|
+ } catch(Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ msg.setError("上传失败:" + e.getMessage());
|
|
|
+ return msg;
|
|
|
+ } finally{
|
|
|
+ //关闭流
|
|
|
+ try {
|
|
|
+ if (outputStream != null && inputStream != null) {
|
|
|
+ outputStream.close();
|
|
|
+ inputStream.close();
|
|
|
+ System.out.println("流已关闭");
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+// file.deleteOnExit();//程序退出时删除临时文件
|
|
|
+ System.out.println(file.delete());
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
}
|
|
|
|
|
|
|