|
@@ -3707,6 +3707,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
User user = userMapper.selectById(userId);
|
|
User user = userMapper.selectById(userId);
|
|
TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",user.getCompanyId()));
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",user.getCompanyId()));
|
|
|
|
+ List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
|
|
//然后处理文件
|
|
//然后处理文件
|
|
String fileName = multipartFile.getOriginalFilename();
|
|
String fileName = multipartFile.getOriginalFilename();
|
|
File file = new File(fileName == null ? "file" : fileName);
|
|
File file = new File(fileName == null ? "file" : fileName);
|
|
@@ -3723,6 +3724,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
inputStream.close();
|
|
inputStream.close();
|
|
outputStream.close();
|
|
outputStream.close();
|
|
if(fileName.endsWith(".xlsx")){
|
|
if(fileName.endsWith(".xlsx")){
|
|
|
|
+ //部门
|
|
|
|
+ boolean projectWithDept = false;
|
|
//然后解析表格
|
|
//然后解析表格
|
|
XSSFWorkbook workbook = new XSSFWorkbook(file);
|
|
XSSFWorkbook workbook = new XSSFWorkbook(file);
|
|
//我们只需要第一个sheet
|
|
//我们只需要第一个sheet
|
|
@@ -3756,6 +3759,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
projectLevelMap.put(MessageUtils.message("excel.highRisk"), 7);
|
|
projectLevelMap.put(MessageUtils.message("excel.highRisk"), 7);
|
|
List<String> existCodeList = new ArrayList<>();
|
|
List<String> existCodeList = new ArrayList<>();
|
|
List<String> userNameList=new ArrayList<>();
|
|
List<String> userNameList=new ArrayList<>();
|
|
|
|
+
|
|
for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
|
|
for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
|
|
XSSFRow row = sheet.getRow(rowIndex);
|
|
XSSFRow row = sheet.getRow(rowIndex);
|
|
if (row == null) {
|
|
if (row == null) {
|
|
@@ -3765,8 +3769,19 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- XSSFCell participatorCell = row.getCell(5);
|
|
|
|
- XSSFCell inchargerCell = row.getCell(6);
|
|
|
|
|
|
+ //检测是否有所属部门列
|
|
|
|
+ if (rowIndex == 0) {
|
|
|
|
+ XSSFCell cell = row.getCell(0);
|
|
|
|
+ if (cell != null) {
|
|
|
|
+ String cellValue = cell.getStringCellValue();
|
|
|
|
+ if (cellValue.equals("所属部门")) {
|
|
|
|
+ //第一列是所属部门
|
|
|
|
+ projectWithDept = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ XSSFCell participatorCell = row.getCell(6+(projectWithDept?1:0));
|
|
|
|
+ XSSFCell inchargerCell = row.getCell(7+(projectWithDept?1:0));
|
|
if (participatorCell!=null)participatorCell.setCellType(CellType.STRING);
|
|
if (participatorCell!=null)participatorCell.setCellType(CellType.STRING);
|
|
if (inchargerCell != null)inchargerCell.setCellType(CellType.STRING);
|
|
if (inchargerCell != null)inchargerCell.setCellType(CellType.STRING);
|
|
String part = participatorCell.getStringCellValue().trim();
|
|
String part = participatorCell.getStringCellValue().trim();
|
|
@@ -3804,30 +3819,31 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- //项目编号 项目名称 参与人 负责人 级别 开始日期 截止日期 合同金额
|
|
|
|
- XSSFCell codeCell = row.getCell(0);
|
|
|
|
- XSSFCell categoryCell = row.getCell(1);
|
|
|
|
- XSSFCell isPublicCell = row.getCell(2);
|
|
|
|
- XSSFCell nameCell = row.getCell(3);
|
|
|
|
- XSSFCell descCell = row.getCell(4);
|
|
|
|
- XSSFCell subNameCell = row.getCell(5);
|
|
|
|
- XSSFCell participatorCell = row.getCell(6);
|
|
|
|
- XSSFCell inchargerCell = row.getCell(7);
|
|
|
|
|
|
+ //项目编号 项目分类 项目名称 参与人 负责人 级别 开始日期 截止日期 合同金额
|
|
|
|
+ XSSFCell deptCell = projectWithDept?row.getCell(0):null;
|
|
|
|
+ XSSFCell codeCell = row.getCell(0+(projectWithDept?1:0));
|
|
|
|
+ XSSFCell categoryCell = row.getCell(1+(projectWithDept?1:0));
|
|
|
|
+ XSSFCell isPublicCell = row.getCell(2+(projectWithDept?1:0));
|
|
|
|
+ XSSFCell nameCell = row.getCell(3+(projectWithDept?1:0));
|
|
|
|
+ XSSFCell descCell = row.getCell(4+(projectWithDept?1:0));
|
|
|
|
+ XSSFCell subNameCell = row.getCell(5+(projectWithDept?1:0));
|
|
|
|
+ XSSFCell participatorCell = row.getCell(6+(projectWithDept?1:0));
|
|
|
|
+ XSSFCell inchargerCell = row.getCell(7+(projectWithDept?1:0));
|
|
XSSFCell reportAuditorsCell=null;
|
|
XSSFCell reportAuditorsCell=null;
|
|
XSSFCell reportCcCell=null;
|
|
XSSFCell reportCcCell=null;
|
|
int i=0;
|
|
int i=0;
|
|
if(timeType.getReportAuditType()==0||timeType.getReportAuditType()==4||timeType.getReportAuditType()==6){
|
|
if(timeType.getReportAuditType()==0||timeType.getReportAuditType()==4||timeType.getReportAuditType()==6){
|
|
i++;
|
|
i++;
|
|
- reportAuditorsCell = row.getCell(7+i);
|
|
|
|
|
|
+ reportAuditorsCell = row.getCell(7+(projectWithDept?1:0)+i);
|
|
}
|
|
}
|
|
if(timeType.getReportAuditType()==7){
|
|
if(timeType.getReportAuditType()==7){
|
|
i++;
|
|
i++;
|
|
- reportCcCell=row.getCell(7+i);
|
|
|
|
|
|
+ reportCcCell=row.getCell(7+(projectWithDept?1:0)+i);
|
|
}
|
|
}
|
|
- XSSFCell levelCell = row.getCell(8+i);
|
|
|
|
- XSSFCell startDateCell = row.getCell(9+i);
|
|
|
|
- XSSFCell endDateCell = row.getCell(10+i);
|
|
|
|
- XSSFCell amountCell = row.getCell(11+i);
|
|
|
|
|
|
+ XSSFCell levelCell = row.getCell(8+(projectWithDept?1:0)+i);
|
|
|
|
+ XSSFCell startDateCell = row.getCell(9+(projectWithDept?1:0)+i);
|
|
|
|
+ XSSFCell endDateCell = row.getCell(10+(projectWithDept?1:0)+i);
|
|
|
|
+ XSSFCell amountCell = row.getCell(11+(projectWithDept?1:0)+i);
|
|
|
|
|
|
|
|
|
|
if (codeCell != null)codeCell.setCellType(CellType.STRING);
|
|
if (codeCell != null)codeCell.setCellType(CellType.STRING);
|
|
@@ -3892,6 +3908,32 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
project.setCreatorName(user.getName());
|
|
project.setCreatorName(user.getName());
|
|
project.setProjectName(name);
|
|
project.setProjectName(name);
|
|
project.setCreateDate(LocalDate.now());
|
|
project.setCreateDate(LocalDate.now());
|
|
|
|
+ if (projectWithDept) {
|
|
|
|
+ if (!StringUtils.isEmpty(deptCell.getStringCellValue())) {
|
|
|
|
+ Department targetDept = null;
|
|
|
|
+ if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1) {
|
|
|
|
+ //通过企业微信接口搜索部门
|
|
|
|
+ Integer wxDeptId = wxCorpInfoService.searchCorpWxDeptId(wxCorpInfo.getCorpid(), deptCell.getStringCellValue());
|
|
|
|
+ if (wxDeptId != null) {
|
|
|
|
+ targetDept = allDeptList.stream().filter(d -> wxDeptId.equals(d.getCorpwxDeptid())).findFirst().get();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //直接搜索数据库
|
|
|
|
+ Optional<Department> first = allDeptList.stream().filter(d -> d.getDepartmentName().equals(deptCell.getStringCellValue())).findFirst();
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
+ targetDept = first.get();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (targetDept != null) {
|
|
|
|
+ //设置所属部门
|
|
|
|
+ Integer deptId = targetDept.getDepartmentId();
|
|
|
|
+ project.setDeptId(deptId);
|
|
|
|
+ project.setDeptCascade(convertDepartmentIdToCascade(deptId));
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("部门[" + deptCell.getStringCellValue() + "]不存在");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
//处理人员
|
|
//处理人员
|
|
if (inchargerCell != null) {
|
|
if (inchargerCell != null) {
|
|
@@ -8177,9 +8219,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
inchagerIds=new ArrayList<>();
|
|
inchagerIds=new ArrayList<>();
|
|
if(functionInchargeList.size()>0){
|
|
if(functionInchargeList.size()>0){
|
|
List<Project> list = projectList.stream().filter(pl -> (pl.getInchargerId()==null?0:pl.getInchargerId()).equals(user.getId())).collect(Collectors.toList());
|
|
List<Project> list = projectList.stream().filter(pl -> (pl.getInchargerId()==null?0:pl.getInchargerId()).equals(user.getId())).collect(Collectors.toList());
|
|
- if(list!=null){
|
|
|
|
|
|
+ if(list.size() > 0){
|
|
List<Integer> collect = list.stream().map(li -> li.getId()).collect(Collectors.toList());
|
|
List<Integer> collect = list.stream().map(li -> li.getId()).collect(Collectors.toList());
|
|
inchagerIds.addAll(collect);
|
|
inchagerIds.addAll(collect);
|
|
|
|
+ } else {
|
|
|
|
+ inchagerIds.add(-1);
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
inchagerIds.add(-1);
|
|
inchagerIds.add(-1);
|
|
@@ -8217,9 +8261,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
inchagerIds=new ArrayList<>();
|
|
inchagerIds=new ArrayList<>();
|
|
if(functionInchargeList.size()>0){
|
|
if(functionInchargeList.size()>0){
|
|
List<Project> list = projectList.stream().filter(pl -> (pl.getInchargerId()==null?0:pl.getInchargerId()).equals(user.getId())).collect(Collectors.toList());
|
|
List<Project> list = projectList.stream().filter(pl -> (pl.getInchargerId()==null?0:pl.getInchargerId()).equals(user.getId())).collect(Collectors.toList());
|
|
- if(list!=null){
|
|
|
|
|
|
+ if(list.size() > 0){
|
|
List<Integer> collect = list.stream().map(li -> li.getId()).collect(Collectors.toList());
|
|
List<Integer> collect = list.stream().map(li -> li.getId()).collect(Collectors.toList());
|
|
inchagerIds.addAll(collect);
|
|
inchagerIds.addAll(collect);
|
|
|
|
+ } else {
|
|
|
|
+ inchagerIds.add(-1);
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
inchagerIds.add(-1);
|
|
inchagerIds.add(-1);
|