|
@@ -136,6 +136,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
ProviderCategoryMapper providerCategoryMapper;
|
|
|
@Resource
|
|
|
ProviderInfoMapper providerInfoMapper;
|
|
|
+ @Resource
|
|
|
+ ProjectMainMapper projectMainMapper;
|
|
|
|
|
|
@Resource
|
|
|
private HttpServletResponse response;
|
|
@@ -2431,6 +2433,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<CustomerInfo> customerInfoList = customerInfoMapper.selectList(new QueryWrapper<CustomerInfo>().eq("company_id", user.getCompanyId()));
|
|
|
//获取全部供货商
|
|
|
List<ProviderInfo> providerInfoList = providerInfoMapper.selectList(new QueryWrapper<ProviderInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ //获取主项目
|
|
|
+ List<ProjectMain> projectMainList = projectMainMapper.selectList(new QueryWrapper<ProjectMain>().eq("company_id", user.getCompanyId()));
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(company.getId());
|
|
|
List<Project> projectList = new ArrayList<Project>();
|
|
|
//由于第一行需要指明列对应的标题
|
|
|
int rowNum = sheet.getLastRowNum();
|
|
@@ -2458,7 +2463,13 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
HSSFCell categoryCell = row.getCell(1);
|
|
|
HSSFCell isPublicCell = row.getCell(2);
|
|
|
HSSFCell nameCell = row.getCell(3);
|
|
|
- HSSFCell subNameCell = row.getCell(4);
|
|
|
+ HSSFCell subNameCell=null;
|
|
|
+ HSSFCell mainNameCell=null;
|
|
|
+ if(timeType.getMainProjectState()==1){
|
|
|
+ mainNameCell = row.getCell(4);
|
|
|
+ }else {
|
|
|
+ subNameCell = row.getCell(4);
|
|
|
+ }
|
|
|
HSSFCell participatorCell = row.getCell(5);
|
|
|
HSSFCell inchargerCell = row.getCell(6);
|
|
|
HSSFCell levelCell = row.getCell(7);
|
|
@@ -2486,6 +2497,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if (categoryCell != null)categoryCell.setCellType(CellType.STRING);
|
|
|
if (isPublicCell != null)isPublicCell.setCellType(CellType.STRING);
|
|
|
if (subNameCell != null)subNameCell.setCellType(CellType.STRING);
|
|
|
+ if (mainNameCell != null)mainNameCell.setCellType(CellType.STRING);
|
|
|
if (participatorCell != null)participatorCell.setCellType(CellType.STRING);
|
|
|
if (inchargerCell != null)inchargerCell.setCellType(CellType.STRING);
|
|
|
if (levelCell != null)levelCell.setCellType(CellType.STRING);
|
|
@@ -2501,9 +2513,13 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
String code = codeCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
|
if (code.equals("项目编号") && rowIndex == 0) {
|
|
|
//检查是否有子项目列
|
|
|
- if (!subNameCell.getStringCellValue().trim().startsWith("子项目")) {
|
|
|
+ if (subNameCell!=null&&!subNameCell.getStringCellValue().trim().startsWith("子项目")&&timeType.getMainProjectState()!=1) {
|
|
|
throw new Exception("缺少子项目列,请下载最新模板");
|
|
|
}
|
|
|
+ //检查是否有主项目列
|
|
|
+ if (mainNameCell!=null&&!mainNameCell.getStringCellValue().trim().startsWith("主项目")&&timeType.getMainProjectState()==1) {
|
|
|
+ throw new Exception("缺少主项目列,请下载最新模板");
|
|
|
+ }
|
|
|
//跳过第一行标题
|
|
|
continue;
|
|
|
}
|
|
@@ -2630,6 +2646,40 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if (isPublicCell != null && !StringUtils.isEmpty(isPublicCell.getStringCellValue())) {
|
|
|
project.setIsPublic("是".equals(isPublicCell.getStringCellValue())?1:0);
|
|
|
}
|
|
|
+ if(timeType.getMainProjectState()!=1){
|
|
|
+ //处理子项目
|
|
|
+ if (subNameCell != null) {
|
|
|
+ //兼容中英文逗号
|
|
|
+ String[] subNames = subNameCell.getStringCellValue().trim().split(",|\\,");
|
|
|
+ if (subNames != null) {
|
|
|
+ for (String s : subNames) {
|
|
|
+ if (!StringUtils.isEmpty(s)) {
|
|
|
+ SubProject sp = new SubProject();
|
|
|
+ sp.setName(s);
|
|
|
+ sp.setProjectId(project.getId());
|
|
|
+ subProjectMapper.insert(sp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //处理主项目
|
|
|
+ if (mainNameCell != null) {
|
|
|
+ //兼容中英文逗号
|
|
|
+ String mainName = mainNameCell.getStringCellValue();
|
|
|
+ if (mainName != null) {
|
|
|
+ if (!StringUtils.isEmpty(mainName)) {
|
|
|
+ Optional<ProjectMain> first = projectMainList.stream().filter(pm -> pm.getName().equals(mainName)).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ project.setProjectMainId(first.get().getId());
|
|
|
+ }else {
|
|
|
+ msg.setError("主项目["+mainName+"]不存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if(projectMapper.insert(project)>0){
|
|
|
ProjectAuditor projectAuditor=new ProjectAuditor();
|
|
|
projectAuditor.setAuditorId(project.getInchargerId());
|
|
@@ -2638,21 +2688,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
projectAuditorMapper.insert(projectAuditor);
|
|
|
}
|
|
|
importCount++;
|
|
|
- //处理子项目
|
|
|
- if (subNameCell != null) {
|
|
|
- //兼容中英文逗号
|
|
|
- String[] subNames = subNameCell.getStringCellValue().trim().split(",|\\,");
|
|
|
- if (subNames != null) {
|
|
|
- for (String s : subNames) {
|
|
|
- if (!StringUtils.isEmpty(s)) {
|
|
|
- SubProject sp = new SubProject();
|
|
|
- sp.setName(s);
|
|
|
- sp.setProjectId(project.getId());
|
|
|
- subProjectMapper.insert(sp);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
//参与人
|
|
|
if (participatorCell != null) {
|
|
|
String part = participatorCell.getStringCellValue().trim();
|
|
@@ -4017,6 +4052,35 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return new HttpRespMsg();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getUserWorkingTimeStatic(String startDate, String endDate, Integer pageIndex, Integer pageSize, HttpServletRequest request,String userId,Integer departmentId) {
|
|
|
+ User targetUser = userMapper.selectById(request.getHeader("token"));
|
|
|
+ List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看全部人员工时统计");
|
|
|
+ List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看负责部门人员工时统计");
|
|
|
+ List<Integer> deptIds=null;
|
|
|
+ List<Department> userDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id",targetUser.getCompanyId()));
|
|
|
+ //判断查看权限
|
|
|
+ if(functionAllList.size()==0){
|
|
|
+ if(functionDeptList.size()>0){
|
|
|
+ deptIds = userDepartmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ }else {
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ deptIds.add(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ long total;
|
|
|
+ List<Map<String,Object>> resultList=projectMapper.getUserWorkingTimeStatic(startDate,endDate,pageIndex,pageSize,userId,departmentId,deptIds);
|
|
|
+ if(pageIndex!=null&&pageSize!=null){
|
|
|
+ total=projectMapper.findCountWithUserWorkingTime(startDate,endDate,pageIndex,pageSize,userId,departmentId,deptIds);
|
|
|
+ }else{
|
|
|
+ total=projectMapper.findCountWithUserWorkingTime(startDate,endDate,null,null,userId,departmentId,deptIds);
|
|
|
+ }
|
|
|
+ Map<String,Object> map=new HashMap<>();
|
|
|
+ map.put("result",resultList);
|
|
|
+ map.put("total",total);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private List<Department> getSubDepts(Department dp, List<Department> list) {
|
|
|
List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());
|