|
@@ -39,7 +39,6 @@ import java.sql.Timestamp;
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
import java.text.NumberFormat;
|
|
import java.text.NumberFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
-import java.time.Duration;
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalTime;
|
|
import java.time.LocalTime;
|
|
@@ -47,7 +46,6 @@ import java.time.chrono.ChronoLocalDate;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -2774,16 +2772,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
inputStream.close();
|
|
inputStream.close();
|
|
outputStream.close();
|
|
outputStream.close();
|
|
if(fileName.endsWith(".xlsx")){
|
|
if(fileName.endsWith(".xlsx")){
|
|
- if(!fileName.endsWith(".xlsx")){
|
|
|
|
- msg.setError("文件格式错误,请使用’.xlsx’格式");
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
//然后解析表格
|
|
//然后解析表格
|
|
XSSFWorkbook workbook = new XSSFWorkbook(file);
|
|
XSSFWorkbook workbook = new XSSFWorkbook(file);
|
|
//我们只需要第一个sheet
|
|
//我们只需要第一个sheet
|
|
XSSFSheet sheet = workbook.getSheetAt(0);
|
|
XSSFSheet sheet = workbook.getSheetAt(0);
|
|
//获取全部人员
|
|
//获取全部人员
|
|
- List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
|
|
|
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()).eq("is_active", 1));
|
|
//获取全部供货商分类列表
|
|
//获取全部供货商分类列表
|
|
List<ProviderCategory> providerCategoryList = providerCategoryMapper.selectList(new QueryWrapper<ProviderCategory>().eq("company_id", user.getCompanyId()));
|
|
List<ProviderCategory> providerCategoryList = providerCategoryMapper.selectList(new QueryWrapper<ProviderCategory>().eq("company_id", user.getCompanyId()));
|
|
Company company = companyMapper.selectById(user.getCompanyId());
|
|
Company company = companyMapper.selectById(user.getCompanyId());
|
|
@@ -2842,7 +2836,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
throw new Exception("项目名称不能为空");
|
|
throw new Exception("项目名称不能为空");
|
|
}
|
|
}
|
|
Project project = new Project();
|
|
Project project = new Project();
|
|
- boolean flag=false;
|
|
|
|
|
|
+ boolean exists=false;
|
|
if (codeCell != null) {
|
|
if (codeCell != null) {
|
|
String code = codeCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
String code = codeCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
if (code.equals("项目编号") && rowIndex == 0) {
|
|
if (code.equals("项目编号") && rowIndex == 0) {
|
|
@@ -2870,7 +2864,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
// throw new Exception("项目编号存在重复: " + code);
|
|
// throw new Exception("项目编号存在重复: " + code);
|
|
existCodeList.add(code);
|
|
existCodeList.add(code);
|
|
//跳过编号重复的数据
|
|
//跳过编号重复的数据
|
|
- flag=true;
|
|
|
|
|
|
+ exists=true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
project.setProjectCode(code);
|
|
project.setProjectCode(code);
|
|
@@ -2915,7 +2909,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
if (isPublicCell != null && !StringUtils.isEmpty(isPublicCell.getStringCellValue())) {
|
|
if (isPublicCell != null && !StringUtils.isEmpty(isPublicCell.getStringCellValue())) {
|
|
project.setIsPublic("是".equals(isPublicCell.getStringCellValue())?1:0);
|
|
project.setIsPublic("是".equals(isPublicCell.getStringCellValue())?1:0);
|
|
}
|
|
}
|
|
- if(flag){
|
|
|
|
|
|
+ if(exists){
|
|
Project updateProject = projectMapper.selectList(new QueryWrapper<Project>().eq("project_code", project.getProjectCode()).eq("company_id", user.getCompanyId())).get(0);
|
|
Project updateProject = projectMapper.selectList(new QueryWrapper<Project>().eq("project_code", project.getProjectCode()).eq("company_id", user.getCompanyId())).get(0);
|
|
project.setId(updateProject.getId());
|
|
project.setId(updateProject.getId());
|
|
projectMapper.updateById(project);
|
|
projectMapper.updateById(project);
|
|
@@ -2948,7 +2942,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
}
|
|
}
|
|
//导入项目参与人,遵守只增不减的原则, 避免误删
|
|
//导入项目参与人,遵守只增不减的原则, 避免误删
|
|
List<Participation> oldPartList = new ArrayList<>();
|
|
List<Participation> oldPartList = new ArrayList<>();
|
|
- if (!flag) {
|
|
|
|
|
|
+ if (exists) {
|
|
//更新的项目,检查已经存在的项目参与人
|
|
//更新的项目,检查已经存在的项目参与人
|
|
oldPartList = participationMapper.selectList(new QueryWrapper<Participation>().eq("project_id", project.getId()));
|
|
oldPartList = participationMapper.selectList(new QueryWrapper<Participation>().eq("project_id", project.getId()));
|
|
}
|
|
}
|
|
@@ -3008,16 +3002,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
operationRecord.setContent("导入了"+importCount+"条项目数据");
|
|
operationRecord.setContent("导入了"+importCount+"条项目数据");
|
|
operationRecordService.save(operationRecord);
|
|
operationRecordService.save(operationRecord);
|
|
}else if(fileName.endsWith(".xls")){
|
|
}else if(fileName.endsWith(".xls")){
|
|
- if(!fileName.endsWith(".xls")){
|
|
|
|
- msg.setError("文件格式错误,请使用’.xlsx’格式");
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
//然后解析表格
|
|
//然后解析表格
|
|
HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(file));
|
|
HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(file));
|
|
//我们只需要第一个sheet
|
|
//我们只需要第一个sheet
|
|
HSSFSheet sheet = workbook.getSheetAt(0);
|
|
HSSFSheet sheet = workbook.getSheetAt(0);
|
|
- //获取全部人员
|
|
|
|
- List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
|
|
|
|
|
|
+ //获取全部人员,仅在职人员
|
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()).eq("is_active", 1));
|
|
//获取全部供货商分类列表
|
|
//获取全部供货商分类列表
|
|
List<ProviderCategory> providerCategoryList = providerCategoryMapper.selectList(new QueryWrapper<ProviderCategory>().eq("company_id", user.getCompanyId()));
|
|
List<ProviderCategory> providerCategoryList = providerCategoryMapper.selectList(new QueryWrapper<ProviderCategory>().eq("company_id", user.getCompanyId()));
|
|
Company company = companyMapper.selectById(user.getCompanyId());
|
|
Company company = companyMapper.selectById(user.getCompanyId());
|
|
@@ -3256,7 +3246,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
throw new Exception("项目名称不能为空");
|
|
throw new Exception("项目名称不能为空");
|
|
}
|
|
}
|
|
Project project = new Project();
|
|
Project project = new Project();
|
|
- boolean flag=false;
|
|
|
|
|
|
+ boolean exists=false;
|
|
if (codeCell != null) {
|
|
if (codeCell != null) {
|
|
String code = codeCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
String code = codeCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
if (code.equals("项目编号") && rowIndex == 0) {
|
|
if (code.equals("项目编号") && rowIndex == 0) {
|
|
@@ -3289,7 +3279,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
// throw new Exception("项目编号存在重复: " + code);
|
|
// throw new Exception("项目编号存在重复: " + code);
|
|
existCodeList.add(code);
|
|
existCodeList.add(code);
|
|
//跳过编号重复的数据
|
|
//跳过编号重复的数据
|
|
- flag=true;
|
|
|
|
|
|
+ exists=true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
project.setProjectCode(code);
|
|
project.setProjectCode(code);
|
|
@@ -3486,7 +3476,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(flag){
|
|
|
|
|
|
+ if(exists){
|
|
Project updateProject = projectMapper.selectList(new QueryWrapper<Project>().eq("project_code", project.getProjectCode()).eq("company_id", user.getCompanyId())).get(0);
|
|
Project updateProject = projectMapper.selectList(new QueryWrapper<Project>().eq("project_code", project.getProjectCode()).eq("company_id", user.getCompanyId())).get(0);
|
|
project.setId(updateProject.getId());
|
|
project.setId(updateProject.getId());
|
|
projectMapper.updateById(project);
|
|
projectMapper.updateById(project);
|
|
@@ -3528,7 +3518,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
if (projectCategorySubCell != null && !StringUtils.isEmpty(projectCategorySubCell.getStringCellValue())) {
|
|
if (projectCategorySubCell != null && !StringUtils.isEmpty(projectCategorySubCell.getStringCellValue())) {
|
|
projectSeparate.setProjectCategorySub(projectCategorySubCell.getStringCellValue());
|
|
projectSeparate.setProjectCategorySub(projectCategorySubCell.getStringCellValue());
|
|
}
|
|
}
|
|
- if(flag&&check){
|
|
|
|
|
|
+ if(exists&&check){
|
|
projectSeparateMapper.updateById(projectSeparate);
|
|
projectSeparateMapper.updateById(projectSeparate);
|
|
List<ProjectKeyNodes> nodes = projectKeyNodesMapper.selectList(new QueryWrapper<ProjectKeyNodes>().eq("project_id", id));
|
|
List<ProjectKeyNodes> nodes = projectKeyNodesMapper.selectList(new QueryWrapper<ProjectKeyNodes>().eq("project_id", id));
|
|
for (int x = 0; x < projectKeyNodesSettingList.size(); x++) {
|
|
for (int x = 0; x < projectKeyNodesSettingList.size(); x++) {
|
|
@@ -3801,9 +3791,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
importCount++;
|
|
importCount++;
|
|
//导入项目参与人,遵守只增不减的原则, 避免误删
|
|
//导入项目参与人,遵守只增不减的原则, 避免误删
|
|
List<Participation> oldPartList = new ArrayList<>();
|
|
List<Participation> oldPartList = new ArrayList<>();
|
|
- if (!flag) {
|
|
|
|
|
|
+ if (exists) {
|
|
//更新的项目,检查已经存在的项目参与人
|
|
//更新的项目,检查已经存在的项目参与人
|
|
oldPartList = participationMapper.selectList(new QueryWrapper<Participation>().eq("project_id", project.getId()));
|
|
oldPartList = participationMapper.selectList(new QueryWrapper<Participation>().eq("project_id", project.getId()));
|
|
|
|
+ System.out.println("获取到已有项目参与人:"+oldPartList.size());
|
|
}
|
|
}
|
|
List<Participation> participationList = new ArrayList<>();
|
|
List<Participation> participationList = new ArrayList<>();
|
|
if(inchargerCell!=null){
|
|
if(inchargerCell!=null){
|
|
@@ -3933,7 +3924,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg exportData(HttpServletRequest request) {
|
|
public HttpRespMsg exportData(HttpServletRequest request) {
|
|
- LocalDateTime time=LocalDateTime.now();
|
|
|
|
String token = request.getHeader("TOKEN");
|
|
String token = request.getHeader("TOKEN");
|
|
User user = userMapper.selectById(token);
|
|
User user = userMapper.selectById(token);
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
|
|
@@ -3999,6 +3989,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
List<List<String>> allList = new ArrayList<List<String>>();
|
|
List<List<String>> allList = new ArrayList<List<String>>();
|
|
allList.add(headList);
|
|
allList.add(headList);
|
|
String[] levelArray = new String[]{"正常","紧急","重要","重要且紧急","低风险","中风险","高风险"};
|
|
String[] levelArray = new String[]{"正常","紧急","重要","重要且紧急","低风险","中风险","高风险"};
|
|
|
|
+ //获取项目级别数据
|
|
|
|
+ List<ProjectLevel> projectLevelList = projectLevelMapper.selectList(new QueryWrapper<ProjectLevel>().eq("company_id", user.getCompanyId()));
|
|
DateTimeFormatter sdf =DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
DateTimeFormatter sdf =DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
DecimalFormat df = new DecimalFormat("##0.0#");
|
|
DecimalFormat df = new DecimalFormat("##0.0#");
|
|
//获取项目子表 数据
|
|
//获取项目子表 数据
|
|
@@ -4063,11 +4055,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
rowData.add(projectVO.getCustomerName());
|
|
rowData.add(projectVO.getCustomerName());
|
|
}
|
|
}
|
|
if (company.getPackageProject() == 1) {
|
|
if (company.getPackageProject() == 1) {
|
|
- Integer level = projectVO.getLevel();
|
|
|
|
- if (level == null) {
|
|
|
|
- level = 1;
|
|
|
|
|
|
+ if(timeType.getProjectLevelState()==1){
|
|
|
|
+ Optional<ProjectLevel> first = projectLevelList.stream().filter(pl -> pl.getId().equals(projectVO.getLevel())).findFirst();
|
|
|
|
+ if(first.isPresent()){
|
|
|
|
+ rowData.add(first.get().getProjectLevelName());
|
|
|
|
+ }else rowData.add("");
|
|
|
|
+ }else {
|
|
|
|
+ Integer level = projectVO.getLevel();
|
|
|
|
+ if (level == null) {
|
|
|
|
+ level = 1;
|
|
|
|
+ }
|
|
|
|
+ rowData.add(levelArray[level-1]);
|
|
}
|
|
}
|
|
- rowData.add(levelArray[level-1]);
|
|
|
|
rowData.add(df.format((Double)projectVO.getContractAmount()));
|
|
rowData.add(df.format((Double)projectVO.getContractAmount()));
|
|
}
|
|
}
|
|
if(company.getId()==936){
|
|
if(company.getId()==936){
|
|
@@ -4119,9 +4118,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
}
|
|
}
|
|
allList.add(rowData);
|
|
allList.add(rowData);
|
|
}
|
|
}
|
|
- LocalDateTime time1=LocalDateTime.now();
|
|
|
|
- Duration between = Duration.between(time1, time);
|
|
|
|
- System.out.println("耗时"+between.toMillis()+"毫秒");
|
|
|
|
//生成excel文件导出
|
|
//生成excel文件导出
|
|
String fileName = "项目导出_"+company.getCompanyName()+System.currentTimeMillis();
|
|
String fileName = "项目导出_"+company.getCompanyName()+System.currentTimeMillis();
|
|
String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , allList, path);
|
|
String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , allList, path);
|
|
@@ -6284,6 +6280,30 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg removeDuplicateParticipators(Integer companyId, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().select("id").eq("company_id", companyId));
|
|
|
|
+ List<Integer> projectIds = projectList.stream().map(Project::getId).collect(Collectors.toList());
|
|
|
|
+ List<Participation> partList = participationMapper.selectList(new QueryWrapper<Participation>().in("project_id", projectIds));
|
|
|
|
+ //排重
|
|
|
|
+ List<Participation> oneList = new ArrayList<>();
|
|
|
|
+ List<Participation> duplicateList = new ArrayList<>();
|
|
|
|
+ partList.forEach(part->{
|
|
|
|
+ if (oneList.stream().anyMatch(one->one.getUserId().equals(part.getUserId())
|
|
|
|
+ && one.getProjectId().equals(part.getProjectId()))) {
|
|
|
|
+ duplicateList.add(part);
|
|
|
|
+ } else {
|
|
|
|
+ oneList.add(part);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if (duplicateList.size() > 0) {
|
|
|
|
+ participationService.removeByIds(duplicateList.stream().map(Participation::getId).collect(Collectors.toList()));
|
|
|
|
+ msg.data = duplicateList.size();
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
private List<Department> getSubDepts(Department dp, List<Department> list) {
|
|
private List<Department> getSubDepts(Department dp, List<Department> list) {
|
|
List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());
|
|
List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());
|