| | |
| | | package com.ycl.platform.service.impl; |
| | | |
| | | import com.ycl.platform.base.BaseSelect; |
| | | import com.ycl.platform.domain.entity.CheckTemplate; |
| | | import com.ycl.platform.domain.query.CheckTemplateQuery; |
| | | import com.ycl.platform.mapper.CheckTemplateMapper; |
| | | import com.ycl.platform.service.ICheckTemplateService; |
| | | import com.ycl.system.Result; |
| | | import com.ycl.system.entity.SysDept; |
| | | import com.ycl.system.service.ISysDeptService; |
| | | import io.jsonwebtoken.lang.Collections; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.stereotype.Service; |
| | | import utils.DateUtils; |
| | | import utils.StringUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 考核模板Service业务层处理 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | * @date 2024-04-01 |
| | | */ |
| | | @Service |
| | | public class CheckTemplateServiceImpl implements ICheckTemplateService |
| | | { |
| | | public class CheckTemplateServiceImpl implements ICheckTemplateService { |
| | | @Autowired |
| | | private CheckTemplateMapper checkTemplateMapper; |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | |
| | | /** |
| | | * 查询考核模板 |
| | | * |
| | | * |
| | | * @param id 考核模板主键 |
| | | * @return 考核模板 |
| | | */ |
| | | @Override |
| | | public CheckTemplate selectCheckTemplateById(Long id) |
| | | { |
| | | return checkTemplateMapper.selectCheckTemplateById(id); |
| | | public CheckTemplateQuery selectCheckTemplateById(Long id) { |
| | | CheckTemplate checkTemplate = checkTemplateMapper.selectCheckTemplateById(id); |
| | | CheckTemplateQuery checkTemplateQuery = new CheckTemplateQuery(); |
| | | BeanUtils.copyProperties(checkTemplate,checkTemplateQuery); |
| | | String deptId = checkTemplate.getDeptId(); |
| | | String deptIdStr = deptId.substring(1, deptId.length() - 1); |
| | | List<Integer> deptIds = Arrays.stream(deptIdStr.split(",")) |
| | | .mapToInt(Integer::parseInt) |
| | | .boxed().collect(Collectors.toList()); |
| | | checkTemplateQuery.setDeptId(deptIds); |
| | | return checkTemplateQuery; |
| | | } |
| | | |
| | | /** |
| | | * 查询考核模板列表 |
| | | * |
| | | * @param checkTemplate 考核模板 |
| | | * |
| | | * @param checkTemplateDTO 考核模板 |
| | | * @return 考核模板 |
| | | */ |
| | | @Override |
| | | public List<CheckTemplate> selectCheckTemplateList(CheckTemplate checkTemplate) |
| | | { |
| | | return checkTemplateMapper.selectCheckTemplateList(checkTemplate); |
| | | public List<CheckTemplate> selectCheckTemplateList(CheckTemplateQuery checkTemplateDTO) { |
| | | List<CheckTemplate> checkTemplates = checkTemplateMapper.selectCheckTemplateList(checkTemplateDTO); |
| | | //部门区域下拉列表 |
| | | Result all = deptService.pullList(); |
| | | List<BaseSelect> data = (List<BaseSelect>) all.get("data"); |
| | | //翻译部门id |
| | | for (CheckTemplate template : checkTemplates) { |
| | | if(template.getDeptId() == null)continue; |
| | | String[] deptIds = template.getDeptId().replace("[", "").replace("]", "").split(","); |
| | | List<String> deptName = new ArrayList<>(); |
| | | for (String deptId : deptIds) { |
| | | List<String> deptStr = data.stream() |
| | | .filter(baseSelect -> baseSelect.getId().equals(Integer.parseInt(deptId))) |
| | | .map(BaseSelect::getValue) |
| | | .collect(Collectors.toList()); |
| | | deptName.addAll(deptStr); |
| | | } |
| | | template.setDeptId(StringUtils.join(deptName,",")); |
| | | } |
| | | |
| | | return checkTemplates; |
| | | } |
| | | |
| | | /** |
| | | * 新增考核模板 |
| | | * |
| | | * @param checkTemplate 考核模板 |
| | | * |
| | | * @param checkTemplateDTO 考核模板 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertCheckTemplate(CheckTemplate checkTemplate) |
| | | { |
| | | checkTemplate.setCreateTime(DateUtils.getNowDate()); |
| | | public int insertCheckTemplate(CheckTemplateQuery checkTemplateDTO) { |
| | | checkTemplateDTO.setCreateTime(DateUtils.getNowDate()); |
| | | CheckTemplate checkTemplate = new CheckTemplate(); |
| | | BeanUtils.copyProperties(checkTemplateDTO,checkTemplate); |
| | | checkTemplate.setDeptId(checkTemplateDTO.getDeptId().toString().replaceAll(" ","")); |
| | | return checkTemplateMapper.insertCheckTemplate(checkTemplate); |
| | | } |
| | | |
| | | /** |
| | | * 修改考核模板 |
| | | * |
| | | * |
| | | * @param checkTemplate 考核模板 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateCheckTemplate(CheckTemplate checkTemplate) |
| | | { |
| | | public int updateCheckTemplate(CheckTemplate checkTemplate) { |
| | | checkTemplate.setUpdateTime(DateUtils.getNowDate()); |
| | | return checkTemplateMapper.updateCheckTemplate(checkTemplate); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除考核模板 |
| | | * |
| | | * |
| | | * @param ids 需要删除的考核模板主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteCheckTemplateByIds(Long[] ids) |
| | | { |
| | | public int deleteCheckTemplateByIds(Long[] ids) { |
| | | return checkTemplateMapper.deleteCheckTemplateByIds(ids); |
| | | } |
| | | |
| | | /** |
| | | * 删除考核模板信息 |
| | | * |
| | | * |
| | | * @param id 考核模板主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteCheckTemplateById(Long id) |
| | | { |
| | | public int deleteCheckTemplateById(Long id) { |
| | | return checkTemplateMapper.deleteCheckTemplateById(id); |
| | | } |
| | | |
| | | @Override |
| | | public Result pullList() { |
| | | List<CheckTemplate> checkTemplates = checkTemplateMapper.selectCheckTemplateList(new CheckTemplateQuery()); |
| | | |
| | | return Result.ok().data(checkTemplates); |
| | | } |
| | | } |