| | |
| | | package com.aps.core.service.impl; |
| | | |
| | | import java.util.List; |
| | | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.aps.common.core.utils.DateUtils; |
| | | import com.aps.common.security.utils.SecurityUtils; |
| | | import com.aps.core.domain.ApsPlanCycle; |
| | | import com.aps.core.domain.ApsPlanManagement; |
| | | import com.aps.core.mapper.ApsPlanCycleMapper; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 计划管理Service业务层处理 |
| | |
| | | */ |
| | | @Override |
| | | public List<ApsPlanManagement> selectApsPlanManagementList(ApsPlanManagement apsPlanManagement) { |
| | | return apsPlanManagementMapper.selectApsPlanManagementList(apsPlanManagement); |
| | | List<ApsPlanManagement> items = apsPlanManagementMapper.selectApsPlanManagementList(apsPlanManagement); |
| | | List<ApsPlanCycle> cycles = apsPlanCycleMapper.selectByPlanIds(items.stream().map(ApsPlanManagement::getId).toList()); |
| | | cycles.forEach(cycle -> { |
| | | for (ApsPlanManagement item : items) { |
| | | if (Objects.equals(item.getId(), cycle.getPlanId())) { |
| | | item.setCycle(cycle); |
| | | break; |
| | | } |
| | | } |
| | | }); |
| | | return items; |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public int insertApsPlanManagement(ApsPlanManagement apsPlanManagement) { |
| | | apsPlanManagement.setCreateTime(DateUtils.getNowDate()); |
| | | apsPlanManagement.setCreateBy(SecurityUtils.getUsername()); |
| | | apsPlanManagement.setId(IdUtil.getSnowflakeNextId()); |
| | | return apsPlanManagementMapper.insertApsPlanManagement(apsPlanManagement); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public int updateApsPlanManagement(ApsPlanManagement apsPlanManagement) { |
| | | apsPlanManagement.setUpdateTime(DateUtils.getNowDate()); |
| | | apsPlanManagement.setUpdateBy(SecurityUtils.getUsername()); |
| | | return apsPlanManagementMapper.updateApsPlanManagement(apsPlanManagement); |
| | | } |
| | | |
| | |
| | | public void updateApsPlanCycle(ApsPlanCycle apsPlanCycle) { |
| | | ApsPlanCycle planCycle = apsPlanCycleMapper.selectByPlanId(apsPlanCycle.getPlanId()); |
| | | if (planCycle == null) { |
| | | apsPlanCycle.setCreateBy(SecurityUtils.getUsername()); |
| | | apsPlanCycle.setCreateTime(DateUtils.getNowDate()); |
| | | apsPlanCycle.setId(IdUtil.getSnowflakeNextId()); |
| | | apsPlanCycleMapper.insert(apsPlanCycle); |
| | | } else { |
| | | BeanUtils.copyProperties(apsPlanCycle, planCycle, "id", "planId"); |
| | | planCycle.setUpdateBy(SecurityUtils.getUsername()); |
| | | planCycle.setUpdateTime(DateUtils.getNowDate()); |
| | | apsPlanCycleMapper.updateById(planCycle); |
| | | } |
| | | } |