|
@@ -1,27 +1,35 @@
|
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.management.platform.entity.*;
|
|
|
-import com.management.platform.mapper.ProjectApprovalMapper;
|
|
|
-import com.management.platform.mapper.ProjectMapper;
|
|
|
-import com.management.platform.mapper.UserMapper;
|
|
|
+import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.management.platform.util.ExcelUtil;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
+import com.management.platform.util.MessageUtils;
|
|
|
+import org.apache.poi.ss.usermodel.CellType;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
+import sun.misc.Request;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.*;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -44,6 +52,30 @@ public class ProjectApprovalServiceImpl extends ServiceImpl<ProjectApprovalMappe
|
|
|
private SysFunctionService sysFunctionService;
|
|
|
@Resource
|
|
|
private ProjectApprovalCheckService projectApprovalCheckService;
|
|
|
+ @Resource
|
|
|
+ private WxCorpInfoService wxCorpInfoService;
|
|
|
+ @Resource
|
|
|
+ private TimeTypeMapper timeTypeMapper;
|
|
|
+ @Resource
|
|
|
+ private CompanyMapper companyMapper;
|
|
|
+ @Resource
|
|
|
+ private HttpServletRequest request;
|
|
|
+ @Resource
|
|
|
+ private ProjectCategoryMapper projectCategoryMapper;
|
|
|
+ @Resource
|
|
|
+ private ParticipationApprovalMapper participationApprovalMapper;
|
|
|
+ @Resource
|
|
|
+ private ParticipationApprovalService participationApprovalService;
|
|
|
+ @Resource
|
|
|
+ private ProjectApprovalAuditorMapper projectApprovalAuditorMapper;
|
|
|
+ @Resource
|
|
|
+ private ProjectApprovalAuditorService projectApprovalAuditorService;
|
|
|
+ @Resource
|
|
|
+ private ProjectMapper projectMapper;
|
|
|
+ @Resource
|
|
|
+ private ExcelExportService excelExportService;
|
|
|
+ @Value(value = "${upload.path}")
|
|
|
+ private String path;
|
|
|
|
|
|
|
|
|
|
|
@@ -101,26 +133,26 @@ public class ProjectApprovalServiceImpl extends ServiceImpl<ProjectApprovalMappe
|
|
|
if(optional.isPresent()){
|
|
|
r.setInchargerName(optional.get().getName());
|
|
|
}
|
|
|
- Integer canCheck=0;
|
|
|
+// Integer canCheck=0;
|
|
|
List<ProjectApprovalCheck> checkList = approvalCheckList.stream().filter(a -> a.getProjectApprovalId().equals(r.getId())).collect(Collectors.toList());
|
|
|
Optional<ProjectApprovalCheck> first = checkList.stream().filter(c -> c.getUserId().equals(user.getId())&&c.getStatus()==0).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- //针对当前登录人员 作为审核人检查是否有审核权限
|
|
|
- boolean anyMatch = checkList.stream().anyMatch(c -> c.getSeq() < first.get().getSeq() && c.getStatus() == 0);
|
|
|
- if(!anyMatch){
|
|
|
- canCheck=1;
|
|
|
- }
|
|
|
- }
|
|
|
+// if(first.isPresent()){
|
|
|
+// //针对当前登录人员 作为审核人检查是否有审核权限
|
|
|
+// boolean anyMatch = checkList.stream().anyMatch(c -> c.getSeq() < first.get().getSeq() && c.getStatus() == 0);
|
|
|
+// if(!anyMatch){
|
|
|
+// canCheck=1;
|
|
|
+// }
|
|
|
+// }
|
|
|
//有权限可编辑
|
|
|
- if(hasAllPriviledge||hasCheckPriviledge){
|
|
|
- canCheck=1;
|
|
|
- }
|
|
|
- //全部审核通过的情况不可编辑
|
|
|
- boolean b = checkList.stream().allMatch(c -> c.getStatus().equals(1));
|
|
|
- if(b){
|
|
|
- canCheck=0;
|
|
|
- }
|
|
|
- r.setCanChecked(canCheck);
|
|
|
+// if(hasAllPriviledge||hasCheckPriviledge){
|
|
|
+// canCheck=1;
|
|
|
+// }
|
|
|
+// //全部审核通过的情况不可编辑
|
|
|
+// boolean b = checkList.stream().allMatch(c -> c.getStatus().equals(1));
|
|
|
+// if(b){
|
|
|
+// canCheck=0;
|
|
|
+// }
|
|
|
+// r.setCanChecked(canCheck);
|
|
|
});
|
|
|
result.put("records",records);
|
|
|
result.put("total",iPage.getTotal());
|
|
@@ -130,6 +162,10 @@ public class ProjectApprovalServiceImpl extends ServiceImpl<ProjectApprovalMappe
|
|
|
|
|
|
@Override
|
|
|
public HttpRespMsg importData(MultipartFile multipartFile) {
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, user.getCompanyId()));
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
|
String fileName = multipartFile.getOriginalFilename();
|
|
|
File file = new File(fileName == null ? "file" : fileName);
|
|
|
InputStream inputStream = null;
|
|
@@ -148,9 +184,24 @@ public class ProjectApprovalServiceImpl extends ServiceImpl<ProjectApprovalMappe
|
|
|
outputStream.close();
|
|
|
//然后解析表格
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook(file);
|
|
|
+ //我们只需要第一个sheet
|
|
|
XSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
+ //获取全部人员
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()).eq("is_active", 1));
|
|
|
+ Company company = companyMapper.selectById(user.getCompanyId());
|
|
|
+ List<Project> projectList = new ArrayList<Project>();
|
|
|
//由于第一行需要指明列对应的标题
|
|
|
int rowNum = sheet.getLastRowNum();
|
|
|
+ HashMap<String, Integer> projectLevelMap = new HashMap<>();
|
|
|
+ projectLevelMap.put(MessageUtils.message("excel.normal"), 1);
|
|
|
+ projectLevelMap.put(MessageUtils.message("excel.urgent"), 2);
|
|
|
+ projectLevelMap.put(MessageUtils.message("excel.important"), 3);
|
|
|
+ projectLevelMap.put(MessageUtils.message("excel.impAndUrg"), 4);
|
|
|
+ projectLevelMap.put(MessageUtils.message("excel.lowRisk"), 5);
|
|
|
+ projectLevelMap.put(MessageUtils.message("excel.MedRisk"), 6);
|
|
|
+ projectLevelMap.put(MessageUtils.message("excel.highRisk"), 7);
|
|
|
+ List<String> existCodeList = new ArrayList<>();
|
|
|
+ List<String> userNameList=new ArrayList<>();
|
|
|
for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
|
|
|
XSSFRow row = sheet.getRow(rowIndex);
|
|
|
if (row == null) {
|
|
@@ -160,10 +211,447 @@ public class ProjectApprovalServiceImpl extends ServiceImpl<ProjectApprovalMappe
|
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
|
continue;
|
|
|
}
|
|
|
+ XSSFCell participatorCell = row.getCell(6);
|
|
|
+ XSSFCell inchargerCell = row.getCell(7);
|
|
|
+
|
|
|
+ String part = "";
|
|
|
+ String inchargerName = "";
|
|
|
+ if (participatorCell!=null) {
|
|
|
+ participatorCell.setCellType(CellType.STRING);
|
|
|
+ part = participatorCell.getStringCellValue().trim();
|
|
|
+ }
|
|
|
+ if (inchargerCell != null) {
|
|
|
+ inchargerCell.setCellType(CellType.STRING);
|
|
|
+ inchargerName = inchargerCell.getStringCellValue().trim();
|
|
|
+ }
|
|
|
+ //兼容繁体
|
|
|
+ if(part.equals("参与人") || part.equals("參與人")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String[] partSplit = part.split("\\,|\\,");
|
|
|
+ for (String s : partSplit) {
|
|
|
+ if(!userNameList.contains(s)&&!s.equals("")){
|
|
|
+ userNameList.add(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!userNameList.contains(inchargerName)&&!inchargerName.equals("")){
|
|
|
+ userNameList.add(inchargerName);
|
|
|
+ }
|
|
|
}
|
|
|
+ HttpRespMsg respMsg=new HttpRespMsg();
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
|
|
|
+ System.out.println("参与搜素的人员列表"+userNameList + userNameList.size());
|
|
|
+ respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
|
|
|
+ if(respMsg.code.equals("0")){
|
|
|
+ msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请使用工号!");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<User> targetUserList= (List<User>) respMsg.data;
|
|
|
+ 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 categoryCell = row.getCell(1);
|
|
|
+ XSSFCell isPublicCell = row.getCell(2);
|
|
|
+ XSSFCell nameCell = row.getCell(3);
|
|
|
+ XSSFCell descCell = row.getCell(4);
|
|
|
+ XSSFCell participatorCell = row.getCell(5);
|
|
|
+ XSSFCell inchargerCell = row.getCell(6);
|
|
|
+ XSSFCell reportAuditorsCell=null;
|
|
|
+ XSSFCell reportCcCell=null;
|
|
|
+ int i=0;
|
|
|
+ if(timeType.getReportAuditType()==0||timeType.getReportAuditType()==4||timeType.getReportAuditType()==6){
|
|
|
+ i++;
|
|
|
+ reportAuditorsCell = row.getCell(6+i);
|
|
|
+ }
|
|
|
+ if(timeType.getReportAuditType()==6){
|
|
|
+ i++;
|
|
|
+ reportCcCell=row.getCell(6+i);
|
|
|
+ }
|
|
|
+ XSSFCell levelCell = row.getCell(7+i);
|
|
|
+ XSSFCell startDateCell = row.getCell(8+i);
|
|
|
+ XSSFCell endDateCell = row.getCell(9+i);
|
|
|
+ XSSFCell amountCell = row.getCell(10+i);
|
|
|
+
|
|
|
+
|
|
|
+ if (codeCell != null)codeCell.setCellType(CellType.STRING);
|
|
|
+ if (nameCell != null)nameCell.setCellType(CellType.STRING);
|
|
|
+ if (categoryCell != null)categoryCell.setCellType(CellType.STRING);
|
|
|
+ if (isPublicCell != null)isPublicCell.setCellType(CellType.STRING);
|
|
|
+ if (descCell != null)descCell.setCellType(CellType.STRING);
|
|
|
+ if (participatorCell != null)participatorCell.setCellType(CellType.STRING);
|
|
|
+ if (inchargerCell != null)inchargerCell.setCellType(CellType.STRING);
|
|
|
+ if (reportAuditorsCell != null)reportAuditorsCell.setCellType(CellType.STRING);
|
|
|
+ if (reportCcCell != null)reportCcCell.setCellType(CellType.STRING);
|
|
|
+ if (levelCell != null)levelCell.setCellType(CellType.STRING);
|
|
|
+ if (startDateCell != null)startDateCell.setCellType(CellType.NUMERIC);
|
|
|
+ if (endDateCell != null)endDateCell.setCellType(CellType.NUMERIC);
|
|
|
+ if (amountCell != null)amountCell.setCellType(CellType.STRING);
|
|
|
+ if (descCell != null)descCell.setCellType(CellType.STRING);
|
|
|
+ if (nameCell == null) {//项目名称为空的直接跳过
|
|
|
+ throw new Exception("项目名称不能为空");
|
|
|
+ }
|
|
|
+ ProjectApproval project = new ProjectApproval();
|
|
|
+ boolean exists=false;
|
|
|
+ if (codeCell != null) {
|
|
|
+ String code = codeCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
|
+ if ((code.equals("项目编号") || code.equals("項目編號") || code.equals("project No")) && 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) {
|
|
|
+// throw new Exception("项目编号存在重复: " + code);
|
|
|
+ existCodeList.add(code);
|
|
|
+ //跳过编号重复的数据
|
|
|
+ exists=true;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ project.setProjectCode(code);
|
|
|
+ }
|
|
|
+ //检查项目分类是否存在
|
|
|
+ List<ProjectCategory> projectCategoryList = projectCategoryMapper.selectList(new QueryWrapper<ProjectCategory>().eq("company_id", user.getCompanyId()));
|
|
|
+ if (categoryCell != null && !StringUtils.isEmpty(categoryCell.getStringCellValue())) {
|
|
|
+ Optional<ProjectCategory> category = projectCategoryList.stream().filter(pc -> pc.getName().equals(categoryCell.getStringCellValue())).findFirst();
|
|
|
+ if(!category.isPresent()){
|
|
|
+ throw new Exception("项目分类["+categoryCell.getStringCellValue()+"]不存在");
|
|
|
+ }
|
|
|
+ project.setCategory(category.get().getId());
|
|
|
+ project.setCategoryName(categoryCell.getStringCellValue());
|
|
|
+ }
|
|
|
+ String name = nameCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
|
+ project.setCompanyId(user.getCompanyId());
|
|
|
+ project.setCreatorId(user.getId());
|
|
|
+ project.setCreatorName(user.getName());
|
|
|
+ project.setProjectName(name);
|
|
|
+ project.setCreateDate(LocalDate.now());
|
|
|
+ //处理人员
|
|
|
+ if (inchargerCell != null) {
|
|
|
+ String inchargerName = inchargerCell.getStringCellValue().trim();
|
|
|
+ if (!StringUtils.isEmpty(inchargerName)) {
|
|
|
+ String s1;
|
|
|
+ if(inchargerName.startsWith("/")){
|
|
|
+ s1=inchargerName.substring(1,inchargerName.length());
|
|
|
+ }else s1=inchargerName;
|
|
|
+ String s2;
|
|
|
+ if(s1.endsWith("/")){
|
|
|
+ s2=s1.substring(0,s1.length()-1);
|
|
|
+ }else s2=s1;
|
|
|
+ String[] split = s2.split("/");
|
|
|
+ Optional<User> first;
|
|
|
+ Integer exception=null;
|
|
|
+ if(split.length==1){
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(split[0])).findFirst();
|
|
|
+ first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
|
|
|
+ }else {
|
|
|
+ first= userList.stream().filter(u -> u.getName().equals(split[0])||(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();
|
|
|
+ }
|
|
|
+ exception=0;
|
|
|
+ }else {
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(split[1])).findFirst();
|
|
|
+ first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
|
|
|
+ exception=1;
|
|
|
+ }else {
|
|
|
+ first= userList.stream().filter(u -> u.getName().equals(split[1])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (first.isPresent()) {
|
|
|
+ project.setInchargerId(first.get().getId());
|
|
|
+ project.setInchargerName(first.get().getName());
|
|
|
+ } else {
|
|
|
+ switch (exception){
|
|
|
+ case 0:throw new Exception("["+split[0]+"]在系统中不存在");
|
|
|
+ case 1:throw new Exception("["+split[1]+"]在系统中不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (levelCell != null) {
|
|
|
+ String levelStr = levelCell.getStringCellValue();
|
|
|
+ if (!StringUtils.isEmpty(levelStr)) {
|
|
|
+ project.setLevel(projectLevelMap.get(levelStr));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ if (startDateCell !=null && !StringUtils.isEmpty(startDateCell.getDateCellValue())) {
|
|
|
+ project.setPlanStartDate(LocalDate.parse(sdf.format(startDateCell.getDateCellValue()), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
|
+ }
|
|
|
+ if (endDateCell !=null && !StringUtils.isEmpty(endDateCell.getDateCellValue())) {
|
|
|
+ project.setPlanEndDate(LocalDate.parse(sdf.format(endDateCell.getDateCellValue()), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
|
+ }
|
|
|
+ if (amountCell !=null && !StringUtils.isEmpty(amountCell.getStringCellValue())) {
|
|
|
+ project.setContractAmount(Double.parseDouble(amountCell.getStringCellValue()));
|
|
|
+ }
|
|
|
+ if(descCell!=null&&!StringUtils.isEmpty(descCell.getStringCellValue())){
|
|
|
+ project.setProjectDesc(descCell.getStringCellValue());
|
|
|
+ }
|
|
|
+ if (isPublicCell != null && !StringUtils.isEmpty(isPublicCell.getStringCellValue())) {
|
|
|
+ project.setIsPublic(MessageUtils.message("excel.yes").equals(isPublicCell.getStringCellValue())?1:0);
|
|
|
+ }
|
|
|
+ if(exists){
|
|
|
+ ProjectApproval updateProject = projectApprovalMapper.selectList(new QueryWrapper<ProjectApproval>().eq("project_code", project.getProjectCode()).eq("company_id", user.getCompanyId())).get(0);
|
|
|
+ project.setId(updateProject.getId());
|
|
|
+ projectApprovalMapper.updateById(project);
|
|
|
+ }else {
|
|
|
+ projectApprovalMapper.insert(project);
|
|
|
+ }
|
|
|
+ importCount++;
|
|
|
+ //导入项目参与人,遵守只增不减的原则, 避免误删
|
|
|
+ List<ParticipationApproval> oldPartList = new ArrayList<>();
|
|
|
+ List<ProjectApprovalAuditor> oldAuditorList = new ArrayList<>();
|
|
|
+ if (exists) {
|
|
|
+ //更新的项目,检查已经存在的项目参与人
|
|
|
+ oldPartList = participationApprovalMapper.selectList(new QueryWrapper<ParticipationApproval>().eq("project_id", project.getId()));
|
|
|
+ oldAuditorList = projectApprovalAuditorMapper.selectList(new QueryWrapper<ProjectApprovalAuditor>().eq("project_id", project.getId()));
|
|
|
+ }
|
|
|
+ List<ParticipationApproval> participationList = new ArrayList<>();
|
|
|
+ if(inchargerCell!=null){
|
|
|
+ String value = inchargerCell.getStringCellValue().trim();
|
|
|
+ if (!StringUtils.isEmpty(value)) {
|
|
|
+ //有项目经理
|
|
|
+ String s1;
|
|
|
+ if(value.startsWith("/")){
|
|
|
+ s1=value.substring(1,value.length());
|
|
|
+ }else {
|
|
|
+ s1=value;
|
|
|
+ }
|
|
|
+ String s2;
|
|
|
+ if(s1.endsWith("/")){
|
|
|
+ s2=s1.substring(0,s1.length()-1);
|
|
|
+ }else {
|
|
|
+ s2=s1;
|
|
|
+ }
|
|
|
+ String[] split = s2.split("/");
|
|
|
+ Optional<User> first;
|
|
|
+ Integer exception=null;
|
|
|
+ if(split.length==1){
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(split[0])).findFirst();
|
|
|
+ first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
|
|
|
+ }else {
|
|
|
+ first= userList.stream().filter(u -> u.getName().equals(split[0])||(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();
|
|
|
+ }
|
|
|
+ exception=0;
|
|
|
+ }else {
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(split[1])).findFirst();
|
|
|
+ first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
|
|
|
+ exception=1;
|
|
|
+ }else {
|
|
|
+ first= userList.stream().filter(u -> u.getName().equals(split[1])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ParticipationApproval p = new ParticipationApproval();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ p.setUserId(first.get().getId());
|
|
|
+ p.setProjectApprovalId(project.getId());
|
|
|
+ participationList.add(p);
|
|
|
+ } else {
|
|
|
+ switch (exception){
|
|
|
+ case 0:throw new Exception("["+split[0]+"]在系统中不存在");
|
|
|
+ case 1:throw new Exception("["+split[1]+"]在系统中不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (participatorCell != null) {
|
|
|
+ String part = participatorCell.getStringCellValue().trim();
|
|
|
+ if (!StringUtils.isEmpty(part)) {
|
|
|
+ String[] partSplit = part.split("\\,|\\,");
|
|
|
+ for (String str : partSplit) {
|
|
|
+ ParticipationApproval p = new ParticipationApproval();
|
|
|
+ String s1;
|
|
|
+ if(str.startsWith("/")){
|
|
|
+ s1=str.substring(1,str.length());
|
|
|
+ }else s1=str;
|
|
|
+ String s2;
|
|
|
+ if(s1.endsWith("/")){
|
|
|
+ s2=s1.substring(0,s1.length()-1);
|
|
|
+ }else s2=s1;
|
|
|
+ String[] split = str.split("/");
|
|
|
+ Optional<User> first;
|
|
|
+ Integer exception=null;
|
|
|
+ if(split.length==1){
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(split[0])).findFirst();
|
|
|
+ first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
|
|
|
+ }else {
|
|
|
+ first= userList.stream().filter(u -> u.getName().equals(split[0])||(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();
|
|
|
+ }
|
|
|
+ exception=0;
|
|
|
+ }else {
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(split[1])).findFirst();
|
|
|
+ first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
|
|
|
+ exception=1;
|
|
|
+ }else {
|
|
|
+ first= userList.stream().filter(u -> u.getName().equals(split[1])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (first.isPresent()) {
|
|
|
+ User partMemb = first.get();
|
|
|
+// System.out.println("参与人:"+partMemb.getName());
|
|
|
+ if (!participationList.stream().anyMatch(partOne->partOne.getUserId().equals(partMemb.getId()))) {
|
|
|
+ p.setUserId(partMemb.getId());
|
|
|
+ p.setProjectApprovalId(project.getId());
|
|
|
+ participationList.add(p);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ switch (exception){
|
|
|
+ case 0:throw new Exception("["+split[0]+"]在系统中不存在");
|
|
|
+ case 1:throw new Exception("["+split[1]+"]在系统中不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (participationList.size() > 0) {
|
|
|
+ //批量保存
|
|
|
+ List<ParticipationApproval> finalOldPartList = oldPartList;
|
|
|
+ List<ParticipationApproval> addPartList = participationList.stream().filter(newP-> !finalOldPartList.stream().anyMatch(oldP->oldP.getUserId().equals(newP.getUserId()))).collect(Collectors.toList());
|
|
|
+ if (addPartList.size() > 0) {
|
|
|
+ participationApprovalService.saveBatch(addPartList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<ProjectApprovalAuditor> projectAuditorList = new ArrayList<>();
|
|
|
+ if (reportAuditorsCell != null) {
|
|
|
+ String part = reportAuditorsCell.getStringCellValue().trim();
|
|
|
+ if (!StringUtils.isEmpty(part)) {
|
|
|
+ String[] partSplit = part.split("\\,|\\,");
|
|
|
+ for (String str : partSplit) {
|
|
|
+ if(str.equals(inchargerCell.getStringCellValue())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ProjectApprovalAuditor projectAuditor = new ProjectApprovalAuditor();
|
|
|
+ String s1;
|
|
|
+ if(str.startsWith("/")){
|
|
|
+ s1=str.substring(1,str.length());
|
|
|
+ }else s1=str;
|
|
|
+ String s2;
|
|
|
+ if(s1.endsWith("/")){
|
|
|
+ s2=s1.substring(0,s1.length()-1);
|
|
|
+ }else s2=s1;
|
|
|
+ String[] split = str.split("/");
|
|
|
+ Optional<User> first;
|
|
|
+ Integer exception=null;
|
|
|
+ if(split.length==1){
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(split[0])).findFirst();
|
|
|
+ first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
|
|
|
+ }else {
|
|
|
+ first= userList.stream().filter(u -> u.getName().equals(split[0])||(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();
|
|
|
+ }
|
|
|
+ exception=0;
|
|
|
+ }else {
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(split[1])).findFirst();
|
|
|
+ first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
|
|
|
+ exception=1;
|
|
|
+ }else {
|
|
|
+ first= userList.stream().filter(u -> u.getName().equals(split[1])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (first.isPresent()) {
|
|
|
+ User partMemb = first.get();
|
|
|
+// System.out.println("参与人:"+partMemb.getName());
|
|
|
+ if (!projectAuditorList.stream().anyMatch(partOne->partOne.getAuditorId().equals(partMemb.getId()))) {
|
|
|
+ projectAuditor.setAuditorId(partMemb.getId());
|
|
|
+ projectAuditor.setAuditorName(partMemb.getName());
|
|
|
+ projectAuditor.setProjectApprovalId(project.getId());
|
|
|
+ projectAuditorList.add(projectAuditor);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ switch (exception){
|
|
|
+ case 0:throw new Exception("["+split[0]+"]在系统中不存在");
|
|
|
+ case 1:throw new Exception("["+split[1]+"]在系统中不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ProjectApprovalAuditor projectAuditor=new ProjectApprovalAuditor();
|
|
|
+ projectAuditor.setAuditorId(project.getInchargerId());
|
|
|
+ projectAuditor.setAuditorName(project.getInchargerName());
|
|
|
+ projectAuditor.setProjectApprovalId(project.getId());
|
|
|
+ projectApprovalAuditorMapper.insert(projectAuditor);
|
|
|
+ }
|
|
|
+ if (projectAuditorList.size() > 0) {
|
|
|
+ //批量保存
|
|
|
+ List<ProjectApprovalAuditor> finalOldAuditorList = oldAuditorList;
|
|
|
+ List<ProjectApprovalAuditor> addAuditorList = projectAuditorList.stream().filter(newP-> !finalOldAuditorList.stream().anyMatch(oldP->oldP.getAuditorId().equals(newP.getAuditorId()))).collect(Collectors.toList());
|
|
|
+ if (addAuditorList.size() > 0) {
|
|
|
+ projectApprovalAuditorService.saveBatch(addAuditorList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //msg.data = "成功导入"+importCount+"条数据。";
|
|
|
+ msg.data = MessageUtils.message("data.importSucRow",importCount);
|
|
|
+ if (existCodeList.size() > 0) {
|
|
|
+ String collect = existCodeList.stream().collect(Collectors.joining(","));
|
|
|
+ msg.data += MessageUtils.message("data.upSkip",existCodeList.size(),collect);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg exportData(String keyword, Integer searchField, String statuses, Integer category, Integer viewId) {
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
+ List<String> titleList=new ArrayList<>();
|
|
|
+ String[] arr=new String[]{"正常","紧急","重要","重要且紧急","低风险","中风险","高风险"};
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, companyId));
|
|
|
+ titleList.add("项目编号");
|
|
|
+ titleList.add("项目名称");
|
|
|
+ titleList.add("项目分类");
|
|
|
+ titleList.add("项目类型");
|
|
|
+ titleList.add("项目经理");
|
|
|
+ titleList.add("级别");
|
|
|
+ titleList.add("审核状态");
|
|
|
+ List<List<String>> dataList=new ArrayList<>();
|
|
|
+ dataList.add(titleList);
|
|
|
+ HttpRespMsg respMsg = listByPage(-1, -1, keyword, searchField, statuses, category, viewId, request);
|
|
|
+ Map<String, Object> msgData = (Map<String, Object>) respMsg.getData();
|
|
|
+ List<ProjectApproval> records = (List<ProjectApproval>) msgData.get("records");
|
|
|
+ for (ProjectApproval record : records) {
|
|
|
+ List<String> item=new ArrayList<>();
|
|
|
+ item.add(record.getProjectCode()==null?"":record.getProjectCode());
|
|
|
+ item.add(record.getProjectName());
|
|
|
+ item.add(record.getCategoryName());
|
|
|
+ item.add(record.getIsPublic()==0?"正式项目":"非项目");
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ item.add("$userName="+(record.getInchargerName()==null?"":record.getInchargerName())+"$");
|
|
|
+ }else {
|
|
|
+ item.add(record.getInchargerName()==null?"":record.getInchargerName());
|
|
|
+ }
|
|
|
+ item.add(arr[record.getLevel()-1]);
|
|
|
+ item.add(record.getStatus()==0?"待审核":record.getStatus()==1?"已通过":"已驳回");
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+ String title="立项导出_"+System.currentTimeMillis();
|
|
|
+ try {
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,title,dataList,path);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return null;
|
|
|
+ return msg;
|
|
|
}
|
|
|
}
|