package com.ruoyi.projectManagement.service.impl;
|
|
import cn.hutool.core.bean.BeanUtil;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.ruoyi.basic.service.CustomerFollowUpFileService;
|
import com.ruoyi.projectManagement.mapper.PlanMapper;
|
import com.ruoyi.projectManagement.pojo.Plan;
|
import com.ruoyi.projectManagement.service.PlanService;
|
import com.ruoyi.projectManagement.vo.PlanVo;
|
import com.ruoyi.projectManagement.vo.SavePlanVo;
|
import com.ruoyi.projectManagement.vo.SearchPlanVo;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.Collections;
|
import java.util.Optional;
|
|
/**
|
* @author buhuazhen
|
* @description 项目管理计划的实现
|
* @createDate 2026-03-06 15:29:26
|
*/
|
@Service
|
@RequiredArgsConstructor
|
@Transactional(readOnly = true)
|
public class PlanServiceImpl implements PlanService {
|
|
private final PlanMapper planMapper;
|
|
private final CustomerFollowUpFileService customerFollowUpFileService;
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void savePlan(SavePlanVo savePlanVo) {
|
Plan plan = BeanUtil.copyProperties(savePlanVo, Plan.class);
|
// 附件处理 , 拼接
|
String attachments = String.join(",", Optional.ofNullable(savePlanVo.getAttachmentIds()).orElse(Collections.emptyList()));
|
plan.setAttachment(attachments);
|
|
|
if (savePlanVo.getId() == null) {
|
planMapper.insert(plan);
|
} else {
|
planMapper.updateById(plan);
|
}
|
|
// todo@ 节点保存
|
|
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void deletePlan(Long id) {
|
planMapper.update(null,
|
new LambdaUpdateWrapper<Plan>()
|
.eq(Plan::getId, id)
|
.set(Plan::getIsDelete, 1));
|
// todo@ 对应节点全部删除
|
|
|
}
|
|
@Override
|
public IPage<PlanVo> searchPlan(SearchPlanVo searchPlanVo) {
|
IPage<Plan> planIPage = planMapper.selectPlanPage(searchPlanVo);
|
IPage<PlanVo> resultPage = planIPage.convert(plan -> BeanUtil.copyProperties(plan, PlanVo.class));
|
// 文件获取
|
customerFollowUpFileService.fillAttachment(resultPage.getRecords(), PlanVo::getAttachment, PlanVo::setAttachmentList);
|
// todo@ node 节点获取
|
|
return resultPage;
|
}
|
|
}
|