| | |
| | | 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()) { |