2026.1.22
1. 新增台账上传office文档功能;
2. 新增office文档存储原始文档名字功能
| | |
| | | import cn.flightfeather.supervision.lightshare.vo.* |
| | | import com.fasterxml.jackson.core.type.TypeReference |
| | | import com.fasterxml.jackson.databind.ObjectMapper |
| | | import com.fasterxml.jackson.module.kotlin.readValue |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.beans.factory.annotation.Value |
| | | import org.springframework.stereotype.Service |
| | | import org.springframework.transaction.annotation.Transactional |
| | | import org.springframework.web.multipart.MultipartFile |
| | | import tk.mybatis.mapper.entity.Example |
| | | import java.io.File |
| | |
| | | return true |
| | | } |
| | | |
| | | override fun uploadLedger(userId: String, ledgerVoList: String, files: Array<MultipartFile>): Boolean { |
| | | |
| | | @Transactional |
| | | override fun uploadLedger( |
| | | userId: String, ledgerVoList: String, |
| | | fileNames: String?, files: Array<MultipartFile>, |
| | | ): Boolean { |
| | | val mapper = ObjectMapper() |
| | | |
| | | val ledgerVos = mapper.readValue<List<LedgerVo>>(ledgerVoList, object : TypeReference<List<LedgerVo>>() {}) |
| | | val ledgerVos = mapper.readValue(ledgerVoList, object : TypeReference<List<LedgerVo>>() {}) |
| | | val fileNamePair = if (fileNames.isNullOrBlank()) { |
| | | emptyList() |
| | | } else { |
| | | mapper.readValue(fileNames, object : TypeReference<List<Map<String, String>>>() {})?.map { |
| | | it["first"] to it["second"] |
| | | } |
| | | } |
| | | |
| | | ledgerVos.forEach { |
| | | it.id = it.id ?: UUIDGenerator.generate16ShortUUID() |
| | |
| | | val record = tmp[0] |
| | | it.id = record.lrGuid |
| | | ledgerMedia = deleteLedgerFile(record.lrGuid) |
| | | record.apply { |
| | | lrYear = updateYear |
| | | lrMonth = updateMonth.toByte() |
| | | lrDay = updateDay.toByte() |
| | | lrSubmitdate = Date() |
| | | // 去除不涉及标志或复制标志 |
| | | record.lrExtension2 = null |
| | | lrExtension2 = null |
| | | } |
| | | ledgerRecordMapper.updateByPrimaryKey(record) |
| | | } |
| | | |
| | |
| | | var picPath = "" |
| | | val time = DateUtil.DateToString(Date(), DateUtil.DateStyle.YYYY_MM) |
| | | files.forEach { file -> |
| | | val fileName = file.originalFilename |
| | | //TODO 此处的文件路径需要修改为动态配置 |
| | | // val basePath = "D:/02product/05ledger/images/" |
| | | var fileName = file.originalFilename |
| | | // 根据传入的文件配队信息获取原始文件名 |
| | | fileNamePair?.find { p-> p.first == file.originalFilename }?.let { p-> fileName = p.second } |
| | | val basePath = imgPath |
| | | val path = "$time/$userId/${it.ledgerName}/" |
| | | picPath += if (picPath.isEmpty()) { |
| | |
| | | userId: String, |
| | | taskId: String?, |
| | | list: String, |
| | | fileNames: String?, |
| | | files: Array<MultipartFile>, |
| | | ): BaseResponse<Boolean> { |
| | | val mapper = ObjectMapper() |
| | | val ledgerVos = mapper.readValue(list, object : TypeReference<List<LedgerVo>>() {}) |
| | | val fileNamePair = if (fileNames.isNullOrBlank()) { |
| | | emptyList() |
| | | } else { |
| | | mapper.readValue(fileNames, object : TypeReference<List<Map<String, String>>>() {})?.map { |
| | | it["first"] to it["second"] |
| | | } |
| | | } |
| | | ledgerVos.forEach { |
| | | it.id = it.id ?: UUIDGenerator.generate16ShortUUID() |
| | | it.fileType = it.fileType ?: 1 |
| | |
| | | var picPath = "" |
| | | val time = DateUtil.DateToString(Date(), DateUtil.DateStyle.YYYY_MM) |
| | | files.forEach { file -> |
| | | val fileName = file.originalFilename |
| | | var fileName = file.originalFilename |
| | | // 根据传入的文件配队信息获取原始文件名 |
| | | fileNamePair?.find { p-> p.first == file.originalFilename }?.let { p-> fileName = p.second } |
| | | val basePath = imgPath |
| | | val path = "$time/$userId/${it.ledgerName}/" |
| | | picPath += if (picPath.isEmpty()) { |
| | |
| | | /** |
| | | * 上传台账 |
| | | */ |
| | | fun uploadLedger(userId: String, ledgerVoList: String, files: Array<MultipartFile>): Boolean |
| | | fun uploadLedger(userId: String, ledgerVoList: String, fileNames: String?, files: Array<MultipartFile>): Boolean |
| | | |
| | | /** |
| | | * 上传不涉及台账 |
| | |
| | | userId: String, |
| | | taskId: String?, |
| | | list: String, |
| | | fileNames: String?, |
| | | files: Array<MultipartFile>, |
| | | ): BaseResponse<Boolean> |
| | | |
| | |
| | | fun uploadLedger( |
| | | @ApiParam("用户id") @PathVariable userId: String, |
| | | @ApiParam("台账信息json") @RequestParam("params") ledgerVoList: String, |
| | | @ApiParam("台账图片") @RequestPart("images") files:Array<MultipartFile> |
| | | ) = ledgerService.uploadLedger(userId, ledgerVoList, files) |
| | | @ApiParam("临时文件名和原始文件名称的对应列表") @RequestParam("fileNames", required = false) |
| | | fileNames: String?, |
| | | @ApiParam("台账图片") @RequestPart("images") files: Array<MultipartFile>, |
| | | ) = ledgerService.uploadLedger(userId, ledgerVoList, fileNames, files) |
| | | |
| | | @ApiOperation("上传不涉及台账") |
| | | @PostMapping("/upload/noLedger") |
| | |
| | | @ApiParam("用户id") @RequestParam userId: String, |
| | | @ApiParam("应急自巡查任务id") @RequestParam(required = false) taskId: String?, |
| | | @ApiParam("自巡查信息json") @RequestParam("params") list: String, |
| | | @ApiParam("临时文件名和原始文件名称的对应列表") @RequestParam("fileNames", required = false) |
| | | fileNames: String?, |
| | | @ApiParam("自巡查图片") @RequestPart("images") files: Array<MultipartFile>, |
| | | ) = selfPatrolService.uploadSelfPatrol(userId, taskId, list, files) |
| | | ) = selfPatrolService.uploadSelfPatrol(userId, taskId, list,fileNames, files) |
| | | |
| | | @ApiOperation("上传不涉及自巡查") |
| | | @PostMapping("/task/record/upload/noInvolved") |