Browse Source

20211026修改导入wbs

master
zy_Java 4 years ago
parent
commit
5c866de98d
  1. 3
      src/main/java/com/ccsens/defaultwbs/api/ClockingInController.java
  2. 18
      src/main/java/com/ccsens/defaultwbs/bean/dto/TaskDto.java
  3. 2
      src/main/java/com/ccsens/defaultwbs/persist/dao/SPluginDao.java
  4. 2
      src/main/java/com/ccsens/defaultwbs/service/ClockingInService.java
  5. 2
      src/main/java/com/ccsens/defaultwbs/service/IClockingInService.java
  6. 114
      src/main/java/com/ccsens/defaultwbs/service/ImportService.java
  7. 2
      src/main/java/com/ccsens/defaultwbs/util/Constant.java
  8. 4
      src/main/resources/application.yml
  9. 10
      src/main/resources/mapper_dao/SPluginDao.xml

3
src/main/java/com/ccsens/defaultwbs/api/ClockingInController.java

@ -55,7 +55,8 @@ public class ClockingInController {
@RequestMapping(value = "/audit", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse auditRecord(@ApiParam @Validated @RequestBody QueryDto<ClockingInDto.Audit> params) throws Exception{
log.info("审核打卡:{}",params);
clockingInService.auditRecord(params.getParam(), params.getUserId());
// clockingInService.auditRecord(params.getParam(), params.getUserId());
clockingInService.auditRecord1(params.getParam(), params.getUserId());
return JsonResponse.newInstance().ok();
}

18
src/main/java/com/ccsens/defaultwbs/bean/dto/TaskDto.java

@ -58,4 +58,22 @@ public class TaskDto {
private int type;
}
/**
* 导入wbs--插件关联表id
*/
@Data
public static class TaskPluginId{
private Long taskPluginId1;
private Long taskPluginId2;
private Long taskPluginId3;
public TaskPluginId(Long id1, Long id2,Long id3) {
this.taskPluginId1 = id1;
this.taskPluginId2 = id2;
this.taskPluginId3 = id3;
}
public TaskPluginId() {
}
}
}

2
src/main/java/com/ccsens/defaultwbs/persist/dao/SPluginDao.java

@ -7,4 +7,6 @@ import org.apache.ibatis.annotations.Param;
*/
public interface SPluginDao {
Long getPluginIdByName(@Param("pluginName") String pluginName);
void updateParamById(@Param("param")String param,@Param("taskPluginId")Long taskPluginId);
}

2
src/main/java/com/ccsens/defaultwbs/service/ClockingInService.java

@ -272,7 +272,7 @@ public class ClockingInService implements IClockingInService {
}
}
@Override
public void auditRecord1(ClockingInDto.Audit params, Long userId) {
ProClockingIn proClockingIn;
//查询当前用户所属的memberId

2
src/main/java/com/ccsens/defaultwbs/service/IClockingInService.java

@ -40,4 +40,6 @@ public interface IClockingInService {
* @return excel的路径
*/
ClockingInVo.ExcelUrl exportRecord(ClockingInDto.QueryClockingIn params, Long userId) throws IOException;
void auditRecord1(ClockingInDto.Audit param, Long userId);
}

114
src/main/java/com/ccsens/defaultwbs/service/ImportService.java

@ -5,22 +5,20 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.ccsens.cloudutil.bean.tall.dto.ProjectDto;
import com.ccsens.cloudutil.feign.Tall3FeignClient;
import com.ccsens.cloudutil.feign.TallFeignClient;
import com.ccsens.common.persist.dao.*;
import com.ccsens.common.bean.po.*;
import com.ccsens.common.persist.mapper.*;
import com.ccsens.defaultwbs.bean.dto.RoleDto;
import com.ccsens.defaultwbs.bean.dto.TaskDto;
import com.ccsens.defaultwbs.bean.vo.ProjectVo;
import com.ccsens.defaultwbs.persist.dao.SProjectDao;
import com.ccsens.defaultwbs.persist.dao.SPluginDao;
import com.ccsens.defaultwbs.persist.dao.SProjectDao;
import com.ccsens.defaultwbs.persist.dao.STaskDao;
import com.ccsens.defaultwbs.persist.dao.SubLabelDao;
import com.ccsens.common.bean.po.LabelBusiness;
import com.ccsens.common.bean.po.ProMemberStakeholder;
import com.ccsens.defaultwbs.util.DefaultCodeError;
import com.ccsens.defaultwbs.util.Constant;
import com.ccsens.cloudutil.bean.tall.dto.ProjectDto;
import com.ccsens.cloudutil.feign.Tall3FeignClient;
import com.ccsens.common.bean.po.*;
import com.ccsens.common.persist.dao.*;
import com.ccsens.common.persist.mapper.ProMemberStakeholderMapper;
import com.ccsens.defaultwbs.util.DefaultCodeError;
import com.ccsens.util.ExcelUtil;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.PropUtil;
@ -63,6 +61,8 @@ public class ImportService implements IImportService {
@Resource
private SubLabelDao subLabelDao;
@Resource
private LabelDao labelDao;
@Resource
private ProRoleDao roleDao;
@Resource
private ProMemberDao memberDao;
@ -108,18 +108,68 @@ public class ImportService implements IImportService {
//成员
Map<String, RoleDto.WbsMember> memberMap = new HashMap<>();
//任务
Map<String, Long> taskMap = new HashMap<>();
Map<String, Object> taskMap = new HashMap<>();
//读取文件
readExcel(xssfWorkbook, userId, roleMap, memberMap, taskMap,projectId,projectInfo);
//读取插件配置表
readPluginConfig(xssfWorkbook,taskMap);
return projectInfo;
}
/**
* 读取插件配置表
*/
private void readPluginConfig(XSSFWorkbook wb, Map<String, Object> taskMap) {
//获取插件配置表Sheet
XSSFSheet wbsSheet = wb.getSheet(Constant.WbsExcel.WBS_PLUGIN_CONFIG);
if (ObjectUtil.isNotNull(wbsSheet)) {
for (int i = 0; i <= wbsSheet.getLastRowNum(); i++) {
//获取行
XSSFRow row = wbsSheet.getRow(i);
if (row == null) {
continue;
}
//序号
String sequence = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(0)));
//任务名
String taskName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(1)));
if(StrUtil.isEmpty(taskName)){
continue;
}
//插件1
String pluginParam1 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(2)));
//插件2
String pluginParam2 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(3)));
//插件3
String pluginParam3 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(4)));
Object o = taskMap.get(sequence + "_" + taskName);
if(ObjectUtil.isNull(o)){
continue;
}
TaskDto.TaskPluginId taskPlugin = (TaskDto.TaskPluginId) o;
if(StrUtil.isNotEmpty(pluginParam1)){
//修改插件表的param
sTaskPluginDao.updateParamById(pluginParam1,taskPlugin.getTaskPluginId1());
}
if(StrUtil.isNotEmpty(pluginParam2)){
//修改插件表的param
sTaskPluginDao.updateParamById(pluginParam2,taskPlugin.getTaskPluginId2());
}
if(StrUtil.isNotEmpty(pluginParam3)){
//修改插件表的param
sTaskPluginDao.updateParamById(pluginParam3,taskPlugin.getTaskPluginId3());
}
}
}
}
/**
* 读取每个sheet
*/
private void readExcel(XSSFWorkbook wb, Long userId, Map<String, Long> roleMap, Map<String, RoleDto.WbsMember> memberMap, Map<String, Long> taskMap,Long projectId,ProjectVo.ProjectInfo projectInfo) {
private void readExcel(XSSFWorkbook wb, Long userId, Map<String, Long> roleMap, Map<String, RoleDto.WbsMember> memberMap, Map<String, Object> taskMap,Long projectId,ProjectVo.ProjectInfo projectInfo) {
//获取wbsSheet
XSSFSheet wbsSheet = wb.getSheet(Constant.WbsExcel.WBS_SHEET);
if (ObjectUtil.isNull(wbsSheet)) {
@ -168,13 +218,13 @@ public class ImportService implements IImportService {
//读取成员表
readMemberSheet(memberSheet,project,roleMap,memberMap);
//添加任务
readTask(wbsSheet,taskStart,project,roleMap);
readTask(wbsSheet,taskStart,project,roleMap,taskMap);
//获取用户列表
Set<Long> userIdSet = new HashSet<>();
userIdSet.add(userId);
//处理创建人的权限问题(添加创建人角色)
//查找创建者标签id
Long roleLabelId = subLabelDao.getLabelByTypeAndLevel(5, 5);
Long roleLabelId = labelDao.getLabelByTypeAndLevel(5, 5);
//添加创建者角色
ProRole role = new ProRole();
role.setId(snowflake.nextId());
@ -345,7 +395,7 @@ public class ImportService implements IImportService {
taskVersion.setAddress(address);
taskVersionMapper.insertSelective(taskVersion);
//查找项目标签
Long labelId = subLabelDao.getLabelByTypeAndLevel(1, 0);
Long labelId = labelDao.getLabelByTypeAndLevel(1, 0);
//添加任务标签关联信息
saveLabelTask(taskDetail.getId(), labelId);
@ -545,7 +595,7 @@ public class ImportService implements IImportService {
/**
* 读取任务信息
*/
private void readTask(XSSFSheet wbsSheet, int taskStart, ProjectVo.SysProject project, Map<String, Long> roleMap) {
private void readTask(XSSFSheet wbsSheet, int taskStart, ProjectVo.SysProject project, Map<String, Long> roleMap, Map<String, Object> taskMap) {
//一级任务id
Long firstTaskId = null;
@ -597,6 +647,8 @@ public class ImportService implements IImportService {
//获取当前行
XSSFRow row = wbsSheet.getRow(i);
if(ObjectUtil.isNull(row)){ continue; }
//序号
String sequence = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(0)));
//一级任务名
String firstTaskName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(1)));
if(StrUtil.isEmpty(firstTaskName) && ObjectUtil.isNull(firstTaskId)){
@ -657,7 +709,6 @@ public class ImportService implements IImportService {
}
String[] split = executorRole.split(Constant.STRING_REGEX);
for (String repulsionName : split) {
//TODO 全体成员
Long executorRoleId = roleMap.get(repulsionName);
if(ObjectUtil.isNull(executorRoleId)){
throw new BaseException(DefaultCodeError.WBS_NOT_FIND_ROLE.addMsg(wbsSheet.getSheetName(),i+1,repulsionName));
@ -672,12 +723,14 @@ public class ImportService implements IImportService {
//处理时间、添加任务分解、添加任务标签
taskStartTime = taskSaveTime(taskStartTime, project, beginTime, endTime, duration, taskDetail.getId(),wbsSheet,i+1);
//添加时间颗粒度标签并关联
Long timeLabel = subLabelDao.getLabelByTypeAndLevel(0, 4);
Long timeLabel = labelDao.getLabelByTypeAndLevel(0, 4);
saveLabelTask(taskDetail.getId(),timeLabel);
//插件
plugin(plugin1,taskDetail.getId(),1,wbsSheet,i+1);
plugin(plugin2,taskDetail.getId(),2,wbsSheet,i+1);
plugin(plugin3,taskDetail.getId(),3,wbsSheet,i+1);
Long taskPlugin1 = plugin(plugin1,taskDetail.getId(),1,wbsSheet,i+1);
Long taskPlugin2 = plugin(plugin2,taskDetail.getId(),2,wbsSheet,i+1);
Long taskPlugin3 = plugin(plugin3,taskDetail.getId(),3,wbsSheet,i+1);
TaskDto.TaskPluginId taskPlugin = new TaskDto.TaskPluginId(taskPlugin1,taskPlugin2,taskPlugin3);
taskMap.put(sequence + "_" + taskName, taskPlugin);
}
//TODO 检查人
//TODO 及时奖惩
@ -685,7 +738,8 @@ public class ImportService implements IImportService {
//TODO 添加默认插件
}
}
private void plugin(String plugin,Long taskId,int row,XSSFSheet wbsSheet,int errorRow) {
private Long plugin(String plugin,Long taskId,int row,XSSFSheet wbsSheet,int errorRow) {
Long taskPlugin = null;
if(StrUtil.isNotEmpty(plugin)){
//根据插件名称查找插件id
Long pluginId = sTaskPluginDao.getPluginIdByName(plugin);
@ -702,7 +756,9 @@ public class ImportService implements IImportService {
proTaskPlugin.setRowspan(1);
proTaskPlugin.setColspan(1);
proTaskPluginDao.insertSelective(proTaskPlugin);
taskPlugin = proTaskPlugin.getId();
}
return taskPlugin;
}
private Long taskSaveTime(Long taskStartTime,ProjectVo.SysProject project, String beginTime, String endTime, String duration, Long taskDetailId,XSSFSheet wbsSheet,int row) {
@ -735,7 +791,7 @@ public class ImportService implements IImportService {
taskSub.setPlanEndTime(taskStartTime);
taskSubDao.insertSelective(taskSub);
//查找定期任务标签并关联任务
Long taskLabel = subLabelDao.getLabelByTypeAndLevel(1, 3);
Long taskLabel = labelDao.getLabelByTypeAndLevel(1, 3);
saveLabelTask(taskDetailId,taskLabel);
}else {
@ -745,7 +801,7 @@ public class ImportService implements IImportService {
taskSub.setTaskDetailId(taskDetailId);
taskSubDao.insertSelective(taskSub);
//查找日常任务标签并关联信息
Long label = subLabelDao.getLabelByTypeAndLevel(1, 2);
Long label = labelDao.getLabelByTypeAndLevel(1, 2);
saveLabelTask(taskDetailId,label);
}
}else {
@ -763,7 +819,7 @@ public class ImportService implements IImportService {
taskSub.setPlanDuration(eTime - bTime);
taskSubDao.insertSelective(taskSub);
//查找定期任务标签并关联任务
Long taskLabel = subLabelDao.getLabelByTypeAndLevel(1, 3);
Long taskLabel = labelDao.getLabelByTypeAndLevel(1, 3);
saveLabelTask(taskDetailId,taskLabel);
// //添加时间颗粒度标签并关联
// Long timeLabel = subLabelDao.getLabelByTypeAndLevel(0, 4);
@ -792,11 +848,11 @@ public class ImportService implements IImportService {
sTaskDao.insertSelectiveList(proTaskSubList);
}
//查找定期任务标签并关联任务
Long taskLabel = subLabelDao.getLabelByTypeAndLevel(1, 3);
Long taskLabel = labelDao.getLabelByTypeAndLevel(1, 3);
saveLabelTask(taskDetailId,taskLabel);
}catch (Exception e1){
throw new BaseException(String.valueOf(e1));
// throw new BaseException(DefaultCodeError.WBS_PROJECT_TIME_ERROR);
// throw new BaseException(SportsCodeError.WBS_PROJECT_TIME_ERROR);
}
}
}
@ -830,9 +886,11 @@ public class ImportService implements IImportService {
parentTask.setParentTaskDetailId(project.getId());
parentTaskMapper.insertSelective(parentTask);
//查找一级任务标签
Long labelId = subLabelDao.getLabelByTypeAndLevel(1, 1);
Long labelId = labelDao.getLabelByTypeAndLevel(1, 1);
//添加任务标签关联信息
saveLabelTask(taskDetail.getId(), labelId);
return firstTaskId;
}
}

2
src/main/java/com/ccsens/defaultwbs/util/Constant.java

@ -24,6 +24,8 @@ public class Constant {
public static final String TASK_INFO_TITLE = "项目任务分解";
/**excel文件格式验证*/
public static final String WBS_FILE_FORMAT = "xls,xlsx";
/**插件配置表*/
public static final String WBS_PLUGIN_CONFIG = "插件配置表";
}
/**wbs表时长对应关系表*/

4
src/main/resources/application.yml

@ -1,4 +1,4 @@
spring:
profiles:
active: dev
include: common, util-dev
active: test
include: common, util-test

10
src/main/resources/mapper_dao/SPluginDao.xml

@ -12,4 +12,14 @@
and rec_status = 0
limit 1
</select>
<update id="updateParamById">
update
t_pro_task_plugin
set
param = #{param}
where
id = #{taskPluginId}
and rec_status = 0
</update>
</mapper>
Loading…
Cancel
Save