From 82baf5d28ce79aa4d3b64956207d247596726924 Mon Sep 17 00:00:00 2001
From: hcong <1050828145@qq.com>
Date: 星期二, 10 十二月 2024 11:21:33 +0800
Subject: [PATCH] 1. BgTaskStatus状态属性序列化
---
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/MediafileServiceImpl.kt | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 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..4081cf9 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,15 @@
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.MediafileService
import cn.flightfeather.supervision.lightshare.vo.MediaFileVo
import com.fasterxml.jackson.core.type.TypeReference
@@ -22,6 +27,9 @@
class MediafileServiceImpl(
val mediafileMapper: MediafileMapper,
private val mediaFileRep: MediaFileRep,
+ private val inspectionRep: InspectionRep,
+ private val subTaskRep: SubTaskRep,
+ private val sceneRep: SceneRep,
@Value("\${filePath}") var filePath: String,
@Value("\${imgPath}") var imgPath: String,
) : MediafileService {
@@ -36,6 +44,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)
+ val mediaFileTypeList = Constant.MediaFileType.getList(sceneInfo?.typeid).map { it.value }
+ return mediaFileRep.findList(inspectionGuid, mediaFileTypeList)
}
//鏍规嵁闂id鑾峰彇濯掍綋鏂囦欢
@@ -115,6 +145,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 +183,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