|
@@ -1,35 +1,37 @@
|
|
|
package org.eco.als.service.impl;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.mybatisflex.core.paginate.Page;
|
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.dromara.easyes.core.biz.EsPageInfo;
|
|
|
+import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
|
|
|
+import org.eco.als.domain.FaultCase;
|
|
|
+import org.eco.als.domain.bo.FaultCaseBo;
|
|
|
+import org.eco.als.domain.vo.FaultCaseImportVo;
|
|
|
+import org.eco.als.domain.vo.FaultCaseVo;
|
|
|
+import org.eco.als.es.mapper.EsFaultCaseMapper;
|
|
|
+import org.eco.als.listener.FaultCaseImportListener;
|
|
|
+import org.eco.als.mapper.FaultCaseMapper;
|
|
|
+import org.eco.als.service.IFaultCaseService;
|
|
|
import org.eco.common.core.core.domain.model.LoginUser;
|
|
|
+import org.eco.common.core.core.page.PageResult;
|
|
|
+import org.eco.common.core.utils.MapstructUtils;
|
|
|
import org.eco.common.excel.entity.ExcelResultRes;
|
|
|
import org.eco.common.excel.service.IExcelService;
|
|
|
-import org.eco.common.core.utils.bean.BeanUtils;
|
|
|
-import org.eco.common.core.utils.MapstructUtils;
|
|
|
-import org.eco.system.service.IImportExportService;
|
|
|
-import org.eco.common.core.utils.StringUtils;
|
|
|
-import org.eco.system.domain.bo.ImportExportBo;
|
|
|
import org.eco.common.orm.core.page.PageQuery;
|
|
|
-import org.eco.common.core.core.page.PageResult;
|
|
|
import org.eco.common.orm.core.service.impl.BaseServiceImpl;
|
|
|
-import jakarta.annotation.Resource;
|
|
|
+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 org.eco.als.mapper.FaultCaseMapper;
|
|
|
-import org.eco.als.domain.FaultCase;
|
|
|
-import org.eco.als.domain.bo.FaultCaseBo;
|
|
|
-import org.eco.als.domain.vo.FaultCaseVo;
|
|
|
-import org.eco.als.domain.vo.FaultCaseImportVo;
|
|
|
-import org.eco.als.listener.FaultCaseImportListener;
|
|
|
-import org.eco.als.service.IFaultCaseService;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
import static org.eco.als.domain.table.FaultCaseTableDef.FAULT_CASE;
|
|
|
|
|
|
/**
|
|
@@ -43,6 +45,8 @@ import static org.eco.als.domain.table.FaultCaseTableDef.FAULT_CASE;
|
|
|
public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, FaultCase> implements IFaultCaseService {
|
|
|
@Resource
|
|
|
private FaultCaseMapper faultCaseMapper;
|
|
|
+ @Resource
|
|
|
+ private EsFaultCaseMapper esFaultCaseMapper;
|
|
|
|
|
|
@Resource
|
|
|
private IExcelService excelService;
|
|
@@ -58,33 +62,33 @@ public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, Fault
|
|
|
private QueryWrapper buildQueryWrapper(FaultCaseBo faultCaseBo) {
|
|
|
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
|
|
queryWrapper.and(FAULT_CASE.AIRCRAFT_TYPE_ID.eq
|
|
|
- (faultCaseBo.getAircraftTypeId()));
|
|
|
+ (faultCaseBo.getAircraftTypeId()));
|
|
|
queryWrapper.and(FAULT_CASE.AIRCRAFT_TYPE_NAME.like
|
|
|
- (faultCaseBo.getAircraftTypeName()));
|
|
|
+ (faultCaseBo.getAircraftTypeName()));
|
|
|
queryWrapper.and(FAULT_CASE.AIRCRAFT_SYSTEM_ID.eq
|
|
|
- (faultCaseBo.getAircraftSystemId()));
|
|
|
+ (faultCaseBo.getAircraftSystemId()));
|
|
|
queryWrapper.and(FAULT_CASE.AIRCRAFT_SYSTEM_NAME.like
|
|
|
- (faultCaseBo.getAircraftSystemName()));
|
|
|
+ (faultCaseBo.getAircraftSystemName()));
|
|
|
queryWrapper.and(FAULT_CASE.AIRCRAFT_SUBSYSTEM_ID.eq
|
|
|
- (faultCaseBo.getAircraftSubsystemId()));
|
|
|
+ (faultCaseBo.getAircraftSubsystemId()));
|
|
|
queryWrapper.and(FAULT_CASE.AIRCRAFT_SUBSYSTEM_NAME.like
|
|
|
- (faultCaseBo.getAircraftSubsystemName()));
|
|
|
+ (faultCaseBo.getAircraftSubsystemName()));
|
|
|
queryWrapper.and(FAULT_CASE.AUTHOR.eq
|
|
|
- (faultCaseBo.getAuthor()));
|
|
|
+ (faultCaseBo.getAuthor()));
|
|
|
queryWrapper.and(FAULT_CASE.FAULT_PHENOMENON.eq
|
|
|
- (faultCaseBo.getFaultPhenomenon()));
|
|
|
+ (faultCaseBo.getFaultPhenomenon()));
|
|
|
queryWrapper.and(FAULT_CASE.FAULT_CAUSE.eq
|
|
|
- (faultCaseBo.getFaultCause()));
|
|
|
+ (faultCaseBo.getFaultCause()));
|
|
|
queryWrapper.and(FAULT_CASE.FAULT_TREE_PATH.eq
|
|
|
- (faultCaseBo.getFaultTreePath()));
|
|
|
+ (faultCaseBo.getFaultTreePath()));
|
|
|
queryWrapper.and(FAULT_CASE.FAULT_PICTURE_PATH.eq
|
|
|
- (faultCaseBo.getFaultPicturePath()));
|
|
|
+ (faultCaseBo.getFaultPicturePath()));
|
|
|
queryWrapper.and(FAULT_CASE.TROUBLESHOOTING_METHOD_PATH.eq
|
|
|
- (faultCaseBo.getTroubleshootingMethodPath()));
|
|
|
+ (faultCaseBo.getTroubleshootingMethodPath()));
|
|
|
queryWrapper.and(FAULT_CASE.VIEW_COUNT.eq
|
|
|
- (faultCaseBo.getViewCount()));
|
|
|
+ (faultCaseBo.getViewCount()));
|
|
|
queryWrapper.and(FAULT_CASE.ORDER_BY.eq
|
|
|
- (faultCaseBo.getOrderBy()));
|
|
|
+ (faultCaseBo.getOrderBy()));
|
|
|
|
|
|
return queryWrapper;
|
|
|
}
|
|
@@ -97,7 +101,7 @@ public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, Fault
|
|
|
*/
|
|
|
@Override
|
|
|
public FaultCaseVo selectById(Long id) {
|
|
|
- return this.getOneAs(query().where(FAULT_CASE.ID.eq(id)), FaultCaseVo.class);
|
|
|
+ return this.getOneAs(query().where(FAULT_CASE.ID.eq(id)), FaultCaseVo.class);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -111,7 +115,7 @@ public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, Fault
|
|
|
@Override
|
|
|
public List<FaultCaseVo> selectList(FaultCaseBo faultCaseBo) {
|
|
|
QueryWrapper queryWrapper = buildQueryWrapper(faultCaseBo);
|
|
|
- return this.listAs(queryWrapper, FaultCaseVo.class);
|
|
|
+ return this.listAs(queryWrapper, FaultCaseVo.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -123,10 +127,32 @@ public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, Fault
|
|
|
@Override
|
|
|
public PageResult<FaultCaseVo> selectPage(FaultCaseBo faultCaseBo) {
|
|
|
QueryWrapper queryWrapper = buildQueryWrapper(faultCaseBo);
|
|
|
- Page<FaultCaseVo> page = this.pageAs(PageQuery.build(), queryWrapper, FaultCaseVo.class);
|
|
|
+ Page<FaultCaseVo> page = this.pageAs(PageQuery.build(), queryWrapper, FaultCaseVo.class);
|
|
|
return PageResult.build(page);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public EsPageInfo<FaultCase> selectEsPage(FaultCaseBo faultCaseBo) {
|
|
|
+ LambdaEsQueryWrapper<FaultCase> wrapper = new LambdaEsQueryWrapper<>();
|
|
|
+ wrapper.match(StrUtil.isNotBlank(faultCaseBo.getFaultPhenomenon()), "pContent", faultCaseBo.getFaultPhenomenon(), 5.0f)
|
|
|
+ .or()
|
|
|
+ .match(StrUtil.isNotBlank(faultCaseBo.getFaultPhenomenon()), "fContent", faultCaseBo.getFaultPhenomenon(), 5.0f);
|
|
|
+ if (StrUtil.equals(faultCaseBo.getOrderBy(), "createTimeAsc")) {
|
|
|
+ wrapper.orderByAsc("createTime");
|
|
|
+ } else if (StrUtil.equals(faultCaseBo.getOrderBy(), "createTimeDesc")) {
|
|
|
+ wrapper.orderByDesc("createTime");
|
|
|
+ } else if (StrUtil.equals(faultCaseBo.getOrderBy(), "countAsc")) {
|
|
|
+ wrapper.orderByAsc("viewCount");
|
|
|
+ } else if (StrUtil.equals(faultCaseBo.getOrderBy(), "countDesc")) {
|
|
|
+ wrapper.orderByDesc("viewCount");
|
|
|
+ }
|
|
|
+ if (!esFaultCaseMapper.existsIndex("fault_case_index")) {
|
|
|
+ esFaultCaseMapper.createIndex();
|
|
|
+ }
|
|
|
+ Page page = PageQuery.build();
|
|
|
+ return esFaultCaseMapper.pageQuery(wrapper, (int) page.getPageNumber(), (int) page.getPageSize());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新增故障案例
|
|
|
*
|
|
@@ -135,8 +161,8 @@ public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, Fault
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean insert(FaultCaseBo faultCaseBo) {
|
|
|
- FaultCase faultCase =MapstructUtils.convert(faultCaseBo, FaultCase. class);
|
|
|
-
|
|
|
+ FaultCase faultCase = MapstructUtils.convert(faultCaseBo, FaultCase.class);
|
|
|
+ esFaultCaseMapper.insert(faultCase);
|
|
|
return this.save(faultCase);//使用全局配置的雪花算法主键生成器生成ID值
|
|
|
}
|
|
|
|
|
@@ -147,12 +173,11 @@ public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, Fault
|
|
|
* @return 结果:true 操作成功,false 操作失败
|
|
|
*/
|
|
|
@Override
|
|
|
- public boolean insertWithPk(FaultCaseBo faultCaseBo)
|
|
|
- {
|
|
|
+ public boolean insertWithPk(FaultCaseBo faultCaseBo) {
|
|
|
FaultCase faultCase = MapstructUtils.convert(faultCaseBo, FaultCase.class);
|
|
|
|
|
|
|
|
|
- return faultCaseMapper.insertWithPk(faultCase) > 0;//前台传来主键值
|
|
|
+ return faultCaseMapper.insertWithPk(faultCase) > 0;//前台传来主键值
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -163,10 +188,10 @@ public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, Fault
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean update(FaultCaseBo faultCaseBo) {
|
|
|
- FaultCase faultCase =MapstructUtils.convert(faultCaseBo, FaultCase. class);
|
|
|
- if (ObjectUtil.isNotNull(faultCase) && ObjectUtil.isNotNull(faultCase.getId())){
|
|
|
- boolean updated = this.updateById(faultCase);
|
|
|
- return updated;
|
|
|
+ FaultCase faultCase = MapstructUtils.convert(faultCaseBo, FaultCase.class);
|
|
|
+ if (ObjectUtil.isNotNull(faultCase) && ObjectUtil.isNotNull(faultCase.getId())) {
|
|
|
+ esFaultCaseMapper.updateById(faultCase);
|
|
|
+ return this.updateById(faultCase);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
@@ -204,6 +229,7 @@ public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, Fault
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public boolean deleteByIds(Long[] ids) {
|
|
|
+ esFaultCaseMapper.deleteBatchIds(Arrays.asList(ids));
|
|
|
return this.removeByIds(Arrays.asList(ids));
|
|
|
}
|
|
|
|