From 6c7f45871b93ef26d353a5a3596701ac2f39ed9c Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 10 九月 2024 17:48:27 +0800 Subject: [PATCH] 1. 新增问题更新接口 --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt | 156 +++++++++++++++++++++++----------------------------- 1 files changed, 69 insertions(+), 87 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt index 8f2b7d4..e84b05a 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt @@ -3,13 +3,10 @@ import cn.flightfeather.supervision.common.exception.BizException import cn.flightfeather.supervision.common.log.BizLog import cn.flightfeather.supervision.common.log.WorkStreamLogInfo -import cn.flightfeather.supervision.domain.ds1.entity.Problemlist -import cn.flightfeather.supervision.domain.ds1.entity.Scense import cn.flightfeather.supervision.common.utils.Constant import cn.flightfeather.supervision.common.utils.FileUtil import cn.flightfeather.supervision.common.utils.UUIDGenerator -import cn.flightfeather.supervision.domain.ds1.entity.Mediafile -import cn.flightfeather.supervision.domain.ds1.entity.Subtask +import cn.flightfeather.supervision.domain.ds1.entity.* import cn.flightfeather.supervision.domain.ds1.mapper.* import cn.flightfeather.supervision.domain.ds1.repository.ProblemRep import cn.flightfeather.supervision.domain.ds1.repository.SubTaskRep @@ -22,6 +19,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.github.pagehelper.PageHelper import org.springframework.beans.BeanUtils +import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Service import org.springframework.web.multipart.MultipartFile import tk.mybatis.mapper.entity.Example @@ -45,6 +43,8 @@ private val subTaskRep: SubTaskRep, private val problemRep: ProblemRep, private val bizLog: BizLog, + @Value("\${filePath}") var filePath: String, + @Value("\${imgPath}") var imgPath: String, ) : ProblemlistService { @Resource @@ -62,29 +62,29 @@ @Resource lateinit var mediafileService: MediafileService - override fun getByTopTask(tguid: String): List<ProblemlistVo> { + override fun getByTopTask(tguid: String): List<ProblemListVo> { TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } //鏍规嵁鍦烘櫙id鍜屾椂闂磋幏鍙栧搴旈《灞備换鍔′笅鐨勬墍鏈夐棶棰� - override fun getProblemByScene(sceneId: String, date: String): List<ProblemlistVo> { + override fun getProblemByScene(sceneId: String, date: String): List<ProblemListVo> { val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") val date1 = simpleDateFormat.parse(date) val scene = scenseMapper.selectByPrimaryKey(sceneId) val district = scene.districtcode val taskVolist = taskService.getByDistrictCode(district!!, date1) - val problemlistVolistTemp1 = mutableListOf<ProblemlistVo>() + val problemListVolistTemp1 = mutableListOf<ProblemListVo>() if (!taskVolist.isEmpty()) { val problemlists = (problemlistMapper.getProblemByScene(sceneId, taskVolist[0].tguid!!)) problemlists.forEach { // 闄愬埗浼佷笟鏌ョ湅鏈鏍哥殑闂 if (it.extension3 != Constant.PROBLEM_UNCHECKED && it.extension3 != Constant.PROBLEM_CHECK_FAIL) { - val problemVo = ProblemlistVo(); + val problemVo = ProblemListVo(); BeanUtils.copyProperties(it, problemVo) - problemlistVolistTemp1.add(problemVo) + problemListVolistTemp1.add(problemVo) } } - problemlistVolistTemp1.forEach { + problemListVolistTemp1.forEach { if (it.ptguid != null) { val tmp1 = problemtypeMapper.selectByPrimaryKey(it.ptguid) if (tmp1 != null) { @@ -102,7 +102,7 @@ } } } - return problemlistVolistTemp1 + return problemListVolistTemp1 } //鑾峰彇鏌愰《灞備换鍔′笅锛屾煇涓満鏅笅鐨勯棶棰樻暣鏀规儏鍐� @@ -213,8 +213,8 @@ } //鏍规嵁鍦板煙鑾峰彇闂 - override fun getByArea(areaVo: AreaVo): List<ProblemlistVo> { - val problemlist = mutableListOf<ProblemlistVo>() + override fun getByArea(areaVo: AreaVo): List<ProblemListVo> { + val problemlist = mutableListOf<ProblemListVo>() // val tmpproblemlsit = mutableListOf<Problemlist>() val example = Example(Scense::class.java) val criteria = example.createCriteria() @@ -238,7 +238,7 @@ tmpcriteria.andBetween("time", areaVo.starttime, areaVo.endtime) val tmp = problemlistMapper.selectByExample(tmpexample) tmp.forEach { - val problem = ProblemlistVo(); + val problem = ProblemListVo(); BeanUtils.copyProperties(it, problem) problemlist.add(problem) } @@ -258,47 +258,47 @@ } //鏍规嵁宸℃煡ID鑾峰彇闂 - override fun findByInspectionID(inspectionID: String): List<ProblemlistVo> { - val problemlistVoList = mutableListOf<ProblemlistVo>() + override fun findByInspectionID(inspectionID: String): List<ProblemListVo> { + val problemListVoList = mutableListOf<ProblemListVo>() val problemlist = Problemlist() problemlist.iguid = inspectionID val problemlists = problemlistMapper.select(problemlist) problemlists.forEach { - val problemlistVo = ProblemlistVo() + val problemlistVo = ProblemListVo() if (it.remark != Constant.PROBLEM_DELETED) { BeanUtils.copyProperties(it, problemlistVo) - problemlistVoList.add(problemlistVo) + problemListVoList.add(problemlistVo) } } //鎺掑簭 - problemlistVoList.sortBy { it.time } - return problemlistVoList + problemListVoList.sortBy { it.time } + return problemListVoList } //鏂板涓�涓棶棰� - override fun addProblem(problemlistVo: ProblemlistVo) { + override fun addProblem(problemlistVo: ProblemListVo) { val probemlist = Problemlist() BeanUtils.copyProperties(problemlistVo, probemlist) problemlistMapper.insert(probemlist) } //鏍规嵁瀛愪换鍔D鏌ヨ闂 - override fun findBySubtaskId(subTaskID: String): List<ProblemlistVo> { - val problemlistVoList = mutableListOf<ProblemlistVo>() + override fun findBySubtaskId(subTaskID: String): List<ProblemListVo> { + val problemListVoList = mutableListOf<ProblemListVo>() val problemlist = Problemlist() problemlist.stguid = subTaskID val problemlists = problemlistMapper.select(problemlist) problemlists.forEach { - val problemlistVo = ProblemlistVo() + val problemlistVo = ProblemListVo() BeanUtils.copyProperties(it, problemlistVo) - problemlistVoList.add(problemlistVo) + problemListVoList.add(problemlistVo) } - return problemlistVoList + return problemListVoList } //鏍规嵁闂ID鑾峰彇涓�涓棶棰� - override fun findByID(id: String): ProblemlistVo { - val problemlistVo = ProblemlistVo() + override fun findByID(id: String): ProblemListVo { + val problemlistVo = ProblemListVo() val problemlist = problemlistMapper.selectByPrimaryKey(id) if (problemlist != null) { BeanUtils.copyProperties(problemlist, problemlistVo) @@ -464,67 +464,15 @@ //json杞琽bject val problemVo = mapper.readValue(problem, object : TypeReference<ProblemVo>() {}) - // 淇濆瓨闂 val inspection = inspectionMapper.selectByPrimaryKey(problemVo.insGuid) ?: return BaseResponse(false, "宸℃煡璁板綍涓嶅瓨鍦�") val scene = scenseMapper.selectByPrimaryKey(inspection.sguid) ?: return BaseResponse(false, "宸℃煡璁板綍瀵瑰簲鍦烘櫙涓嶅瓨鍦�") - val problemlist = Problemlist().apply { - guid = UUIDGenerator.generate16ShortUUID() - iguid = inspection.guid - stguid = inspection.stguid - sguid = inspection.sguid - sensename = inspection.scensename - senseaddress = inspection.scenseaddress - ptguid = problemVo.ptGuid - problemname = problemVo.proName - longitude = problemVo.longitude ?: scene.longitude - latitude = problemVo.latitude ?: scene.latitude - locationid = problemVo.locationId - location = problemVo.location - time = Date() - isrechecked = false - ischanged = false - advise = problemVo.advice - extension3 = Constant.PROBLEM_UNCHECKED - } + // 淇濆瓨闂 + val problemlist = ProblemListVo.newPro(inspection, problemVo, scene) problemlistMapper.insert(problemlist) // 淇濆瓨鍥剧墖 - val now = LocalDateTime.now() - for (image in files) { - val mediaFile = Mediafile().apply { - guid = UUIDGenerator.generate16ShortUUID() - iguid = inspection.guid - businessguid = problemlist.guid - longitude = problemlist.longitude - latitude = problemlist.latitude - address = problemlist.senseaddress - filetype = 1 - businesstype = "闂" - businesstypeid = 1 - path = - "FlightFeather/Photo/" + scene.districtname + "/" + now.year + "骞�" + now.monthValue + "鏈�/" + now.monthValue + "鏈�" + now.dayOfMonth + "鏃�/" + scene.name + "/" - description = - problemlist.problemname + " " + problemlist.location + " " + UUIDGenerator.generateUUID(4) + ".jpg" - savetime = Date() - ischanged = false - extension1 = - scene.citycode + "/" + scene.districtcode + "/" + now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + "/" + scene.guid + "/" - remark = "宸蹭笂浼�" - } - mediafileMapper.insert(mediaFile) - - val path = mediaFile.extension1 - val fileName = mediaFile.guid + ".jpg" -// val filePath = "E:\\work\\绗笁鏂圭洃绠pp\\鑷姩璇勫垎\\椁愰ギ\\" - val filePath = "${Constant.DEFAULT_FILE_PATH}/images/$path/" - try { - //璋冪敤鏂囦欢淇濆瓨鏂规硶 - FileUtil.uploadFile(image.bytes, filePath, fileName) - } catch (e: Exception) { - // TODO: handle exception - } - } + saveProFile(problemlist, inspection, scene, files) //鏇存柊宸℃煡淇℃伅鐨勯棶棰樻暟 if (inspection.problemcount != null) { @@ -539,6 +487,40 @@ } return BaseResponse(true) + } + + override fun updateProblem(problem: ProblemListVo, deleteImg: List<String>, files: Array<MultipartFile>): String { + problemRep.findOne(problem.guid) ?: throw BizException("璇ラ棶棰樹笉瀛樺湪") + val inspection = inspectionMapper.selectByPrimaryKey(problem.guid) ?: throw BizException("宸℃煡璁板綍涓嶅瓨鍦�") + val scene = scenseMapper.selectByPrimaryKey(inspection.sguid) ?: throw BizException("宸℃煡璁板綍瀵瑰簲鍦烘櫙涓嶅瓨鍦�") + saveProFile(problem, inspection, scene, files) + mediafileService.deleteList(deleteImg) + return "success" + } + + override fun saveProFile( + problemlist: Problemlist, + inspection: Inspection, + scene: Scense, + files: Array<MultipartFile>, + ): Int { + var res = 0 + // 淇濆瓨鍥剧墖 + for (image in files) { + val mediaFile = MediaFileVo.newProFile(inspection, problemlist, scene) + 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 changeProblem(problemId: String, files: Array<MultipartFile>): BaseResponse<String> { @@ -585,7 +567,7 @@ val path = m.extension1 val fileName = m.guid + ".jpg" // val filePath = "E:\\work\\绗笁鏂圭洃绠pp\\鑷姩璇勫垎\\椁愰ギ\\" - val filePath = "${Constant.DEFAULT_FILE_PATH}/images/$path" + val filePath = "${imgPath}/$path" try { //璋冪敤鏂囦欢淇濆瓨鏂规硶 FileUtil.uploadFile(image.bytes, filePath, fileName) @@ -597,9 +579,9 @@ return BaseResponse(true) } - override fun getBySubTask(stGuid: String, all: Boolean?): List<ProblemlistVo> { + override fun getBySubTask(stGuid: String, all: Boolean?): List<ProblemListVo> { //鏍规嵁瀛愪换鍔D鑾峰彇闂鍒楄〃 - val problemListVo = mutableListOf<ProblemlistVo>() + val problemListVo = mutableListOf<ProblemListVo>() if (all == false) { //鍘婚櫎鏈鏍镐互鍙婂鏍镐笉閫氳繃鐨勯棶棰� findBySubtaskId(stGuid).forEach { @@ -637,7 +619,7 @@ areaVo.scensetypeid ?: throw BizException("缂哄皯鍦烘櫙绫诲瀷鍙傛暟") val task = taskRep.findOneTask(areaVo) ?: throw BizException("鏈壘鍒板搴旂殑宸℃煡鎬讳换鍔�") val p = PageHelper.startPage<SceneProblemSummary>(page, per_page) - val res = problemRep.getSceneProSummary(task.tguid!!, areaVo.scensetypeid!!, areaVo.sort, sortBy) + val res = problemRep.selectSceneProSummary(task.tguid!!, areaVo.scensetypeid!!, areaVo.sort, sortBy) return DataHead(p.pageNum, p.pages, p.total) to res } } \ No newline at end of file -- Gitblit v1.9.3