|
@@ -0,0 +1,191 @@
|
|
|
+package com.taais.biz.service.impl;
|
|
|
+
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.mybatisflex.core.paginate.Page;
|
|
|
+import com.mybatisflex.core.query.QueryWrapper;
|
|
|
+import com.taais.biz.domain.ToInfrared;
|
|
|
+import com.taais.biz.domain.Video2image;
|
|
|
+import com.taais.biz.domain.bo.ToInfraredBo;
|
|
|
+import com.taais.biz.domain.vo.ToInfraredVo;
|
|
|
+import com.taais.biz.mapper.ToInfraredMapper;
|
|
|
+import com.taais.biz.service.IToInfraredService;
|
|
|
+import com.taais.common.core.config.TaaisConfig;
|
|
|
+import com.taais.common.core.constant.Constants;
|
|
|
+import com.taais.common.core.utils.MapstructUtils;
|
|
|
+import com.taais.common.core.utils.StringUtils;
|
|
|
+import com.taais.common.orm.core.page.PageQuery;
|
|
|
+import com.taais.common.core.core.page.PageResult;
|
|
|
+import com.taais.common.orm.core.service.impl.BaseServiceImpl;
|
|
|
+import com.taais.system.domain.vo.SysOssVo;
|
|
|
+import com.taais.system.service.ISysOssService;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
|
|
|
+import static com.taais.biz.domain.table.ToInfraredTableDef.TO_INFRARED;
|
|
|
+import static com.taais.biz.service.impl.VideoStableServiceImpl.removeFileExtension;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 可见光转红外Service业务层处理
|
|
|
+ *
|
|
|
+ * @author 0
|
|
|
+ * 2024-09-20
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToInfrared> implements IToInfraredService {
|
|
|
+ @Autowired
|
|
|
+ private ISysOssService ossService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ToInfraredMapper toInfraredMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public QueryWrapper query() {
|
|
|
+ return super.query().from(TO_INFRARED);
|
|
|
+ }
|
|
|
+
|
|
|
+ private QueryWrapper buildQueryWrapper(ToInfraredBo toInfraredBo) {
|
|
|
+ QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
|
|
+ queryWrapper.and(TO_INFRARED.NAME.like
|
|
|
+ (toInfraredBo.getName()));
|
|
|
+ queryWrapper.and(TO_INFRARED.STATUS.eq
|
|
|
+ (toInfraredBo.getStatus()));
|
|
|
+ queryWrapper.and(TO_INFRARED.START_TIME.eq
|
|
|
+ (toInfraredBo.getStartTime()));
|
|
|
+ queryWrapper.and(TO_INFRARED.END_TIME.eq
|
|
|
+ (toInfraredBo.getEndTime()));
|
|
|
+ queryWrapper.and(TO_INFRARED.COST_SECOND.eq
|
|
|
+ (toInfraredBo.getCostSecond()));
|
|
|
+ queryWrapper.and(TO_INFRARED.LOG.eq
|
|
|
+ (toInfraredBo.getLog()));
|
|
|
+ queryWrapper.and(TO_INFRARED.REMARKS.eq
|
|
|
+ (toInfraredBo.getRemarks()));
|
|
|
+ queryWrapper.and(TO_INFRARED.URL.eq
|
|
|
+ (toInfraredBo.getUrl()));
|
|
|
+ queryWrapper.and(TO_INFRARED.INPUT_OSS_ID.eq
|
|
|
+ (toInfraredBo.getInputOssId()));
|
|
|
+ queryWrapper.and(TO_INFRARED.INPUT_PATH.eq
|
|
|
+ (toInfraredBo.getInputPath()));
|
|
|
+ queryWrapper.and(TO_INFRARED.OUTPUT_PATH.eq
|
|
|
+ (toInfraredBo.getOutputPath()));
|
|
|
+
|
|
|
+ return queryWrapper;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询可见光转红外
|
|
|
+ *
|
|
|
+ * @param id 可见光转红外主键
|
|
|
+ * @return 可见光转红外
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ToInfraredVo selectById(Long id) {
|
|
|
+ return this.getOneAs(query().where(TO_INFRARED.ID.eq(id)), ToInfraredVo.class);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询可见光转红外列表
|
|
|
+ *
|
|
|
+ * @param toInfraredBo 可见光转红外Bo
|
|
|
+ * @return 可见光转红外集合
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ToInfraredVo> selectList(ToInfraredBo toInfraredBo) {
|
|
|
+ QueryWrapper queryWrapper = buildQueryWrapper(toInfraredBo);
|
|
|
+ return this.listAs(queryWrapper, ToInfraredVo.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询可见光转红外列表
|
|
|
+ *
|
|
|
+ * @param toInfraredBo 可见光转红外Bo
|
|
|
+ * @return 分页可见光转红外集合
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public PageResult<ToInfraredVo> selectPage(ToInfraredBo toInfraredBo) {
|
|
|
+ QueryWrapper queryWrapper = buildQueryWrapper(toInfraredBo);
|
|
|
+ Page<ToInfraredVo> page = this.pageAs(PageQuery.build(), queryWrapper, ToInfraredVo.class);
|
|
|
+ return PageResult.build(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增可见光转红外
|
|
|
+ *
|
|
|
+ * @param toInfraredBo 可见光转红外Bo
|
|
|
+ * @return 结果:true 操作成功,false 操作失败
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public boolean insert(ToInfraredBo toInfraredBo) {
|
|
|
+ // 检查input_oss_id是否存在
|
|
|
+ if (ObjectUtil.isNull(toInfraredBo.getInputOssId())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ SysOssVo ossEntity = ossService.getById(toInfraredBo.getInputOssId());
|
|
|
+ if (ObjectUtil.isNull(ossEntity)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ ToInfrared toInfrared = new ToInfrared();
|
|
|
+
|
|
|
+ toInfrared.setInputOssId(toInfraredBo.getInputOssId());
|
|
|
+ toInfrared.setUrl(ossEntity.getUrl());
|
|
|
+
|
|
|
+ String filePath = ossEntity.getFileName();
|
|
|
+ String localPath = TaaisConfig.getProfile();
|
|
|
+ String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
+ toInfrared.setInputPath(resourcePath);
|
|
|
+
|
|
|
+ String fileName = StringUtils.substringAfterLast(filePath, "/");
|
|
|
+ String fileName_without_suffix = removeFileExtension(fileName);
|
|
|
+
|
|
|
+ Path path = Paths.get(resourcePath);
|
|
|
+ Path outPath = path.resolveSibling(fileName_without_suffix + "_images" + System.currentTimeMillis());
|
|
|
+ toInfrared.setOutputPath(outPath.toString());
|
|
|
+
|
|
|
+ toInfrared.setZipFilePath(path.resolveSibling(fileName_without_suffix + ".zip").toString());
|
|
|
+
|
|
|
+ toInfrared.setName(toInfraredBo.getName());
|
|
|
+ toInfrared.setStatus(NOT_START);
|
|
|
+ toInfrared.setRemarks(toInfraredBo.getRemarks());
|
|
|
+
|
|
|
+ return this.save(toInfrared);// 使用全局配置的雪花算法主键生成器生成ID值
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改可见光转红外
|
|
|
+ *
|
|
|
+ * @param toInfraredBo 可见光转红外Bo
|
|
|
+ * @return 结果:true 更新成功,false 更新失败
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public boolean update(ToInfraredBo toInfraredBo) {
|
|
|
+ ToInfrared toInfrared = MapstructUtils.convert(toInfraredBo, ToInfrared.class);
|
|
|
+ if (ObjectUtil.isNotNull(toInfrared) && ObjectUtil.isNotNull(toInfrared.getId())) {
|
|
|
+ boolean updated = this.updateById(toInfrared);
|
|
|
+ return updated;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除可见光转红外
|
|
|
+ *
|
|
|
+ * @param ids 需要删除的可见光转红外主键集合
|
|
|
+ * @return 结果:true 删除成功,false 删除失败
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public boolean deleteByIds(Long[] ids) {
|
|
|
+ return this.removeByIds(Arrays.asList(ids));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|