| | |
| | | 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 |
| | |
| | | if (sceneType != SceneType.NoType.value) { |
| | | createCriteria().andEqualTo("lScenetype", sceneType) |
| | | } |
| | | orderBy("lTypeid") |
| | | }) |
| | | val records = getLedgerRecords(userId, null, sceneType, time) |
| | | 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 |
| | | } |
| | | } |
| | |
| | | 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 |
| | |
| | | |
| | | } |
| | | |
| | | override fun getLedgerDetail2(userId: String, ledgerSubTypeId: Int?, sceneType: Int, time: String): List<LedgerVo> { |
| | | val records = getLedgerRecords(userId, ledgerSubTypeId, sceneType, time) |
| | | override fun getLedgerDetail2(userId: String, ledgerSubTypeId: Int?, sceneType: Int, time: String?): List<LedgerVo> { |
| | | val records = if (time != null) { |
| | | getLedgerRecords(userId, ledgerSubTypeId, sceneType, time) |
| | | } else { |
| | | // FIXME: 2022/10/13 暂时只支持ledgerSubTypeId不为null的情况 |
| | | if (ledgerSubTypeId == null) return emptyList() |
| | | PageHelper.startPage<LedgerRecord>(1, 1) |
| | | ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply { |
| | | createCriteria().andEqualTo("lrSubmitid", userId) |
| | | .andEqualTo("lsSubtypeid", ledgerSubTypeId) |
| | | orderBy("lrSubmitdate").desc() |
| | | }) |
| | | } |
| | | val result = ArrayList<LedgerVo>() |
| | | records.forEach { |
| | | val media = ledgerMediaFileMapper.selectByExample( |
| | |
| | | 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 此处的文件路径需要修改为动态配置 |
| | |
| | | } |
| | | try { |
| | | //调用文件保存方法 |
| | | FileUtil().uploadFile(file.bytes, basePath + path, fileName!!) |
| | | FileUtil.uploadFile(file.bytes, basePath + path, fileName!!) |
| | | } catch (e: Exception) { |
| | | e.printStackTrace() |
| | | } |
| | |
| | | |
| | | //插入新的多媒体文件记录数据 |
| | | 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 |
| | | } |
| | |
| | | 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>>() |
| | |
| | | |
| | | return records |
| | | } |
| | | |
| | | override fun copyLedger(userId: String, time: String, copyLedgerList: List<CopyLedgerVo>): BaseResponse<String> { |
| | | val year = time.split("-")[0] |
| | | val month = time.split("-")[1] |
| | | val date = DateUtil.StringToDate(time, DateUtil.DateStyle.YYYY_MM) |
| | | 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) |
| | | } |
| | | } |
| | | } |