From 3e2159e45e12b2b8af058b68eafeaf082cf3fe85 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 15 九月 2022 09:30:31 +0800 Subject: [PATCH] 2022.9.15 1. 根据微信小程序前端需求,添加各对应后台逻辑 --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/LedgerServiceImpl.kt | 172 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 132 insertions(+), 40 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/LedgerServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/LedgerServiceImpl.kt index 868eb5b..f05ae65 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/LedgerServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/LedgerServiceImpl.kt @@ -13,8 +13,7 @@ import cn.flightfeather.supervision.infrastructure.utils.FileUtil import cn.flightfeather.supervision.infrastructure.utils.UUIDGenerator import cn.flightfeather.supervision.lightshare.service.LedgerService -import cn.flightfeather.supervision.lightshare.vo.LedgerSubTypeVo -import cn.flightfeather.supervision.lightshare.vo.LedgerVo +import cn.flightfeather.supervision.lightshare.vo.* import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.databind.ObjectMapper import com.github.pagehelper.PageHelper @@ -66,19 +65,24 @@ val resultList = mutableListOf<LedgerSubTypeVo>() ledgerSubTypes.forEach { val l = LedgerSubTypeVo( - it.lsSubtypeid, - it.lsName, - it.getlTypeid(), - it.getlTypename(), - needUpdate = it.getlNeedupdate(), - sceneType = it.getlScenetype(), - iconUrl = it.getlIconurl() + it.lsSubtypeid, + it.lsName, + it.getlTypeid(), + it.getlTypename(), + needUpdate = it.getlNeedupdate(), + sceneType = it.getlScenetype(), + iconUrl = it.getlIconurl(), + realTime = it.getlRealTime() ) for (r in records) { if (l.ledgerSubTypeId == r.lsSubtypeid) { l.ledgerFinished = true l.upLoad = true - l.checkStatus = r.lrVerifyrst?.toIntOrNull() ?: LedgerCheckStatus.UnCheck.value +// l.checkStatus = r.lrVerifyrst?.toIntOrNull() ?: LedgerCheckStatus.UnCheck.value + l.verified + l.verifierName = r.lrVerifierrealname + l.verified = r.lrIsverify + l.verifyRst = l.verifyRst break } } @@ -102,8 +106,8 @@ return result } - val startDate = DateUtil().StringToDate(startTime) - val endDate = DateUtil().StringToDate(endTime) + val startDate = DateUtil.StringToDate(startTime) + val endDate = DateUtil.StringToDate(endTime) val cal = Calendar.getInstance().apply { time = startDate } val year = cal.get(Calendar.YEAR) val month = cal.get(Calendar.MONTH) + 1 @@ -211,41 +215,22 @@ val ledgerVos = mapper.readValue<List<LedgerVo>>(ledgerVoList, object :TypeReference<List<LedgerVo>>(){}) ledgerVos.forEach { + it.id = it.id ?: UUIDGenerator.generate16ShortUUID() + it.fileType = it.fileType ?: 1 + val userInfo = userinfoMapper.selectByPrimaryKey(userId) + userInfo.extension2?.toInt()?.let {s-> it.sceneType = s } + val today = Calendar.getInstance().apply { time = Date() } .get(Calendar.DAY_OF_MONTH) - val cal = Calendar.getInstance().apply { time = it.updateDate } + val cal = Calendar.getInstance().apply { time = it.updateDate ?: Date() } val updateYear = cal.get(Calendar.YEAR) val updateMonth = cal.get(Calendar.MONTH) + 1 val updateDay = cal.get(Calendar.DAY_OF_MONTH) - //鐢熸垚鍙拌处鏇存柊璁板綍 - val ledgerRecord = LedgerRecord().apply { - lrGuid = it.id - lsSubtypeid = it.ledgerSubTypeId - lsSubtypename = it.ledgerName - lrYear = updateYear - lrMonth = updateMonth.toByte() - lrDay = updateDay.toByte() - lrEasubmitkind = it.fileType?.toByte() ?: 1 - lrSubmitid = userId - lrSubmitname = userInfo?.acountname ?: "" - lrIssubmitontime = today <= 10 - lrSubmitdate = Date() - lrUpdatetype = it.updateType - lrExtension1 = it.sceneType.toString() - } - - //妫�鏌ユ暟鎹簱鏄惁宸叉湁璁板綍锛岄�夋嫨鎻掑叆鎴栨洿鏂� - val tmp = ledgerRecordMapper.selectByPrimaryKey(ledgerRecord.lrGuid) - if (tmp == null || tmp.lrGuid == null) { - ledgerRecordMapper.insert(ledgerRecord) - } else { - ledgerRecordMapper.updateByPrimaryKey(ledgerRecord) - } //瀵规瘡寮犲浘鐗囩敓鎴愮浉搴旂殑璺緞骞朵繚瀛� var picPath = "" - val time = DateUtil().DateToString(Date(), DateUtil.DateStyle.YYYY_MM) + val time = DateUtil.DateToString(Date(), DateUtil.DateStyle.YYYY_MM) files.forEach {file-> val fileName = file.originalFilename //TODO 姝ゅ鐨勬枃浠惰矾寰勯渶瑕佷慨鏀逛负鍔ㄦ�侀厤缃� @@ -258,7 +243,7 @@ } try { //璋冪敤鏂囦欢淇濆瓨鏂规硶 - FileUtil().uploadFile(file.bytes, basePath + path, fileName!!) + FileUtil.uploadFile(file.bytes, basePath + path, fileName!!) } catch (e: Exception) { e.printStackTrace() } @@ -288,6 +273,31 @@ //鎻掑叆鏂扮殑澶氬獟浣撴枃浠惰褰曟暟鎹� ledgerMediaFileMapper.insert(ledgerMedia) + + //鐢熸垚鍙拌处鏇存柊璁板綍 + val ledgerRecord = LedgerRecord().apply { + lrGuid = it.id + lsSubtypeid = it.ledgerSubTypeId + lsSubtypename = it.ledgerName + lrYear = updateYear + lrMonth = updateMonth.toByte() + lrDay = updateDay.toByte() + lrEasubmitkind = it.fileType?.toByte() ?: 1 + lrSubmitid = userId + lrSubmitname = userInfo?.acountname ?: "" + lrIssubmitontime = today <= 10 + lrSubmitdate = Date() + lrUpdatetype = it.updateType + lrExtension1 = it.sceneType.toString() + } + + //妫�鏌ユ暟鎹簱鏄惁宸叉湁璁板綍锛岄�夋嫨鎻掑叆鎴栨洿鏂� + val tmp = ledgerRecordMapper.selectByPrimaryKey(ledgerRecord.lrGuid) + if (tmp == null || tmp.lrGuid == null) { + ledgerRecordMapper.insert(ledgerRecord) + } else { + ledgerRecordMapper.updateByPrimaryKey(ledgerRecord) + } return true } @@ -339,7 +349,7 @@ createCriteria().andEqualTo("lScenetype", sceneType) } }) - val c = Calendar.getInstance().apply { this.time = DateUtil().StringToDate(time) } + val c = Calendar.getInstance().apply { this.time = DateUtil.StringToDate(time) } val year = c.get(Calendar.YEAR) val month = c.get(Calendar.MONTH) + 1 val map = mutableMapOf<Int, MutableList<Int>>() @@ -373,4 +383,86 @@ return records } + + override fun copyLedger(userId: String, time: String, copyLedgerList: List<CopyLedgerVo>): BaseResponse<String> { + val year = time.split("-")[0] + val month = time.split("-")[1] + copyLedgerList.forEach { + //鍘婚噸鍒ゆ柇 + val r = ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply { + createCriteria().andEqualTo("lrSubmitid", userId) + .andEqualTo("lsSubtypeid", it.subTypeId) + .andEqualTo("lrYear", year) + .andEqualTo("lrMonth", month) + }) + if (r.size > 0) { + return@forEach + } + + val y = it.time?.split("-")?.get(0) ?: return@forEach + val m = it.time?.split("-")?.get(1) ?: return@forEach + ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply { + createCriteria().andEqualTo("lrSubmitid", userId) + .andEqualTo("lsSubtypeid", it.subTypeId) + .andEqualTo("lrYear", y) + .andEqualTo("lrMonth", m) + }).forEach record@ {lr -> + //鑾峰彇璁板綍瀵瑰簲鐨勬枃浠朵俊鎭� + val fileList = ledgerMediaFileMapper.selectByExample(Example(LedgerMediaFile::class.java).apply { + createCriteria().andEqualTo("lrGuid", lr.lrGuid) + }) + if (fileList.size == 0) return@record + val file = fileList[0] ?: return@record + + //淇敼璁板綍淇℃伅锛屽鍒朵负鏂扮殑鍙拌处 + lr.lrGuid = UUIDGenerator.generate16ShortUUID() + lr.lrYear = year.toInt() + lr.lrMonth = month.toByte() + lr.lrIssubmitontime = true + lr.lrSubmitdate = Date() + lr.lrExtension2 = "copy"//琛ㄦ槑鏄鍒剁殑鍙拌处 + ledgerRecordMapper.insert(lr) + + //淇敼瀵瑰簲鐨勬枃浠朵俊鎭� + file.apply { + mfGuid = UUIDGenerator.generate16ShortUUID() + lrGuid = lr.lrGuid + mfSavetime = Date() + } + ledgerMediaFileMapper.insert(file) + } + } + + return BaseResponse(true) + } + + override fun checkLedger(verifierId: String, remark: String?, recordList: List<LedgerCheckVo>): BaseResponse<Boolean> { + val recordIdList = mutableListOf<String?>() + recordList.forEach { recordIdList.add(it.recordId) } + val records = ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply { + createCriteria().andIn("lrGuid", recordIdList) + .andIsNotNull("lrGuid") + }) + return if (records.isEmpty()) { + BaseResponse(false, "鎵�閫夎褰曚笉瀛樺湪") + } else { + records.forEach { + for (r in recordList) { + if (r.recordId == it.lrGuid) { + it.lrVerifierid = verifierId + it.lrVerifierrealname + it.lrVerifydate = Date() + it.lrIsverify = r.result + it.lrVerifyrst = r.remark + it.lrAiverifytime = if (it.lrAiverifytime == null) 0 else it.lrAiverifytime++ + it.lrIsai = false + + ledgerRecordMapper.updateByPrimaryKey(it) + continue + } + } + } + BaseResponse(true) + } + } } \ No newline at end of file -- Gitblit v1.9.3