From a3cc1d220f8a1de11874bebceba0130d32157ff1 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 30 九月 2025 09:26:32 +0800 Subject: [PATCH] 2025.9.30 1. 联合前端调试数据产品接口(待完成) --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/MediafileServiceImpl.kt | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/MediafileServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/MediafileServiceImpl.kt index 27ca9c2..927627b 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/MediafileServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/MediafileServiceImpl.kt @@ -1,10 +1,16 @@ package cn.flightfeather.supervision.lightshare.service.impl +import cn.flightfeather.supervision.common.exception.BizException import cn.flightfeather.supervision.domain.ds1.entity.Mediafile import cn.flightfeather.supervision.domain.ds1.mapper.MediafileMapper import cn.flightfeather.supervision.common.utils.Constant import cn.flightfeather.supervision.common.utils.FileUtil +import cn.flightfeather.supervision.domain.ds1.entity.Inspection +import cn.flightfeather.supervision.domain.ds1.repository.InspectionRep import cn.flightfeather.supervision.domain.ds1.repository.MediaFileRep +import cn.flightfeather.supervision.domain.ds1.repository.SceneRep +import cn.flightfeather.supervision.domain.ds1.repository.SubTaskRep +import cn.flightfeather.supervision.lightshare.service.DomainitemService import cn.flightfeather.supervision.lightshare.service.MediafileService import cn.flightfeather.supervision.lightshare.vo.MediaFileVo import com.fasterxml.jackson.core.type.TypeReference @@ -22,6 +28,10 @@ class MediafileServiceImpl( val mediafileMapper: MediafileMapper, private val mediaFileRep: MediaFileRep, + private val inspectionRep: InspectionRep, + private val subTaskRep: SubTaskRep, + private val sceneRep: SceneRep, + private val domainItemService: DomainitemService, @Value("\${filePath}") var filePath: String, @Value("\${imgPath}") var imgPath: String, ) : MediafileService { @@ -36,6 +46,28 @@ val mediafilelist = mediafileMapper.select(mediafile) mediafilelist.sortBy { it.savetime } return mediafilelist + } + + /** + * 鑾峰彇鎵�鏈変换鎰忔媿甯歌璁板綍鍥剧墖 + * @param iGuid + */ + override fun getRoutineRecord(iGuid: String?, stGuid: String?): List<Mediafile?> { + var inspectionGuid = iGuid + val sceneId = if (iGuid != null) { + inspectionRep.findOne(iGuid)?.sguid + } else if (stGuid != null) { + val s = subTaskRep.findOne(stGuid) + val ins = inspectionRep.findOne(Inspection().apply { stguid = stGuid }) + inspectionGuid = ins?.guid + s?.scenseid + } else { + throw BizException("宸℃煡璁板綍id鍜屽贰鏌ヤ换鍔d鑷冲皯濉啓鍏朵腑涓�涓�") + } + sceneId ?: throw BizException("璁板綍瀵瑰簲鐨勫満鏅笉瀛樺湪") + val sceneInfo = sceneRep.findScene(sceneId = sceneId) ?: throw BizException("鍦烘櫙涓嶅瓨鍦紝鑾峰彇鍦烘櫙鍥剧墖澶辫触") + val mediaFileTypeList = domainItemService.getMediaFileType(sceneInfo.typeid?.toInt()).entries.map { it.key?.toInt() } + return mediaFileRep.findList(inspectionGuid, mediaFileTypeList) } //鏍规嵁闂id鑾峰彇濯掍綋鏂囦欢 @@ -115,6 +147,26 @@ override fun save(mediafile: Mediafile): Int = mediafileMapper.updateByPrimaryKey(mediafile) + override fun saveMediaFile(files: Array<MultipartFile>, getMediaFile: () -> Mediafile): Int { + var res = 0 + // 淇濆瓨鍥剧墖 + for (image in files) { + val mediaFile = getMediaFile() + res += mediafileMapper.insert(mediaFile) + + val path = mediaFile.extension1 + val fileName = mediaFile.guid + ".jpg" + val filePath = "${imgPath}/$path/" + try { + //璋冪敤鏂囦欢淇濆瓨鏂规硶 + FileUtil.uploadFile(image.bytes, filePath, fileName) + } catch (e: Exception) { + // TODO: handle exception + } + } + return res + } + override fun update(mediafile: Mediafile): Int = mediafileMapper.updateByPrimaryKey(mediafile) //鍒犻櫎濯掍綋鏂囦欢 @@ -133,6 +185,7 @@ override fun deleteList(idList: List<String>): Int { var res = 0 + if (idList.isEmpty()) return res mediaFileRep.findList(idList).forEach { //鏈嶅姟鍣ㄤ繚瀛樿矾寰� val path = it?.extension1 -- Gitblit v1.9.3