|
@@ -1,216 +0,0 @@
|
|
|
-package org.eco.als.service.impl;
|
|
|
-
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.lang.tree.Tree;
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.mybatisflex.core.query.QueryWrapper;
|
|
|
-import jakarta.annotation.Resource;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.eco.als.domain.Aircraft;
|
|
|
-import org.eco.als.domain.bo.AircraftBo;
|
|
|
-import org.eco.als.domain.vo.AircraftImportVo;
|
|
|
-import org.eco.als.domain.vo.AircraftVo;
|
|
|
-import org.eco.als.listener.AircraftImportListener;
|
|
|
-import org.eco.als.mapper.AircraftMapper;
|
|
|
-import org.eco.als.service.IAircraftService;
|
|
|
-import org.eco.common.core.core.domain.model.LoginUser;
|
|
|
-import org.eco.common.core.service.AircraftService;
|
|
|
-import org.eco.common.core.utils.MapstructUtils;
|
|
|
-import org.eco.common.core.utils.SpringUtils;
|
|
|
-import org.eco.common.core.utils.TreeBuildUtils;
|
|
|
-import org.eco.common.excel.entity.ExcelResultRes;
|
|
|
-import org.eco.common.excel.service.IExcelService;
|
|
|
-import org.eco.common.orm.core.service.impl.BaseServiceImpl;
|
|
|
-import org.eco.system.service.IImportExportService;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import static org.eco.als.domain.table.AircraftTableDef.AIRCRAFT;
|
|
|
-
|
|
|
-/**
|
|
|
- * 机型机号Service业务层处理
|
|
|
- *
|
|
|
- * @author wgk
|
|
|
- * @date 2024-07-19
|
|
|
- */
|
|
|
-@Service
|
|
|
-@Slf4j
|
|
|
-public class AircraftServiceImpl extends BaseServiceImpl<AircraftMapper, Aircraft> implements IAircraftService, AircraftService {
|
|
|
- @Resource
|
|
|
- private AircraftMapper aircraftMapper;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private IExcelService excelService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private IImportExportService importExportService;
|
|
|
-
|
|
|
- @Override
|
|
|
- public QueryWrapper query() {
|
|
|
- return super.query().from(AIRCRAFT);
|
|
|
- }
|
|
|
-
|
|
|
- private QueryWrapper buildQueryWrapper(AircraftBo aircraftBo) {
|
|
|
- QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
|
|
- queryWrapper.and(AIRCRAFT.NAME.like
|
|
|
- (aircraftBo.getName()));
|
|
|
- queryWrapper.orderBy(AIRCRAFT.ORDER_NUM.asc());
|
|
|
-
|
|
|
- return queryWrapper;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询机型机号
|
|
|
- *
|
|
|
- * @param id 机型机号主键
|
|
|
- * @return 机型机号
|
|
|
- */
|
|
|
- @Override
|
|
|
- public AircraftVo selectById(Long id) {
|
|
|
- return this.getOneAs(query().where(AIRCRAFT.ID.eq(id)), AircraftVo.class);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询机型机号
|
|
|
- *
|
|
|
- * @param name 机型机号主键
|
|
|
- * @return 机型机号
|
|
|
- */
|
|
|
- @Override
|
|
|
- public AircraftVo selectByName(String name) {
|
|
|
- return this.getOneAs(query().where(AIRCRAFT.NAME.eq(name)), AircraftVo.class);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询机型机号列表
|
|
|
- *
|
|
|
- * @param aircraftBo 机型机号Bo
|
|
|
- * @return 机型机号集合
|
|
|
- */
|
|
|
- @Override
|
|
|
- public List<AircraftVo> selectList(AircraftBo aircraftBo) {
|
|
|
- QueryWrapper queryWrapper = buildQueryWrapper(aircraftBo);
|
|
|
- return this.listAs(queryWrapper, AircraftVo.class);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<Tree<Long>> selectTree(AircraftBo aircraftBo) {
|
|
|
- List<AircraftVo> list = SpringUtils.getAopProxy(this).selectList(aircraftBo);
|
|
|
- return buildTree(list);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<Tree<Long>> buildTree(List<AircraftVo> aircraftVoList) {
|
|
|
- if (CollUtil.isEmpty(aircraftVoList)) {
|
|
|
- return CollUtil.newArrayList();
|
|
|
- }
|
|
|
- return TreeBuildUtils.build(aircraftVoList, (dept, tree) ->
|
|
|
- tree.setId(dept.getId())
|
|
|
- .setParentId(dept.getParentId())
|
|
|
- .setName(dept.getName())
|
|
|
- .setWeight(dept.getOrderNum()));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增机型机号
|
|
|
- *
|
|
|
- * @param aircraftBo 机型机号Bo
|
|
|
- * @return 结果:true 操作成功,false 操作失败
|
|
|
- */
|
|
|
- @Override
|
|
|
- public boolean insert(AircraftBo aircraftBo) {
|
|
|
- Aircraft aircraft = MapstructUtils.convert(aircraftBo, Aircraft.class);
|
|
|
-
|
|
|
- return this.save(aircraft);//使用全局配置的雪花算法主键生成器生成ID值
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增机型机号,前台提供主键值,一般用于导入的场合
|
|
|
- *
|
|
|
- * @param aircraftBo 机型机号Bo
|
|
|
- * @return 结果:true 操作成功,false 操作失败
|
|
|
- */
|
|
|
- @Override
|
|
|
- public boolean insertWithPk(AircraftBo aircraftBo) {
|
|
|
- Aircraft aircraft = MapstructUtils.convert(aircraftBo, Aircraft.class);
|
|
|
- //获取祖级列表字段
|
|
|
- assert aircraft != null;
|
|
|
- Long parentId = aircraft.getParentId();
|
|
|
- if (parentId == 0) {
|
|
|
- aircraft.setAncestors("0");
|
|
|
- } else {
|
|
|
- AircraftVo parentAircraft = selectById(aircraftBo.getParentId());
|
|
|
- if (ObjectUtil.isNotNull(parentAircraft)) {
|
|
|
- aircraft.setAncestors(parentAircraft.getAncestors() + "," + parentId);
|
|
|
- } else {
|
|
|
- aircraft.setAncestors("0");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return aircraftMapper.insertWithPk(aircraft) > 0;//前台传来主键值
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改机型机号
|
|
|
- *
|
|
|
- * @param aircraftBo 机型机号Bo
|
|
|
- * @return 结果:true 更新成功,false 更新失败
|
|
|
- */
|
|
|
- @Override
|
|
|
- public boolean update(AircraftBo aircraftBo) {
|
|
|
- Aircraft aircraft = MapstructUtils.convert(aircraftBo, Aircraft.class);
|
|
|
- if (ObjectUtil.isNotNull(aircraft) && ObjectUtil.isNotNull(aircraft.getId())) {
|
|
|
- return this.updateById(aircraft);
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void asyncImportData(MultipartFile file, boolean updateSupport, LoginUser loginUser) {
|
|
|
- ExcelResultRes result;
|
|
|
- try {
|
|
|
- String name = file.getOriginalFilename();
|
|
|
- result = excelService.importExcel(file.getInputStream(), name, AircraftImportVo.class, new AircraftImportListener(updateSupport, loginUser));
|
|
|
- } catch (IOException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- boolean flag = importExportService.saveInfo(result, loginUser, "0");
|
|
|
- if (flag) {
|
|
|
- log.info("异步导入日志写入成功");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void asyncExport(List<AircraftVo> listVo, String sheetName, LoginUser loginUser) {
|
|
|
- ExcelResultRes result = excelService.exportExcel(listVo, sheetName, AircraftVo.class);
|
|
|
- boolean flag = importExportService.saveInfo(result, loginUser, "1");
|
|
|
- if (flag) {
|
|
|
- log.info("异步导出日志写入成功");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量删除机型机号
|
|
|
- *
|
|
|
- * @param ids 需要删除的机型机号主键集合
|
|
|
- * @return 结果:true 删除成功,false 删除失败
|
|
|
- */
|
|
|
- @Transactional
|
|
|
- @Override
|
|
|
- public boolean deleteByIds(Long[] ids) {
|
|
|
- return this.removeByIds(Arrays.asList(ids));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public String selectAircraftNoById(Long aircraftId) {
|
|
|
- AircraftVo aircraft = selectById(aircraftId);
|
|
|
- return ObjectUtil.isNull(aircraft) ? null : aircraft.getName();
|
|
|
- }
|
|
|
-}
|