|
|
@ -42,9 +42,7 @@ import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -62,81 +60,122 @@ import java.util.stream.Collectors; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class ProcessCommentService extends MybatisBaseService<ProcessCommentMapper, ProcessComment> { |
|
|
|
@Resource |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Resource |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
private QueryWrapper<ProcessComment> createQueryWrapper(ProcessCommentQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<ProcessComment> qw = new QueryWrapper<>(); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<ProcessCommentVo> listPageVo(PagerQuery<ProcessCommentQuery> pq) { |
|
|
|
ProcessCommentQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ProcessComment> qw = createQueryWrapper(query); |
|
|
|
IPage<ProcessComment> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ProcessCommentVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<ProcessCommentVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(ProcessCommentDto dto){ |
|
|
|
@Resource |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Resource |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
|
|
|
|
private QueryWrapper<ProcessComment> createQueryWrapper(ProcessCommentQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<ProcessComment> qw = new QueryWrapper<>(); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<ProcessCommentVo> listPageVo(PagerQuery<ProcessCommentQuery> pq) { |
|
|
|
ProcessCommentQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ProcessComment> qw = createQueryWrapper(query); |
|
|
|
IPage<ProcessComment> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ProcessCommentVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<ProcessCommentVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(ProcessCommentDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
dto.setSid(UUID.randomUUID().toString()); |
|
|
|
baseMapper.insertByDto(dto); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(ProcessCommentDto dto){ |
|
|
|
ProcessComment entity = new ProcessComment(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(ProcessCommentDto dto){ |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
dto.setSid(UUID.randomUUID().toString()); |
|
|
|
baseMapper.insertByDto(dto); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(ProcessCommentDto dto) { |
|
|
|
ProcessComment entity = new ProcessComment(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(ProcessCommentDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ProcessComment entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public ProcessCommentDetailsVo fetchDetailsVoBySid(String sid){ |
|
|
|
ProcessComment entity = fetchBySid(sid); |
|
|
|
ProcessCommentDetailsVo vo = new ProcessCommentDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
public List<ProcessCommentVo> getCommentList(String processId) { |
|
|
|
List<ProcessCommentVo> commentList = baseMapper.getCommentList(processId); |
|
|
|
for(ProcessCommentVo histIns:commentList){ |
|
|
|
if(StringUtils.isNotBlank(histIns.getProcessFile())){ |
|
|
|
List<String> processFile = Arrays.asList(histIns.getProcessFile().split(",")).stream().map(c -> fileUploadComponent.getUrlPrefix() + c).collect(Collectors.toList()); |
|
|
|
histIns.setFileList(processFile); |
|
|
|
} |
|
|
|
ResultBean<List<SysUserVo>> sysUserVoResultBean = sysUserFeign.fetchBySids(histIns.getReviewerSid());// sysUserService.selectUserById(Long.parseLong(histIns.getAssignee()));
|
|
|
|
List<SysUserVo> data1 = sysUserVoResultBean.getData(); |
|
|
|
for( SysUserVo data:data1){ |
|
|
|
AppUserVo taskUserInfo=new AppUserVo(); |
|
|
|
taskUserInfo.setAssigneeName(data.getName()); |
|
|
|
if(!com.yxt.common.base.utils.StringUtils.isBlank(data.getHeadImage())){ |
|
|
|
taskUserInfo.setAssigneeHeadImage(fileUploadComponent.getUrlPrefix() +data.getHeadImage()); |
|
|
|
} |
|
|
|
histIns.setTaskUserInfo(taskUserInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
return commentList; |
|
|
|
} |
|
|
|
|
|
|
|
public List<String> selectByIdAndComment(String comment, String instanceId) { |
|
|
|
return baseMapper.selectByIdAndComment(comment, instanceId); |
|
|
|
} |
|
|
|
} |
|
|
|
ProcessComment entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public ProcessCommentDetailsVo fetchDetailsVoBySid(String sid) { |
|
|
|
ProcessComment entity = fetchBySid(sid); |
|
|
|
ProcessCommentDetailsVo vo = new ProcessCommentDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
public List<ProcessCommentVo> getCommentList(String processId) { |
|
|
|
List<ProcessCommentVo> commentList = baseMapper.getCommentList(processId); |
|
|
|
// 2. 获取所有 reviewerSid 批量查询用户信息
|
|
|
|
Set<String> reviewerSids = commentList.stream() |
|
|
|
.filter(c -> StringUtils.isNotBlank(c.getReviewerSid())) |
|
|
|
.map(ProcessCommentVo::getReviewerSid) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
// 批量查询所有评论中的 reviewerSid 对应的用户信息
|
|
|
|
Map<String, SysUserVo> userMap = new HashMap<>(); |
|
|
|
// 将 Set<String> 转换为以逗号分隔的字符串
|
|
|
|
String assigneeIdsStr = String.join(",", reviewerSids); |
|
|
|
if (StringUtils.isNotBlank(assigneeIdsStr)) { |
|
|
|
userMap = sysUserFeign.fetchBySids(assigneeIdsStr).getData().stream() |
|
|
|
.collect(Collectors.toMap(SysUserVo::getSid, user -> user)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 3. 遍历 commentList,填充文件列表和用户信息
|
|
|
|
for (ProcessCommentVo histIns : commentList) { |
|
|
|
// 处理文件列表
|
|
|
|
if (StringUtils.isNotBlank(histIns.getProcessFile())) { |
|
|
|
List<String> processFile = Arrays.asList(histIns.getProcessFile().split(",")).stream().map(c -> fileUploadComponent.getUrlPrefix() + c).collect(Collectors.toList()); |
|
|
|
histIns.setFileList(processFile); |
|
|
|
} |
|
|
|
|
|
|
|
// 处理用户信息
|
|
|
|
SysUserVo user = userMap.get(histIns.getReviewerSid()); |
|
|
|
if (user != null) { |
|
|
|
AppUserVo taskUserInfo = new AppUserVo(); |
|
|
|
taskUserInfo.setAssigneeName(user.getName()); |
|
|
|
if (StringUtils.isNotBlank(user.getHeadImage())) { |
|
|
|
taskUserInfo.setAssigneeHeadImage(fileUploadComponent.getUrlPrefix() + user.getHeadImage()); |
|
|
|
} |
|
|
|
histIns.setTaskUserInfo(taskUserInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return commentList; |
|
|
|
} |
|
|
|
|
|
|
|
public List<ProcessCommentVo> getCommentListOld(String processId) { |
|
|
|
List<ProcessCommentVo> commentList = baseMapper.getCommentList(processId); |
|
|
|
for (ProcessCommentVo histIns : commentList) { |
|
|
|
if (StringUtils.isNotBlank(histIns.getProcessFile())) { |
|
|
|
List<String> processFile = Arrays.asList(histIns.getProcessFile().split(",")).stream().map(c -> fileUploadComponent.getUrlPrefix() + c).collect(Collectors.toList()); |
|
|
|
histIns.setFileList(processFile); |
|
|
|
} |
|
|
|
ResultBean<List<SysUserVo>> sysUserVoResultBean = sysUserFeign.fetchBySids(histIns.getReviewerSid());// sysUserService.selectUserById(Long.parseLong(histIns.getAssignee()));
|
|
|
|
List<SysUserVo> data1 = sysUserVoResultBean.getData(); |
|
|
|
for (SysUserVo data : data1) { |
|
|
|
AppUserVo taskUserInfo = new AppUserVo(); |
|
|
|
taskUserInfo.setAssigneeName(data.getName()); |
|
|
|
if (!com.yxt.common.base.utils.StringUtils.isBlank(data.getHeadImage())) { |
|
|
|
taskUserInfo.setAssigneeHeadImage(fileUploadComponent.getUrlPrefix() + data.getHeadImage()); |
|
|
|
} |
|
|
|
histIns.setTaskUserInfo(taskUserInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
return commentList; |
|
|
|
} |
|
|
|
|
|
|
|
public List<String> selectByIdAndComment(String comment, String instanceId) { |
|
|
|
return baseMapper.selectByIdAndComment(comment, instanceId); |
|
|
|
} |
|
|
|
} |