|
@@ -3853,8 +3853,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
msg.setError(MessageUtils.message("report.data"));
|
|
msg.setError(MessageUtils.message("report.data"));
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
- List<String> projectList = new ArrayList<>();
|
|
|
|
- List<String> subProjectList = new ArrayList<>();
|
|
|
|
List<Project> allProjectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
|
|
List<Project> allProjectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
|
|
List<SubProject> allSubProjectList = subProjectMapper.selectList(new QueryWrapper<SubProject>().eq("company_id", companyId));
|
|
List<SubProject> allSubProjectList = subProjectMapper.selectList(new QueryWrapper<SubProject>().eq("company_id", companyId));
|
|
List<Report> reportList = new ArrayList<>();
|
|
List<Report> reportList = new ArrayList<>();
|
|
@@ -3870,10 +3868,12 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- String username = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(2).getStringCellValue().trim();
|
|
|
|
|
|
+// String username = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(2).getStringCellValue().trim();
|
|
|
|
+ String username =row.getCell(1).getStringCellValue().trim();
|
|
|
|
|
|
if (rowIndex == 0) {
|
|
if (rowIndex == 0) {
|
|
- String deptName = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(3).getStringCellValue().trim();
|
|
|
|
|
|
+// String deptName = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(3).getStringCellValue().trim();
|
|
|
|
+ String deptName =row.getCell(1).getStringCellValue().trim();
|
|
if ("部门".equals(deptName)) {
|
|
if ("部门".equals(deptName)) {
|
|
hasDept = true;
|
|
hasDept = true;
|
|
}
|
|
}
|
|
@@ -3886,8 +3886,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
}
|
|
}
|
|
}
|
|
}
|
|
int deptColumnExtra = (hasDept?1:0);
|
|
int deptColumnExtra = (hasDept?1:0);
|
|
- //下标从0开始
|
|
|
|
- int projectNameStartIndex = (withCheckIn==null?2:(6 + deptColumnExtra));
|
|
|
|
|
|
+// //下标从0开始
|
|
|
|
+// int projectNameStartIndex = (withCheckIn==null?2:(6 + deptColumnExtra));
|
|
HttpRespMsg respMsg=new HttpRespMsg();
|
|
HttpRespMsg respMsg=new HttpRespMsg();
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
|
|
respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
|
|
respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
|
|
@@ -3908,125 +3908,99 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if (rowIndex == 0) {
|
|
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)).findAny().isPresent()) {
|
|
|
|
- projectNotExists = true;
|
|
|
|
- neProjectName = projectName;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- //检查子项目是否存在
|
|
|
|
- if (!StringUtils.isEmpty(subProject) && !allSubProjectList.stream().anyMatch(subp->subp.getName().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 {
|
|
|
|
- dataCount++;
|
|
|
|
- //数据行
|
|
|
|
- for (int i=1;i<projectNameStartIndex+projectList.size(); i++) {
|
|
|
|
- if (row.getCell(i) != null) {
|
|
|
|
- row.getCell(i).setCellType(CellType.STRING);
|
|
|
|
- }
|
|
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ dataCount++;
|
|
|
|
+ //数据行
|
|
|
|
+ for (int i=1;i<13; 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));
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
- boolean isDateFormat = row.getCell(0).getCellTypeEnum() == CellType.NUMERIC;
|
|
|
|
- String reportDate = isDateFormat?sdf.format(row.getCell(0).getDateCellValue()):row.getCell(0).getStringCellValue();
|
|
|
|
- if (StringUtils.isEmpty(reportDate)) {
|
|
|
|
- //msg.setError("第"+dataCount+"行缺少日期");
|
|
|
|
- msg.setError(MessageUtils.message("data.NullErrorByRow",dataCount));
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
- String username = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(2).getStringCellValue().trim();
|
|
|
|
- //检查人员是否存在
|
|
|
|
- Optional<User> any;
|
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
|
- Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(username)).findFirst();
|
|
|
|
- any = allUserList.stream().filter(u -> u.getName().equals(username)||(u.getJobNumber()!=null&&u.getJobNumber().equals(username))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findAny();
|
|
|
|
- }else {
|
|
|
|
- any = allUserList.stream().filter(u -> u.getName().equals(username)||(u.getJobNumber()!=null&&u.getJobNumber().equals(username))).findAny();
|
|
|
|
- }
|
|
|
|
- if (!any.isPresent()) {
|
|
|
|
- //msg.setError("人员["+username+"]不存在,请先在组织结构中添加或者通过钉钉同步导入");
|
|
|
|
- msg.setError(MessageUtils.message("staff.peopleNullAndAdd",username));
|
|
|
|
|
|
+ if (row.getCell(0) == null) {
|
|
|
|
+ //msg.setError("第"+dataCount+"行缺少日期");
|
|
|
|
+ msg.setError(MessageUtils.message("data.NullErrorByRow",dataCount));
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ boolean isDateFormat = row.getCell(0).getCellTypeEnum() == CellType.NUMERIC;
|
|
|
|
+ String reportDate = isDateFormat?sdf.format(row.getCell(0).getDateCellValue()):row.getCell(0).getStringCellValue();
|
|
|
|
+ if (StringUtils.isEmpty(reportDate)) {
|
|
|
|
+ //msg.setError("第"+dataCount+"行缺少日期");
|
|
|
|
+ msg.setError(MessageUtils.message("data.NullErrorByRow",dataCount));
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+// String username = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(2).getStringCellValue().trim();
|
|
|
|
+ String username = row.getCell(1).getStringCellValue().trim();
|
|
|
|
+ //检查人员是否存在
|
|
|
|
+ Optional<User> any;
|
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
|
+ Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(username)).findFirst();
|
|
|
|
+ any = allUserList.stream().filter(u -> u.getName().equals(username)||(u.getJobNumber()!=null&&u.getJobNumber().equals(username))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findAny();
|
|
|
|
+ }else {
|
|
|
|
+ any = allUserList.stream().filter(u -> u.getName().equals(username)||(u.getJobNumber()!=null&&u.getJobNumber().equals(username))).findAny();
|
|
|
|
+ }
|
|
|
|
+ if (!any.isPresent()) {
|
|
|
|
+ //msg.setError("人员["+username+"]不存在,请先在组织结构中添加或者通过钉钉同步导入");
|
|
|
|
+ msg.setError(MessageUtils.message("staff.peopleNullAndAdd",username));
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ User reportCreator = any.get();
|
|
|
|
+ if(!StringUtils.isEmpty(row.getCell(2).getStringCellValue())&&!reportCreator.getJobNumber().equals(row.getCell(2).getStringCellValue())){
|
|
|
|
+ msg.setError("人员["+username+"]所填工号与系统不一致");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isEmpty(row.getCell(3).getStringCellValue())){
|
|
|
|
+ msg.setError("项目列不能为空");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ if(!StringUtils.isEmpty(row.getCell(3).getStringCellValue())&&!allProjectList.stream().anyMatch(al->al.getProjectName().equals(row.getCell(3).getStringCellValue()))){
|
|
|
|
+ msg.setError("项目["+row.getCell(3).getStringCellValue()+"]不存在");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ Optional<Project> project = allProjectList.stream().filter(al -> al.getProjectName().equals(row.getCell(3).getStringCellValue())).findFirst();
|
|
|
|
+ SubProject subP=new SubProject();
|
|
|
|
+ if(!StringUtils.isEmpty(row.getCell(4).getStringCellValue())){
|
|
|
|
+ if(!allSubProjectList.stream().anyMatch(al->al.getName().equals(row.getCell(4).getStringCellValue()))){
|
|
|
|
+ msg.setError("子项目["+row.getCell(4).getStringCellValue()+"]不存在");
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
- User reportCreator = any.get();
|
|
|
|
- for (int i=projectNameStartIndex; i < projectNameStartIndex + projectList.size(); i++) {
|
|
|
|
- if (row.getCell(i) == null) {
|
|
|
|
- continue;
|
|
|
|
|
|
+ Optional<SubProject> subProject = allSubProjectList.stream().filter(al -> al.getName().equals(row.getCell(4).getStringCellValue())).findFirst();
|
|
|
|
+ subP=subProject.get();
|
|
|
|
+ if(!subProject.get().getProjectId().equals(project.get().getId())){
|
|
|
|
+ msg.setError("子项目["+subProject.get().getName()+"]不属于项目["+project.get().getProjectName()+"]");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String stringCellValue = row.getCell(6).getStringCellValue();
|
|
|
|
+ double time=0;
|
|
|
|
+ if(!StringUtils.isEmpty(stringCellValue)){
|
|
|
|
+ time=Double.valueOf(stringCellValue);
|
|
|
|
+ if(time>0){
|
|
|
|
+ Report report = new Report();
|
|
|
|
+ report.setCompanyId(companyId);
|
|
|
|
+ report.setCreatorId(reportCreator.getId());
|
|
|
|
+ report.setDeptId(reportCreator.getDepartmentId());
|
|
|
|
+ report.setProjectId(project.get().getId());
|
|
|
|
+ //子项目
|
|
|
|
+ if (!StringUtils.isEmpty(subP.getName())) {
|
|
|
|
+ report.setSubProjectId(subP.getId());
|
|
}
|
|
}
|
|
- 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)).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)).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;
|
|
|
|
- }
|
|
|
|
|
|
+ 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 {
|
|
|
|
+ msg.setError(MessageUtils.message("report.negativeError",username));
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|