|
@@ -9,6 +9,8 @@ import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.ReportLogDetailService;
|
|
|
import com.management.platform.service.ReportLogService;
|
|
|
import com.management.platform.service.ReportService;
|
|
|
+import com.management.platform.service.WxCorpInfoService;
|
|
|
+import com.management.platform.service.impl.WxCorpInfoServiceImpl;
|
|
|
import com.management.platform.util.ExcelUtil;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
@@ -36,6 +38,8 @@ import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -70,6 +74,8 @@ public class ReportLogController {
|
|
|
private ReportService reportService;
|
|
|
@Resource
|
|
|
private ReportLogDetailService reportLogDetailService;
|
|
|
+ @Resource
|
|
|
+ private WxCorpInfoService wxCorpInfoService;
|
|
|
|
|
|
@RequestMapping("/get")
|
|
|
public HttpRespMsg get(String creatorId, String createDate) {
|
|
@@ -183,6 +189,9 @@ public class ReportLogController {
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
//然后处理文件
|
|
|
String fileName = multipartFile.getOriginalFilename();
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, companyId));
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
File file = new File(fileName == null ? "file" : fileName);
|
|
|
InputStream inputStream = null;
|
|
@@ -225,154 +234,164 @@ public class ReportLogController {
|
|
|
Integer numCellValue = Integer.valueOf(numCell.getStringCellValue());
|
|
|
reportLogIds.add(numCellValue);
|
|
|
}
|
|
|
- List<ReportLog> reportLogList = reportLogService.list(new LambdaQueryWrapper<ReportLog>().in(ReportLog::getId, reportLogIds));
|
|
|
- List<String> reportIds = reportLogList.stream().map(ReportLog::getReportIds).collect(Collectors.toList());
|
|
|
- List<Integer> reportIdList =new ArrayList<>();
|
|
|
- reportIds.forEach(r->{
|
|
|
- String[] split = r.split(",");
|
|
|
- List<Integer> reportSubIds = Arrays.asList(split).stream().map(s -> Integer.valueOf(s)).collect(Collectors.toList());
|
|
|
- reportIdList.addAll(reportSubIds);
|
|
|
- });
|
|
|
- List<Report> reportList = reportMapper.selectList(new LambdaQueryWrapper<Report>().in(Report::getId, reportIdList));
|
|
|
- StringBuilder sb=new StringBuilder();
|
|
|
- List<Report> needUpdateReportList=new ArrayList<>();
|
|
|
- List<ReportLog> needUpdateReportLogList=new ArrayList<>();
|
|
|
- List<ReportLogDetail> needUpdateReportLogDetailList=new ArrayList<>();
|
|
|
- for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
|
|
|
- XSSFRow row = sheet.getRow(rowIndex);
|
|
|
- if (row == null) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- //跳过空行
|
|
|
- if (ExcelUtil.isRowEmpty(row)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- XSSFCell numCell = row.getCell(0);
|
|
|
- XSSFCell nameCell = row.getCell(1);
|
|
|
- XSSFCell jobNumCell = row.getCell(2);
|
|
|
- XSSFCell createDateCell = row.getCell(3);
|
|
|
- XSSFCell createTimeCell = row.getCell(4);
|
|
|
- XSSFCell projectNameCell = row.getCell(5);
|
|
|
- XSSFCell projectCodeCell = row.getCell(6);
|
|
|
- XSSFCell auditDateCell = row.getCell(7);
|
|
|
+ ExecutorService executor = Executors.newFixedThreadPool(1);
|
|
|
+ executor.execute(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ List<ReportLog> reportLogList = reportLogService.list(new LambdaQueryWrapper<ReportLog>().select(ReportLog::getReportIds,ReportLog::getId,ReportLog::getMsg).in(ReportLog::getId, reportLogIds));
|
|
|
+ List<String> reportIds = reportLogList.stream().map(ReportLog::getReportIds).collect(Collectors.toList());
|
|
|
+ List<Integer> reportIdList =new ArrayList<>();
|
|
|
+ reportIds.forEach(r->{
|
|
|
+ String[] split = r.split(",");
|
|
|
+ List<Integer> reportSubIds = Arrays.asList(split).stream().map(s -> Integer.valueOf(s)).collect(Collectors.toList());
|
|
|
+ reportIdList.addAll(reportSubIds);
|
|
|
+ });
|
|
|
+ List<Report> reportList = reportMapper.selectList(new LambdaQueryWrapper<Report>().in(Report::getId, reportIdList));
|
|
|
+ List<ReportLogDetail> allReportLogDetails = reportLogDetailService.list(new LambdaQueryWrapper<ReportLogDetail>().select(ReportLogDetail::getMsg,ReportLogDetail::getId).in(ReportLogDetail::getReportId, reportIdList));
|
|
|
+ StringBuilder sb=new StringBuilder();
|
|
|
+ List<Report> needUpdateReportList=new ArrayList<>();
|
|
|
+ List<ReportLog> needUpdateReportLogList=new ArrayList<>();
|
|
|
+ List<ReportLogDetail> needUpdateReportLogDetailList=new ArrayList<>();
|
|
|
+ for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
|
|
|
+ XSSFRow row = sheet.getRow(rowIndex);
|
|
|
+ if (row == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //跳过空行
|
|
|
+ if (ExcelUtil.isRowEmpty(row)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ XSSFCell numCell = row.getCell(0);
|
|
|
+ XSSFCell nameCell = row.getCell(1);
|
|
|
+ XSSFCell jobNumCell = row.getCell(2);
|
|
|
+ XSSFCell createDateCell = row.getCell(3);
|
|
|
+ XSSFCell createTimeCell = row.getCell(4);
|
|
|
+ XSSFCell projectNameCell = row.getCell(5);
|
|
|
+ XSSFCell projectCodeCell = row.getCell(6);
|
|
|
+ XSSFCell auditDateCell = row.getCell(7);
|
|
|
|
|
|
- if (numCell != null) {
|
|
|
- String code = numCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
|
- if ((code.equals("编号(不可随意修改)")||(code.equals("编号(不可随意修改)")) && rowIndex == 0)){
|
|
|
- //跳过第一行标题
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (numCell != null) {
|
|
|
+ String code = numCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
|
+ if ((code.equals("编号(不可随意修改)")||(code.equals("编号(不可随意修改)")) && rowIndex == 0)){
|
|
|
+ //跳过第一行标题
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (numCell != null)numCell.setCellType(CellType.STRING);
|
|
|
- if (nameCell != null)nameCell.setCellType(CellType.STRING);
|
|
|
- if (jobNumCell != null)jobNumCell.setCellType(CellType.STRING);
|
|
|
- if (createDateCell != null)createDateCell.setCellType(CellType.STRING);
|
|
|
- if (createTimeCell != null)createTimeCell.setCellType(CellType.STRING);
|
|
|
- if (projectNameCell != null)projectNameCell.setCellType(CellType.STRING);
|
|
|
- if (projectCodeCell != null)projectCodeCell.setCellType(CellType.STRING);
|
|
|
- if (auditDateCell != null)auditDateCell.setCellType(CellType.STRING);
|
|
|
+ if (numCell != null)numCell.setCellType(CellType.STRING);
|
|
|
+ if (nameCell != null)nameCell.setCellType(CellType.STRING);
|
|
|
+ if (jobNumCell != null)jobNumCell.setCellType(CellType.STRING);
|
|
|
+ if (createDateCell != null)createDateCell.setCellType(CellType.STRING);
|
|
|
+ if (createTimeCell != null)createTimeCell.setCellType(CellType.STRING);
|
|
|
+ if (projectNameCell != null)projectNameCell.setCellType(CellType.STRING);
|
|
|
+ if (projectCodeCell != null)projectCodeCell.setCellType(CellType.STRING);
|
|
|
+ if (auditDateCell != null)auditDateCell.setCellType(CellType.STRING);
|
|
|
|
|
|
- Integer numCellValue = Integer.valueOf(numCell.getStringCellValue());
|
|
|
- String nameCellValue = nameCell.getStringCellValue();
|
|
|
- String jobNumCellValue =jobNumCell.getStringCellValue();
|
|
|
- String createDateCellValue = createDateCell.getStringCellValue();
|
|
|
- String createTimeCellValue = createTimeCell.getStringCellValue();
|
|
|
- String projectNameCellValue = projectNameCell.getStringCellValue();
|
|
|
- String projectCodeCellValue = projectCodeCell.getStringCellValue();
|
|
|
- String auditDateCellValue = auditDateCell.getStringCellValue();
|
|
|
+ Integer numCellValue = Integer.valueOf(numCell.getStringCellValue());
|
|
|
+ String nameCellValue = nameCell.getStringCellValue();
|
|
|
+ String jobNumCellValue =jobNumCell.getStringCellValue();
|
|
|
+ String createDateCellValue = createDateCell.getStringCellValue();
|
|
|
+ String createTimeCellValue = createTimeCell.getStringCellValue();
|
|
|
+ String projectNameCellValue = projectNameCell.getStringCellValue();
|
|
|
+ String projectCodeCellValue = projectCodeCell.getStringCellValue();
|
|
|
+ String auditDateCellValue = auditDateCell.getStringCellValue();
|
|
|
|
|
|
|
|
|
- Optional<ReportLog> first = reportLogList.stream().filter(r -> r.getId().equals(numCellValue)).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- ReportLog reportLog = first.get();
|
|
|
- String reportIdSplit = reportLog.getReportIds();
|
|
|
- List<Integer> ids = Arrays.asList(reportIdSplit.split(",")).stream().map(s -> Integer.valueOf(s)).collect(Collectors.toList());
|
|
|
- List<Report> reports = reportList.stream().filter(r -> ids.contains(r.getId())).collect(Collectors.toList());
|
|
|
- LocalDateTime auditDateTime = null;
|
|
|
- LocalDateTime createTimeTime = null;
|
|
|
- if(auditDateCellValue!=null&&!StringUtils.isEmpty(auditDateCellValue)){
|
|
|
- try {
|
|
|
- auditDateTime = LocalDateTime.parse(auditDateCellValue, df);
|
|
|
- }catch (Exception e){
|
|
|
- msg.setError("第"+row+"行审核时间格式错误,请检查审核时间数据");
|
|
|
- return msg;
|
|
|
- }
|
|
|
- String creatorId = reports.get(0).getCreatorId();
|
|
|
- if(reportLog.getMsg().contains("审核通过了")){
|
|
|
- reportLog.setOperateDate(auditDateTime);
|
|
|
- needUpdateReportLogList.add(reportLog);
|
|
|
- }
|
|
|
- LocalDateTime finalAuditDateTime = auditDateTime;
|
|
|
- reports.forEach(r->{
|
|
|
- r.setProjectAuditTime(finalAuditDateTime);
|
|
|
- });
|
|
|
- List<Integer> details = reports.stream().map(Report::getId).distinct().collect(Collectors.toList());
|
|
|
- List<ReportLogDetail> reportLogDetails = reportLogDetailService.list(new LambdaQueryWrapper<ReportLogDetail>().in(ReportLogDetail::getReportId, details));
|
|
|
- reportLogDetails.forEach(r->{
|
|
|
+ Optional<ReportLog> first = reportLogList.stream().filter(r -> r.getId().equals(numCellValue)).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ ReportLog reportLog = first.get();
|
|
|
+ String reportIdSplit = reportLog.getReportIds();
|
|
|
+ List<Integer> ids = Arrays.asList(reportIdSplit.split(",")).stream().map(s -> Integer.valueOf(s)).collect(Collectors.toList());
|
|
|
+ List<Report> reports = reportList.stream().filter(r -> ids.contains(r.getId())).collect(Collectors.toList());
|
|
|
+ LocalDateTime auditDateTime = null;
|
|
|
+ LocalDateTime createTimeTime = null;
|
|
|
+ if(auditDateCellValue!=null&&!StringUtils.isEmpty(auditDateCellValue)){
|
|
|
+ try {
|
|
|
+ auditDateTime = LocalDateTime.parse(auditDateCellValue, df);
|
|
|
+ }catch (Exception e){
|
|
|
+ new Exception("第"+row+"行审核时间格式错误,请检查审核时间数据");
|
|
|
+ }
|
|
|
+ String creatorId = reports.get(0).getCreatorId();
|
|
|
+ if(reportLog.getMsg().contains("审核通过了")){
|
|
|
+ reportLog.setOperateDate(auditDateTime);
|
|
|
+ needUpdateReportLogList.add(reportLog);
|
|
|
+ }
|
|
|
+ LocalDateTime finalAuditDateTime = auditDateTime;
|
|
|
+ reports.forEach(r->{
|
|
|
+ r.setProjectAuditTime(finalAuditDateTime);
|
|
|
+ });
|
|
|
+ List<Integer> details = reports.stream().map(Report::getId).distinct().collect(Collectors.toList());
|
|
|
+ List<ReportLogDetail> reportLogDetails = allReportLogDetails.stream().filter(a -> details.contains(a.getReportId())).collect(Collectors.toList());
|
|
|
+ reportLogDetails.forEach(r->{
|
|
|
// if(r.getMsg()!=null&&r.getMsg().contains("审核通过了")&&!r.getOperatorId().equals(creatorId)){
|
|
|
- if(r.getMsg()!=null&&r.getMsg().contains("审核通过了")){
|
|
|
- r.setOperateDate(finalAuditDateTime);
|
|
|
- needUpdateReportLogDetailList.add(r);
|
|
|
+ if(r.getMsg()!=null&&r.getMsg().contains("审核通过了")){
|
|
|
+ r.setOperateDate(finalAuditDateTime);
|
|
|
+ needUpdateReportLogDetailList.add(r);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ needUpdateReportList.addAll(reports);
|
|
|
}
|
|
|
- });
|
|
|
- needUpdateReportList.addAll(reports);
|
|
|
- }
|
|
|
- if(createTimeCellValue!=null&&!StringUtils.isEmpty(createTimeCellValue)){
|
|
|
- try {
|
|
|
- createTimeTime = LocalDateTime.parse(createTimeCellValue, df);
|
|
|
- }catch (Exception e){
|
|
|
- msg.setError("第"+row+"行填报时间格式错误,请检查审核时间数据");
|
|
|
- return msg;
|
|
|
- }
|
|
|
- String creatorId = reports.get(0).getCreatorId();
|
|
|
- Integer id = reports.get(0).getId();
|
|
|
- List<ReportLog> list = reportLogService.list(new LambdaQueryWrapper<ReportLog>().apply("FIND_IN_SET(" + id + ",report_ids)"));
|
|
|
- List<ReportLog> reportLogs = list.stream().filter(l -> l.getMsg().contains("提交了")).collect(Collectors.toList());
|
|
|
- LocalDateTime finalCreateTimeTime1 = createTimeTime;
|
|
|
- reportLogs.forEach(r->{
|
|
|
- if(creatorId.equals(r.getOperatorId())){
|
|
|
- r.setOperateDate(finalCreateTimeTime1);
|
|
|
- needUpdateReportLogList.add(r);
|
|
|
- }
|
|
|
- });
|
|
|
- LocalDateTime finalCreateTimeTime = createTimeTime;
|
|
|
- reports.forEach(r->{
|
|
|
- r.setCreateTime(finalCreateTimeTime);
|
|
|
- });
|
|
|
- List<Integer> details = reports.stream().map(Report::getId).distinct().collect(Collectors.toList());
|
|
|
- List<ReportLogDetail> reportLogDetails = reportLogDetailService.list(new LambdaQueryWrapper<ReportLogDetail>().in(ReportLogDetail::getReportId, details));
|
|
|
- reportLogDetails.forEach(r->{
|
|
|
+ if(createTimeCellValue!=null&&!StringUtils.isEmpty(createTimeCellValue)){
|
|
|
+ try {
|
|
|
+ createTimeTime = LocalDateTime.parse(createTimeCellValue, df);
|
|
|
+ }catch (Exception e){
|
|
|
+ new Exception("第"+row+"行填报时间格式错误,请检查审核时间数据");
|
|
|
+ }
|
|
|
+ String creatorId = reports.get(0).getCreatorId();
|
|
|
+ Integer id = reports.get(0).getId();
|
|
|
+ List<ReportLog> list = reportLogService.list(new LambdaQueryWrapper<ReportLog>().apply("FIND_IN_SET(" + id + ",report_ids)"));
|
|
|
+ List<ReportLog> reportLogs = list.stream().filter(l -> l.getMsg().contains("提交了")).collect(Collectors.toList());
|
|
|
+ LocalDateTime finalCreateTimeTime1 = createTimeTime;
|
|
|
+ reportLogs.forEach(r->{
|
|
|
+ if(creatorId.equals(r.getOperatorId())){
|
|
|
+ r.setOperateDate(finalCreateTimeTime1);
|
|
|
+ needUpdateReportLogList.add(r);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ LocalDateTime finalCreateTimeTime = createTimeTime;
|
|
|
+ reports.forEach(r->{
|
|
|
+ r.setCreateTime(finalCreateTimeTime);
|
|
|
+ });
|
|
|
+ List<Integer> details = reports.stream().map(Report::getId).distinct().collect(Collectors.toList());
|
|
|
+ List<ReportLogDetail> reportLogDetails = allReportLogDetails.stream().filter(a -> details.contains(a.getReportId())).collect(Collectors.toList());
|
|
|
+ reportLogDetails.forEach(r->{
|
|
|
// if(r.getMsg()!=null&&r.getMsg().contains("提交了")&&r.getOperatorId().equals(creatorId)){
|
|
|
- if(r.getMsg()!=null&&r.getMsg().contains("提交了")){
|
|
|
- r.setOperateDate(finalCreateTimeTime1);
|
|
|
- needUpdateReportLogDetailList.add(r);
|
|
|
+ if(r.getMsg()!=null&&r.getMsg().contains("提交了")){
|
|
|
+ r.setOperateDate(finalCreateTimeTime1);
|
|
|
+ needUpdateReportLogDetailList.add(r);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ needUpdateReportList.addAll(reports);
|
|
|
}
|
|
|
- });
|
|
|
- needUpdateReportList.addAll(reports);
|
|
|
+ }else {
|
|
|
+ if(sb.toString().length()==0){
|
|
|
+ sb.append(numCell);
|
|
|
+ }else {
|
|
|
+ sb.append(","+numCell);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }else {
|
|
|
- if(sb.toString().length()==0){
|
|
|
- sb.append(numCell);
|
|
|
+ if(needUpdateReportList.size()>0){
|
|
|
+ reportService.updateBatchById(needUpdateReportList);
|
|
|
+ }
|
|
|
+ if(needUpdateReportLogList.size()>0){
|
|
|
+ reportLogService.updateBatchById(needUpdateReportLogList);
|
|
|
+ }
|
|
|
+ if(needUpdateReportLogDetailList.size()>0){
|
|
|
+ reportLogDetailService.updateBatchById(needUpdateReportLogDetailList);
|
|
|
+ }
|
|
|
+ String msgStr="";
|
|
|
+ if(sb.length()>0){
|
|
|
+ msgStr="更新完成,其中编号["+sb.toString()+"]的填报数据不存在";
|
|
|
}else {
|
|
|
- sb.append(","+numCell);
|
|
|
+ msgStr="更新完成";
|
|
|
+ }
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ wxCorpInfoService.sendWXCorpMsg(wxCorpInfo, user.getCorpwxUserid(),msgStr, null, WxCorpInfoServiceImpl.TEXT_CARD_MSG_REPORT_IMPORT);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if(needUpdateReportList.size()>0){
|
|
|
- reportService.updateBatchById(needUpdateReportList);
|
|
|
- }
|
|
|
- if(needUpdateReportLogList.size()>0){
|
|
|
- reportLogService.updateBatchById(needUpdateReportLogList);
|
|
|
- }
|
|
|
- if(needUpdateReportLogDetailList.size()>0){
|
|
|
- reportLogDetailService.updateBatchById(needUpdateReportLogDetailList);
|
|
|
- }
|
|
|
- if(sb.length()>0){
|
|
|
- msg.setMsg("更新完成,其中编号["+sb.toString()+"]的填报数据不存在");
|
|
|
- }else {
|
|
|
- msg.setMsg("更新完成");
|
|
|
- }
|
|
|
+ });
|
|
|
+ msg.setMsg("正在导入审核修改...请稍后查看");
|
|
|
}catch (FileNotFoundException e) {
|
|
|
e.printStackTrace();
|
|
|
} catch (IOException e) {
|