|
|
@ -2,9 +2,11 @@ package com.ccsens.ptccsens.service; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.ccsens.ptccsens.persist.dao.ProTaskDetailDao; |
|
|
|
import com.ccsens.util.PoiUtil; |
|
|
|
import com.ccsens.util.PropUtil; |
|
|
|
import com.ccsensptos.tallsdk.bean.vo.TallWbsVo; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
@ -12,6 +14,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.OutputStream; |
|
|
@ -26,6 +29,9 @@ import java.util.List; |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
|
public class ExportService implements IExportService { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private ProTaskDetailDao taskDetailDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public String exportWbs(TallWbsVo.WbsProjectInfo wbsProjectInfo, List<TallWbsVo.WbsTaskInfo> wbsTaskInfo, TallWbsVo.WbsRoleInfo wbsRoleInfo) throws Exception { |
|
|
|
Workbook wb = new XSSFWorkbook(); |
|
|
@ -35,6 +41,7 @@ public class ExportService implements IExportService { |
|
|
|
//生成项目成员表的数据
|
|
|
|
List<List<PoiUtil.PoiUtilCell>> member = generateMember(wbsRoleInfo); |
|
|
|
PoiUtil.exportWB("项目成员表", member, wb); |
|
|
|
log.info("成员表写入成功"); |
|
|
|
//生成文件
|
|
|
|
String fileName = "exportWbs/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; |
|
|
|
String path = PropUtil.path + fileName; |
|
|
@ -42,8 +49,11 @@ public class ExportService implements IExportService { |
|
|
|
if (!tmpFile.getParentFile().exists()) { |
|
|
|
tmpFile.getParentFile().mkdirs(); |
|
|
|
} |
|
|
|
log.info("生成流"); |
|
|
|
OutputStream stream = new FileOutputStream(tmpFile); |
|
|
|
log.info("写入wbs"); |
|
|
|
wb.write(stream); |
|
|
|
|
|
|
|
stream.close(); |
|
|
|
|
|
|
|
wb.close(); |
|
|
@ -126,84 +136,166 @@ public class ExportService implements IExportService { |
|
|
|
//序号
|
|
|
|
int num = 1; |
|
|
|
//循环添加一级任务
|
|
|
|
int pageNum = 1; |
|
|
|
int pageSize = 100; |
|
|
|
for (TallWbsVo.WbsTaskInfo task : wbsTaskInfo) { |
|
|
|
if(CollectionUtil.isEmpty(task.getSecondTaskList())){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
for (int i = 0; i < task.getSecondTaskList().size(); i++) { |
|
|
|
TallWbsVo.WbsSecondTask secondTask = task.getSecondTaskList().get(i); |
|
|
|
//行
|
|
|
|
List<PoiUtil.PoiUtilCell> taskRow = new ArrayList<>(); |
|
|
|
//序号
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell("" + num++)); |
|
|
|
//一级任务
|
|
|
|
if(i == 0){ |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(task.getFirstName(),task.getFirstId(),1,task.getSecondTaskList().size())); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
} |
|
|
|
//任务名
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getTaskName(),secondTask.getSubId(),1,1)); |
|
|
|
//描述
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getDescription(),secondTask.getDetailId(),1,1)); |
|
|
|
//开始时间
|
|
|
|
if("0".equals(secondTask.getStartTime()) || secondTask.getStartTime() == null){ |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getStartTime())); |
|
|
|
} |
|
|
|
//结束时间
|
|
|
|
if("0".equals(secondTask.getEndTime()) || secondTask.getEndTime() == null){ |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getEndTime())); |
|
|
|
} |
|
|
|
//TODO 任务时长
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
//标签
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getLabel())); |
|
|
|
//负责人
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getExecutor())); |
|
|
|
//检查人
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getChecker())); |
|
|
|
//交付物
|
|
|
|
if("0".equals(secondTask.getDeliverId()) || secondTask.getDeliverId() == null){ |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getDeliverName(),secondTask.getDeliverId(),1,1)); |
|
|
|
} |
|
|
|
//即时奖惩
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
//插件1
|
|
|
|
if("0".equals(secondTask.getPluginOneId()) || secondTask.getPluginOneId() == null){ |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
log.info("循环一级任务:{}",task.getFirstName()); |
|
|
|
boolean flag = true; |
|
|
|
while (flag){ |
|
|
|
log.info("第{}个二级任务",(pageNum*pageSize)); |
|
|
|
PageHelper.startPage(pageNum,pageSize); |
|
|
|
List<TallWbsVo.WbsSecondTask> secondTaskList = taskDetailDao.getSecondTask(task.getFirstId()); |
|
|
|
if(CollectionUtil.isEmpty(secondTaskList)){ |
|
|
|
flag = false; |
|
|
|
pageNum = 1; |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getPluginOneName(),secondTask.getPluginOneId(),1,1)); |
|
|
|
pageNum++; |
|
|
|
} |
|
|
|
//插件2
|
|
|
|
if("0".equals(secondTask.getPluginTwoId()) || secondTask.getPluginTwoId() == null){ |
|
|
|
for (int i = 0; i < secondTaskList.size(); i++) { |
|
|
|
TallWbsVo.WbsSecondTask secondTask = secondTaskList.get(i); |
|
|
|
log.info("二级任务:{}",i); |
|
|
|
|
|
|
|
//行
|
|
|
|
List<PoiUtil.PoiUtilCell> taskRow = new ArrayList<>(); |
|
|
|
//序号
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell("" + num++)); |
|
|
|
//一级任务
|
|
|
|
if(i == 0){ |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(task.getFirstName(),task.getFirstId(),1,secondTaskList.size())); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
} |
|
|
|
//任务名
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getTaskName(),secondTask.getSubId(),1,1)); |
|
|
|
//描述
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getDescription(),secondTask.getDetailId(),1,1)); |
|
|
|
//开始时间
|
|
|
|
if("0".equals(secondTask.getStartTime()) || secondTask.getStartTime() == null){ |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getStartTime())); |
|
|
|
} |
|
|
|
//结束时间
|
|
|
|
if("0".equals(secondTask.getEndTime()) || secondTask.getEndTime() == null){ |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getEndTime())); |
|
|
|
} |
|
|
|
//TODO 任务时长
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getPluginTwoName(),secondTask.getPluginTwoId(),1,1)); |
|
|
|
} |
|
|
|
//插件3
|
|
|
|
if("0".equals(secondTask.getPluginThreeId()) || secondTask.getPluginThreeId() == null){ |
|
|
|
//标签
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getLabel())); |
|
|
|
//负责人
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getExecutor())); |
|
|
|
//检查人
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getChecker())); |
|
|
|
//交付物
|
|
|
|
if("0".equals(secondTask.getDeliverId()) || secondTask.getDeliverId() == null){ |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getDeliverName(),secondTask.getDeliverId(),1,1)); |
|
|
|
} |
|
|
|
//即时奖惩
|
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getPluginThreeName(),secondTask.getPluginThreeId(),1,1)); |
|
|
|
} |
|
|
|
wbs.add(taskRow); |
|
|
|
if(wbs.size() >= 30){ |
|
|
|
//写入数据
|
|
|
|
PoiUtil.exportWB("WBS", rowIndex, wbs, wb); |
|
|
|
rowIndex += 30; |
|
|
|
wbs.clear(); |
|
|
|
//插件1
|
|
|
|
if("0".equals(secondTask.getPluginOneId()) || secondTask.getPluginOneId() == null){ |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getPluginOneName(),secondTask.getPluginOneId(),1,1)); |
|
|
|
} |
|
|
|
//插件2
|
|
|
|
if("0".equals(secondTask.getPluginTwoId()) || secondTask.getPluginTwoId() == null){ |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getPluginTwoName(),secondTask.getPluginTwoId(),1,1)); |
|
|
|
} |
|
|
|
//插件3
|
|
|
|
if("0".equals(secondTask.getPluginThreeId()) || secondTask.getPluginThreeId() == null){ |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell()); |
|
|
|
}else { |
|
|
|
taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getPluginThreeName(),secondTask.getPluginThreeId(),1,1)); |
|
|
|
} |
|
|
|
wbs.add(taskRow); |
|
|
|
} |
|
|
|
|
|
|
|
PoiUtil.exportWB("WBS", rowIndex, wbs, wb); |
|
|
|
rowIndex += 100; |
|
|
|
wbs.clear(); |
|
|
|
} |
|
|
|
|
|
|
|
// for (int i = 0; i < task.getSecondTaskList().size(); i++) {
|
|
|
|
// TallWbsVo.WbsSecondTask secondTask = task.getSecondTaskList().get(i);
|
|
|
|
// //行
|
|
|
|
// List<PoiUtil.PoiUtilCell> taskRow = new ArrayList<>();
|
|
|
|
// //序号
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell("" + num++));
|
|
|
|
// //一级任务
|
|
|
|
// if(i == 0){
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell(task.getFirstName(),task.getFirstId(),1,task.getSecondTaskList().size()));
|
|
|
|
// }else {
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell());
|
|
|
|
// }
|
|
|
|
// //任务名
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getTaskName(),secondTask.getSubId(),1,1));
|
|
|
|
// //描述
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getDescription(),secondTask.getDetailId(),1,1));
|
|
|
|
// //开始时间
|
|
|
|
// if("0".equals(secondTask.getStartTime()) || secondTask.getStartTime() == null){
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell());
|
|
|
|
// }else {
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getStartTime()));
|
|
|
|
// }
|
|
|
|
// //结束时间
|
|
|
|
// if("0".equals(secondTask.getEndTime()) || secondTask.getEndTime() == null){
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell());
|
|
|
|
// }else {
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getEndTime()));
|
|
|
|
// }
|
|
|
|
// //TODO 任务时长
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell());
|
|
|
|
// //标签
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getLabel()));
|
|
|
|
// //负责人
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getExecutor()));
|
|
|
|
// //检查人
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getChecker()));
|
|
|
|
// //交付物
|
|
|
|
// if("0".equals(secondTask.getDeliverId()) || secondTask.getDeliverId() == null){
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell());
|
|
|
|
// }else {
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getDeliverName(),secondTask.getDeliverId(),1,1));
|
|
|
|
// }
|
|
|
|
// //即时奖惩
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell());
|
|
|
|
// //插件1
|
|
|
|
// if("0".equals(secondTask.getPluginOneId()) || secondTask.getPluginOneId() == null){
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell());
|
|
|
|
// }else {
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getPluginOneName(),secondTask.getPluginOneId(),1,1));
|
|
|
|
// }
|
|
|
|
// //插件2
|
|
|
|
// if("0".equals(secondTask.getPluginTwoId()) || secondTask.getPluginTwoId() == null){
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell());
|
|
|
|
// }else {
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getPluginTwoName(),secondTask.getPluginTwoId(),1,1));
|
|
|
|
// }
|
|
|
|
// //插件3
|
|
|
|
// if("0".equals(secondTask.getPluginThreeId()) || secondTask.getPluginThreeId() == null){
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell());
|
|
|
|
// }else {
|
|
|
|
// taskRow.add(new PoiUtil.PoiUtilCell(secondTask.getPluginThreeName(),secondTask.getPluginThreeId(),1,1));
|
|
|
|
// }
|
|
|
|
// wbs.add(taskRow);
|
|
|
|
// if(wbs.size() >= 30){
|
|
|
|
// //写入数据
|
|
|
|
// PoiUtil.exportWB("WBS", rowIndex, wbs, wb);
|
|
|
|
// rowIndex += 30;
|
|
|
|
// wbs.clear();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
} |
|
|
|
//写入数据
|
|
|
|
PoiUtil.exportWB("WBS", rowIndex, wbs, wb); |
|
|
|
// PoiUtil.exportWB("WBS", rowIndex, wbs, wb);
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -252,7 +344,9 @@ public class ExportService implements IExportService { |
|
|
|
TallWbsVo.WbsRole role = pmList.get(i); |
|
|
|
if(CollectionUtil.isNotEmpty(role.getMemberList())){ |
|
|
|
for (int j = 0; j < role.getMemberList().size(); j++) { |
|
|
|
|
|
|
|
TallWbsVo.WbsMember member = role.getMemberList().get(j); |
|
|
|
log.info("角色:{}",member.getMemberName()); |
|
|
|
List<PoiUtil.PoiUtilCell> roleInfo = new ArrayList<>(); |
|
|
|
roleInfo.add(new PoiUtil.PoiUtilCell("" + num++)); |
|
|
|
//系统角色
|
|
|
|