|
|
@ -206,57 +206,30 @@ public class TaskDeliverService implements ITaskDeliverService { |
|
|
|
if (!role.getName().equalsIgnoreCase(WebConstant.ROLE_NAME.AllMember.phase) && !isBelongRole){ |
|
|
|
throw new BaseException(CodeEnum.IS_NOT_EXECUTOR); |
|
|
|
} |
|
|
|
// //查找以前上传的不为历史信息的文件。改为历史信息
|
|
|
|
// ProTaskDeliverPostLogExample logExample = new ProTaskDeliverPostLogExample();
|
|
|
|
// logExample.createCriteria().andTaskSubTimeIdEqualTo(subTimeId).andDeliverIdEqualTo(uploadDeliver.getDeliverId())
|
|
|
|
// .andUserIdEqualTo(currentUserId).andIsHistoryEqualTo(0);
|
|
|
|
// List<ProTaskDeliverPostLog> deliverPostLogList = deliverPostLogDao.selectByExample(logExample);
|
|
|
|
// if (CollectionUtil.isNotEmpty(deliverPostLogList)) {
|
|
|
|
// for (ProTaskDeliverPostLog deliverPostLog : deliverPostLogList) {
|
|
|
|
// deliverPostLog.setIsHistory(1);
|
|
|
|
// deliverPostLogDao.updateByPrimaryKeySelective(deliverPostLog);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
//将文件信息与交付物绑定,添加记录deliverPostLog
|
|
|
|
if (CollectionUtil.isNotEmpty(uploadDeliver.getFileInfo()) || StrUtil.isNotEmpty(uploadDeliver.getDescription())) { |
|
|
|
if(CollectionUtil.isEmpty(uploadDeliver.getFileInfo())){ |
|
|
|
ProTaskDeliverPostLog deliverPostLog = new ProTaskDeliverPostLog(); |
|
|
|
deliverPostLog.setId(snowflake.nextId()); |
|
|
|
deliverPostLog.setDeliverId(uploadDeliver.getDeliverId()); |
|
|
|
deliverPostLog.setTaskSubTimeId(subTimeId); |
|
|
|
deliverPostLog.setUserId(currentUserId); |
|
|
|
deliverPostLog.setDescription(uploadDeliver.getDescription()); |
|
|
|
deliverPostLog.setTime(now); |
|
|
|
deliverPostLog.setIsHistory(0); |
|
|
|
deliverPostLogDao.insertSelective(deliverPostLog); |
|
|
|
//添加交付物检查人表
|
|
|
|
if (CollectionUtil.isNotEmpty(uploadDeliver.getCheckerIdList())) { |
|
|
|
ProTaskDeliverPostLogChecker postLogChecker; |
|
|
|
for (Long checkerId : uploadDeliver.getCheckerIdList()) { |
|
|
|
postLogChecker = new ProTaskDeliverPostLogChecker(); |
|
|
|
postLogChecker.setId(snowflake.nextId()); |
|
|
|
postLogChecker.setDeliverPostLogId(deliverPostLog.getId()); |
|
|
|
postLogChecker.setCheckerId(checkerId); |
|
|
|
postLogCheckerDao.insertSelective(postLogChecker); |
|
|
|
//拼接文件id
|
|
|
|
StringBuilder filesId = new StringBuilder(); |
|
|
|
if(CollectionUtil.isNotEmpty(uploadDeliver.getFileInfo())){ |
|
|
|
for (int i = 0; i < uploadDeliver.getFileInfo().size(); i++) { |
|
|
|
DeliverDto.FileInfo fileInfo = uploadDeliver.getFileInfo().get(i); |
|
|
|
if(i == 0){ |
|
|
|
filesId.append(fileInfo.getId()); |
|
|
|
}else { |
|
|
|
filesId.append(",").append(fileInfo.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
throw new BaseException(CodeEnum.NOT_CHECKER); |
|
|
|
} |
|
|
|
}else { |
|
|
|
for (DeliverDto.FileInfo fileInfo : uploadDeliver.getFileInfo()) { |
|
|
|
// SysCommitedFile file = commitedFileDao.selectByPrimaryKey(fileInfo.getId());
|
|
|
|
// if(ObjectUtil.isNull(file)){
|
|
|
|
// throw new BaseException(CodeEnum.NOT_DELIVER_FILE);
|
|
|
|
// }
|
|
|
|
ProTaskDeliverPostLog deliverPostLog = new ProTaskDeliverPostLog(); |
|
|
|
deliverPostLog.setId(snowflake.nextId()); |
|
|
|
deliverPostLog.setDeliverId(uploadDeliver.getDeliverId()); |
|
|
|
deliverPostLog.setTaskSubTimeId(subTimeId); |
|
|
|
deliverPostLog.setFileId(fileInfo.getId()); |
|
|
|
deliverPostLog.setUserId(currentUserId); |
|
|
|
deliverPostLog.setDescription(uploadDeliver.getDescription()); |
|
|
|
deliverPostLog.setTime(now); |
|
|
|
deliverPostLog.setIsHistory(0); |
|
|
|
deliverPostLog.setFilesId(filesId.toString()); |
|
|
|
deliverPostLogDao.insertSelective(deliverPostLog); |
|
|
|
//添加交付物检查人表
|
|
|
|
if (CollectionUtil.isNotEmpty(uploadDeliver.getCheckerIdList())) { |
|
|
@ -271,10 +244,6 @@ public class TaskDeliverService implements ITaskDeliverService { |
|
|
|
} else { |
|
|
|
throw new BaseException(CodeEnum.NOT_CHECKER); |
|
|
|
} |
|
|
|
//保存wps的文件消息
|
|
|
|
saveWpsFile(currentUserId, deliverPostLog.getId(), fileInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
//修改交付物状态
|
|
|
|
ProTaskDeliver deliver = new ProTaskDeliver(); |
|
|
|
deliver.setId(uploadDeliver.getDeliverId()); |
|
|
@ -282,8 +251,6 @@ public class TaskDeliverService implements ITaskDeliverService { |
|
|
|
taskDeliverDao.updateByPrimaryKeySelective(deliver); |
|
|
|
} |
|
|
|
|
|
|
|
//发送WS信息
|
|
|
|
|
|
|
|
//获取所有接收者的id
|
|
|
|
List<BaseMessageDto.MessageUser> messageUserList = new ArrayList<>(); |
|
|
|
BaseMessageDto.MessageUser messageUser; |
|
|
@ -344,6 +311,168 @@ public class TaskDeliverService implements ITaskDeliverService { |
|
|
|
return deliverInfo; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
// * 将文件绑定交付物
|
|
|
|
// */
|
|
|
|
// @Override
|
|
|
|
// public ProjectVo.DeliverInfo addDeliver(Long currentUserId, DeliverDto.UploadDeliver uploadDeliver) throws Exception {
|
|
|
|
// Long now = System.currentTimeMillis();
|
|
|
|
// Long subTimeId = isTaskOrSubTime(uploadDeliver.getTaskId());
|
|
|
|
// if (ObjectUtil.isNull(subTimeId)) {
|
|
|
|
// throw new BaseException(CodeEnum.NOT_TASK);
|
|
|
|
// }
|
|
|
|
// ProjectVo.DeliverInfo deliverInfo = null;
|
|
|
|
// //查找交付
|
|
|
|
// ProTaskDeliver taskDeliver = taskDeliverDao.selectByPrimaryKey(uploadDeliver.getDeliverId());
|
|
|
|
// if (ObjectUtil.isNull(taskDeliver)) {
|
|
|
|
// throw new BaseException(CodeEnum.NOT_DELIVER);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// ProTaskDetail taskDetail = taskDetailDao.selectByPrimaryKey(taskDeliver.getTaskDetailId());
|
|
|
|
// ProRole role = proRoleDao.selectByPrimaryKey(taskDetail.getExecutorRole());
|
|
|
|
// Boolean isBelongRole = proMemberService.userIsBelongRole(currentUserId, role.getId(),null);
|
|
|
|
// if (!role.getName().equalsIgnoreCase(WebConstant.ROLE_NAME.AllMember.phase) && !isBelongRole){
|
|
|
|
// throw new BaseException(CodeEnum.IS_NOT_EXECUTOR);
|
|
|
|
// }
|
|
|
|
//// //查找以前上传的不为历史信息的文件。改为历史信息
|
|
|
|
//// ProTaskDeliverPostLogExample logExample = new ProTaskDeliverPostLogExample();
|
|
|
|
//// logExample.createCriteria().andTaskSubTimeIdEqualTo(subTimeId).andDeliverIdEqualTo(uploadDeliver.getDeliverId())
|
|
|
|
//// .andUserIdEqualTo(currentUserId).andIsHistoryEqualTo(0);
|
|
|
|
//// List<ProTaskDeliverPostLog> deliverPostLogList = deliverPostLogDao.selectByExample(logExample);
|
|
|
|
//// if (CollectionUtil.isNotEmpty(deliverPostLogList)) {
|
|
|
|
//// for (ProTaskDeliverPostLog deliverPostLog : deliverPostLogList) {
|
|
|
|
//// deliverPostLog.setIsHistory(1);
|
|
|
|
//// deliverPostLogDao.updateByPrimaryKeySelective(deliverPostLog);
|
|
|
|
//// }
|
|
|
|
//// }
|
|
|
|
// //将文件信息与交付物绑定,添加记录deliverPostLog
|
|
|
|
// if (CollectionUtil.isNotEmpty(uploadDeliver.getFileInfo()) || StrUtil.isNotEmpty(uploadDeliver.getDescription())) {
|
|
|
|
// if(CollectionUtil.isEmpty(uploadDeliver.getFileInfo())){
|
|
|
|
// ProTaskDeliverPostLog deliverPostLog = new ProTaskDeliverPostLog();
|
|
|
|
// deliverPostLog.setId(snowflake.nextId());
|
|
|
|
// deliverPostLog.setDeliverId(uploadDeliver.getDeliverId());
|
|
|
|
// deliverPostLog.setTaskSubTimeId(subTimeId);
|
|
|
|
// deliverPostLog.setUserId(currentUserId);
|
|
|
|
// deliverPostLog.setDescription(uploadDeliver.getDescription());
|
|
|
|
// deliverPostLog.setTime(now);
|
|
|
|
// deliverPostLog.setIsHistory(0);
|
|
|
|
// deliverPostLogDao.insertSelective(deliverPostLog);
|
|
|
|
// //添加交付物检查人表
|
|
|
|
// if (CollectionUtil.isNotEmpty(uploadDeliver.getCheckerIdList())) {
|
|
|
|
// ProTaskDeliverPostLogChecker postLogChecker;
|
|
|
|
// for (Long checkerId : uploadDeliver.getCheckerIdList()) {
|
|
|
|
// postLogChecker = new ProTaskDeliverPostLogChecker();
|
|
|
|
// postLogChecker.setId(snowflake.nextId());
|
|
|
|
// postLogChecker.setDeliverPostLogId(deliverPostLog.getId());
|
|
|
|
// postLogChecker.setCheckerId(checkerId);
|
|
|
|
// postLogCheckerDao.insertSelective(postLogChecker);
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// throw new BaseException(CodeEnum.NOT_CHECKER);
|
|
|
|
// }
|
|
|
|
// }else {
|
|
|
|
// for (DeliverDto.FileInfo fileInfo : uploadDeliver.getFileInfo()) {
|
|
|
|
//// SysCommitedFile file = commitedFileDao.selectByPrimaryKey(fileInfo.getId());
|
|
|
|
//// if(ObjectUtil.isNull(file)){
|
|
|
|
//// throw new BaseException(CodeEnum.NOT_DELIVER_FILE);
|
|
|
|
//// }
|
|
|
|
// ProTaskDeliverPostLog deliverPostLog = new ProTaskDeliverPostLog();
|
|
|
|
// deliverPostLog.setId(snowflake.nextId());
|
|
|
|
// deliverPostLog.setDeliverId(uploadDeliver.getDeliverId());
|
|
|
|
// deliverPostLog.setTaskSubTimeId(subTimeId);
|
|
|
|
// deliverPostLog.setFileId(fileInfo.getId());
|
|
|
|
// deliverPostLog.setUserId(currentUserId);
|
|
|
|
// deliverPostLog.setDescription(uploadDeliver.getDescription());
|
|
|
|
// deliverPostLog.setTime(now);
|
|
|
|
// deliverPostLog.setIsHistory(0);
|
|
|
|
// deliverPostLogDao.insertSelective(deliverPostLog);
|
|
|
|
// //添加交付物检查人表
|
|
|
|
// if (CollectionUtil.isNotEmpty(uploadDeliver.getCheckerIdList())) {
|
|
|
|
// ProTaskDeliverPostLogChecker postLogChecker;
|
|
|
|
// for (Long checkerId : uploadDeliver.getCheckerIdList()) {
|
|
|
|
// postLogChecker = new ProTaskDeliverPostLogChecker();
|
|
|
|
// postLogChecker.setId(snowflake.nextId());
|
|
|
|
// postLogChecker.setDeliverPostLogId(deliverPostLog.getId());
|
|
|
|
// postLogChecker.setCheckerId(checkerId);
|
|
|
|
// postLogCheckerDao.insertSelective(postLogChecker);
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// throw new BaseException(CodeEnum.NOT_CHECKER);
|
|
|
|
// }
|
|
|
|
// //保存wps的文件消息
|
|
|
|
// saveWpsFile(currentUserId, deliverPostLog.getId(), fileInfo);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// //修改交付物状态
|
|
|
|
// ProTaskDeliver deliver = new ProTaskDeliver();
|
|
|
|
// deliver.setId(uploadDeliver.getDeliverId());
|
|
|
|
// deliver.setIsUpload(1);
|
|
|
|
// taskDeliverDao.updateByPrimaryKeySelective(deliver);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// //发送WS信息
|
|
|
|
//
|
|
|
|
// //获取所有接收者的id
|
|
|
|
// List<BaseMessageDto.MessageUser> messageUserList = new ArrayList<>();
|
|
|
|
// BaseMessageDto.MessageUser messageUser;
|
|
|
|
// HashSet<Long> userIdSet = new HashSet<>();
|
|
|
|
// HashSet<String> userIdStr = new HashSet<>();
|
|
|
|
// if (CollectionUtil.isNotEmpty(uploadDeliver.getCheckerIdList())) {
|
|
|
|
// for (Long postLogCheckerId : uploadDeliver.getCheckerIdList()) {
|
|
|
|
// userIdSet.addAll(userService.selectUserIdByRoleId(postLogCheckerId));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// // ws 发送消息
|
|
|
|
// Set<String> userIds = new HashSet<>();
|
|
|
|
// for (Long userId : userIdSet) {
|
|
|
|
// messageUser = new BaseMessageDto.MessageUser();
|
|
|
|
// messageUser.setUserId(userId);
|
|
|
|
// messageUserList.add(messageUser);
|
|
|
|
// userIds.add(userId.toString());
|
|
|
|
// }
|
|
|
|
// Long roleId;
|
|
|
|
// if (role.getName().equals(WebConstant.ROLE_NAME.AllMember.phase)) {
|
|
|
|
// List<ProRole> roleList = proMemberService.selectRolesByUserIdAndProjectId(currentUserId, taskDetail.getProjectId(),null);
|
|
|
|
// roleId = roleList.get(0).getId();
|
|
|
|
// } else {
|
|
|
|
// roleId = taskDetail.getExecutorRole();
|
|
|
|
// }
|
|
|
|
//// DeliverMessageWithUploadDto uploadMessage = new DeliverMessageWithUploadDto(taskDetail.getProjectId(),roleId,taskDetail.getId(),
|
|
|
|
//// taskDeliver.getId(),taskDeliver.getName(),currentUserId,now,uploadDeliver.getFileInfo(),messageUserList);
|
|
|
|
//// log.info("上传交付物:{}",JacksonUtil.beanToJson(uploadMessage));
|
|
|
|
// DeliverMessageWithUploadDto.Data data = new DeliverMessageWithUploadDto.Data();
|
|
|
|
// data.setProjectId(taskDetail.getProjectId());
|
|
|
|
// data.setDeliverId(taskDeliver.getId());
|
|
|
|
// data.setDeliverName(taskDeliver.getName());
|
|
|
|
// data.setRoleId(roleId);
|
|
|
|
// data.setTaskId(taskDetail.getId());
|
|
|
|
// data.setUploader(currentUserId);
|
|
|
|
// data.setUploadTime(now);
|
|
|
|
// data.setFile(uploadDeliver.getFileInfo());
|
|
|
|
// DeliverMessageWithUploadDto uploadMessage = new DeliverMessageWithUploadDto();
|
|
|
|
// uploadMessage.setData(data);
|
|
|
|
//
|
|
|
|
// InMessage inMessage = new InMessage();
|
|
|
|
// inMessage.setToDomain(MessageConstant.DomainType.User);
|
|
|
|
// inMessage.setTos(userIds);
|
|
|
|
// inMessage.setData(JacksonUtil.beanToJson(uploadMessage));
|
|
|
|
// rabbitTemplate.convertAndSend(RabbitMQConfig.MESSAGE_QUEUE_NAME,
|
|
|
|
// JacksonUtil.beanToJson(inMessage) );
|
|
|
|
// //用智能助手发送消息
|
|
|
|
// SysProject project = sysProjectDao.selectByPrimaryKey(taskDetail.getProjectId());
|
|
|
|
// robotService.addDeliverRobotSend(currentUserId,taskDeliver.getName(),subTimeId, project);
|
|
|
|
//
|
|
|
|
// //返回
|
|
|
|
// List<ProjectVo.DeliverInfo> deliverInfoList = taskDeliverDao.selectByDeliverId(uploadDeliver.getDeliverId());
|
|
|
|
// if (CollectionUtil.isNotEmpty(deliverInfoList)) {
|
|
|
|
// deliverInfo = deliverInfoList.get(0);
|
|
|
|
//// deliverInfo.setUrl(WebConstant.TEST_URL_BASE + deliverInfo.getUrl());
|
|
|
|
// deliverInfo.setUrl(PropUtil.imgDomain + "/" + deliverInfo.getUrl());
|
|
|
|
// }
|
|
|
|
// return deliverInfo;
|
|
|
|
// }
|
|
|
|
|
|
|
|
private void saveWpsFile(Long currentUserId, Long deliverLogId, DeliverDto.FileInfo fileInfo) { |
|
|
|
File file = new File(WebConstant.UPLOAD_PATH_BASE + File.separator + fileInfo.getUrl()); |
|
|
|
if(file.exists()) { |
|
|
@ -916,4 +1045,51 @@ public class TaskDeliverService implements ITaskDeliverService { |
|
|
|
file.delete(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据任务id查询输出文档的信息 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<DeliverVo.QueryDeliverByTaskId> queryDeliverByTaskId(Long currentUserId, Long taskId) { |
|
|
|
//查询分解后的任务
|
|
|
|
ProTaskSubTime taskSubTime = taskSubTimeDao.selectByPrimaryKey(taskId); |
|
|
|
if(ObjectUtil.isNull(taskSubTime)){ |
|
|
|
throw new BaseException(CodeEnum.NOT_TASK); |
|
|
|
} |
|
|
|
//查询任务详情
|
|
|
|
ProTaskDetail taskDetail = taskDetailDao.selectByPrimaryKey(taskSubTime.getTaskDetailId()); |
|
|
|
if(ObjectUtil.isNull(taskDetail)){ |
|
|
|
throw new BaseException(CodeEnum.NOT_TASK); |
|
|
|
} |
|
|
|
List<DeliverVo.QueryDeliverByTaskId> queryDeliverByTaskIds = taskDeliverDao.queryDeliverByTaskId(currentUserId, taskSubTime.getId(), taskDetail.getId()); |
|
|
|
if(CollectionUtil.isNotEmpty(queryDeliverByTaskIds)){ |
|
|
|
queryDeliverByTaskIds.forEach(deliver -> { |
|
|
|
if(CollectionUtil.isNotEmpty(deliver.getDeliverRecodes())){ |
|
|
|
deliver.getDeliverRecodes().forEach(deliverRecode -> { |
|
|
|
if(StrUtil.isNotEmpty(deliverRecode.getFilesId())){ |
|
|
|
try { |
|
|
|
//拆分文件id
|
|
|
|
String[] split = deliverRecode.getFilesId().split(","); |
|
|
|
List<String> splits =new ArrayList<>(Arrays.asList(split)); |
|
|
|
if(split.length != 0){ |
|
|
|
//获取文件项目的路径
|
|
|
|
String requestUrl = PropUtil.filedeal; |
|
|
|
//通过文件id查询文件信息
|
|
|
|
String c = RestTemplateUtil.postBody1(requestUrl,splits); |
|
|
|
JsonResponse<List<FileVo.FilePosition>> a = JSONObject.parseObject(c,JsonResponse.class); |
|
|
|
if(ObjectUtil.isNotNull(a) && ObjectUtil.isNotNull(a.getData())){ |
|
|
|
List<FileVo.FilePosition> fileList = a.getData(); |
|
|
|
deliverRecode.setFileList(fileList); |
|
|
|
} |
|
|
|
} |
|
|
|
}catch (Exception e){ |
|
|
|
log.info("查询文件信息失败:{}", e); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return queryDeliverByTaskIds; |
|
|
|
} |
|
|
|
} |
|
|
|