From c17e9978745cfe6c983f3aff75c9182fffef32fd Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期一, 09 六月 2025 17:29:23 +0800 Subject: [PATCH] 1. 修复部分数据统计接口bug --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt | 599 +++++++++++++++++++++++------------------------------------ 1 files changed, 236 insertions(+), 363 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt index db25309..e0f8796 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt @@ -1,17 +1,34 @@ package cn.flightfeather.supervision.lightshare.service.impl +import cn.flightfeather.supervision.business.bgtask.ReportTaskCtrl +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.business.report.DbMapper +import cn.flightfeather.supervision.business.report.file.ReportOne +import cn.flightfeather.supervision.business.report.file.ReportThree +import cn.flightfeather.supervision.business.report.file.ReportTwo +import cn.flightfeather.supervision.business.report.template.* +import cn.flightfeather.supervision.common.exception.BizException import cn.flightfeather.supervision.common.utils.* import cn.flightfeather.supervision.domain.ds1.entity.* import cn.flightfeather.supervision.domain.ds1.mapper.* +import cn.flightfeather.supervision.domain.ds1.repository.EvaluationRep +import cn.flightfeather.supervision.domain.ds1.repository.EvaluationRuleRep +import cn.flightfeather.supervision.domain.ds1.repository.SceneRep +import cn.flightfeather.supervision.domain.ds2.mapper.LedgerRecordMapper +import cn.flightfeather.supervision.domain.ds2.mapper.LedgerSubTypeMapper +import cn.flightfeather.supervision.domain.ds2.mapper.UserMapMapper import cn.flightfeather.supervision.lightshare.service.SearchService +import cn.flightfeather.supervision.lightshare.service.TaskService import cn.flightfeather.supervision.lightshare.vo.* import com.github.pagehelper.PageHelper import org.springframework.beans.BeanUtils +import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Service import tk.mybatis.mapper.entity.Example import java.io.File import java.io.FileInputStream import java.io.FileOutputStream +import java.net.URLEncoder import java.nio.charset.StandardCharsets import java.util.* import javax.servlet.http.HttpServletResponse @@ -25,51 +42,127 @@ val userinfoMapper: UserinfoMapper, val subtaskMapper: SubtaskMapper, val scenseMapper: ScenseMapper, + val sceneConstructionSiteMapper: SceneConstructionSiteMapper, + val sceneMixingPlantMapper: SceneMixingPlantMapper, + val sceneStorageYardMapper: SceneStorageYardMapper, + val sceneWharfMapper: SceneWharfMapper, val problemlistMapper: ProblemlistMapper, val problemtypeMapper: ProblemtypeMapper, val townMapper: TownMapper, val mediafileMapper: MediafileMapper, val scoreMapper: ScoreMapper, val inspectionMapper: InspectionMapper, - val taskMapper: TaskMapper -): SearchService { + val taskMapper: TaskMapper, + val monitorobjectversionMapper: MonitorobjectversionMapper, + val evaluationruleMapper: EvaluationruleMapper, + val evaluationsubruleMapper: EvaluationsubruleMapper2, + val evaluationMapper: EvaluationMapper, + val itemevaluationMapper: ItemevaluationMapper, + val ledgerSubTypeMapper: LedgerSubTypeMapper, + val ledgerRecordMapper: LedgerRecordMapper, + val userMapMapper: UserMapMapper, + val taskService: TaskService, + private val evaluationRep: EvaluationRep, + private val evaluationRuleRep: EvaluationRuleRep, + private val sceneRep: SceneRep, + @Value("\${filePath}") var filePath: String, + @Value("\${imgPath}") var imgPath: String, + private val dbMapper: DbMapper, + private val reportTaskCtrl: ReportTaskCtrl, +) : SearchService { - private val dateUtil = DateUtil() + override fun writeToFile(config: ExcelConfigVo, mode: Int) { + val dbMapper = DbMapper( + scenseMapper, + problemlistMapper, + problemtypeMapper, + subtaskMapper, + monitorobjectversionMapper, + sceneConstructionSiteMapper, + sceneMixingPlantMapper, + sceneStorageYardMapper, + sceneWharfMapper, + taskMapper, + evaluationruleMapper, evaluationsubruleMapper, evaluationMapper, itemevaluationMapper, + ledgerSubTypeMapper, ledgerRecordMapper, userinfoMapper, userMapMapper, townMapper + ) + val dataSource = DataSource(config, dbMapper) + val t = when (mode) { + 8 -> ReportOne(dataSource) + 9 -> ReportTwo(dataSource) + 10 -> ReportThree(dataSource) - override fun writeToFile(config: ExcelConfigVo) { - val fileName = "e:/${DateUtil().DateToString(Date(), "yyyy-MM-ddhhmmss")}.xls" - val out = FileOutputStream(fileName) - val heads = getTableTitles() - val contents = getTableContents(config) - ExcelUtil.write2(out, heads, contents) + else -> null + } +// t?.execute() + t?.toFile("target/") } - override fun getExcel(config: ExcelConfigVo, response: HttpServletResponse): HttpServletResponse { + override fun getExcel(config: ExcelConfigVo, response: HttpServletResponse): Boolean { + val dataSource = DataSource(config, dbMapper) + val t = when (config.mode) { + 1 -> ReportOne(dataSource) + 2 -> ReportTwo(dataSource) + 3 -> ReportThree(dataSource) - val fileName = "${DateUtil().DateToString(Date(), "yyyy-MM-dd hh:mm:ss")}.xls" - response.apply { - setHeader("Content-Disposition", "attachment;filename=$fileName") - setHeader("fileName", fileName) - contentType = "application/vnd.ms-excel;charset=UTF-8" - setHeader("Pragma", "no-cache") - setHeader("Cache-Control", "no-cache") - setDateHeader("Expires", 0) + else -> ReportOne(dataSource) } - - val heads = getTableTitles() - val contents = getTableContents(config) - - val out = response.outputStream - ExcelUtil.write2(out, heads, contents) - - return response + val fileName = t.getReportName() + val p = "$filePath/autoscore/" + val file = File(p + fileName) + if (config.forceUpdate || !file.exists()) { + val downloadUrl = "/autoscore/${fileName}" + reportTaskCtrl.startTask(t, downloadUrl) + return false + } else { + val fName = Base64.getEncoder().encodeToString(fileName.toByteArray()) + response.apply { + setHeader("Content-Disposition", "attachment;filename=$fName") + setHeader("fileName", fName) + addHeader("Access-Control-Expose-Headers", "fileName") + contentType = "application/vnd.ms-excel;charset=UTF-8" + setHeader("Pragma", "no-cache") + setHeader("Cache-Control", "no-cache") + setDateHeader("Expires", 0) + } + response.outputStream.write(file.readBytes()) + return true + } } override fun getSubTaskDetail(config: ExcelConfigVo): SubTaskTableVo { - val titles = getTableTitles2() - val content = getTableContents2(config) + val dbMapper = DbMapper( + scenseMapper, + problemlistMapper, + problemtypeMapper, + subtaskMapper, + monitorobjectversionMapper, + sceneConstructionSiteMapper, + sceneMixingPlantMapper, + sceneStorageYardMapper, + sceneWharfMapper, + taskMapper, + evaluationruleMapper, evaluationsubruleMapper, evaluationMapper, itemevaluationMapper, + ledgerSubTypeMapper, ledgerRecordMapper, userinfoMapper, userMapMapper, townMapper + ) +// val dataSource = DataSource(config, dbMapper) +// val t = when (config.mode) { +//// 1 -> ReportOne(dataSource) +//// 2 -> ReportTwo(dataSource) +//// 3 -> ReportThree(dataSource) +// 4->DailyReportSummary() +// else -> ReportOne(dataSource) +// } +// val fileName = t.getReportName() +// val fName = URLEncoder.encode(fileName, "UTF-8") +// +// val p = Constant.DEFAULT_FILE_PATH + "/files/autoscore/" +// val file = File(p + fileName) +// if (config.forceUpdate || !file.exists()) { +// t.toFile(p) +// } - return SubTaskTableVo(titles, content) + return SubTaskTableVo(emptyList(), emptyList()) } override fun downloadPic(config: ExcelConfigVo, response: HttpServletResponse): HttpServletResponse { @@ -94,19 +187,19 @@ } } else { createCriteria() - .andEqualTo("tguid", config.topTaskGuid) - .andGreaterThanOrEqualTo("planstarttime", config.startTime) - .andLessThanOrEqualTo("planendtime", config.endTime).apply { - config.provinceCode?.let { - andEqualTo("provincecode", it) - } - config.cityCode?.let { - andEqualTo("citycode", it) - } - config.districtCode?.let { - andEqualTo("districtcode", it) - } + .andEqualTo("tguid", config.topTaskGuid) + .andGreaterThanOrEqualTo("planstarttime", config.startTime) + .andLessThanOrEqualTo("planendtime", config.endTime).apply { + config.provinceCode?.let { + andEqualTo("provincecode", it) } + config.cityCode?.let { + andEqualTo("citycode", it) + } + config.districtCode?.let { + andEqualTo("districtcode", it) + } + } } orderBy("planstarttime") } @@ -118,7 +211,7 @@ //鏍规嵁鍦烘櫙鏉′欢绛涢�� val need = if (config.sceneType != null) { - scene.typeid == config.sceneType.toByte() + scene.typeid == config.sceneType?.toByte() } else { true } @@ -153,8 +246,9 @@ } //寤虹珛绗竴灞傜洰褰曪紝鍖呭惈鎵�鏈夌殑浠诲姟 - val time = DateUtil().DateToString(Date(), "yyyy-MM-dd_HH-mm-ss") - var basePath = Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + "temp" + File.separator + time + val time = DateUtil.DateToString(Date(), "yyyy-MM-dd_HH-mm-ss") + var basePath = + imgPath + File.separator + "temp" + File.separator + time var file = File(basePath) var i = 1 while (file.exists() && i <= 100) { @@ -163,7 +257,7 @@ i++ } if (file.exists()) { - FileUtil().delAllFile(basePath) + FileUtil.delAllFile(basePath) } else { file.mkdirs() } @@ -180,7 +274,7 @@ i++ } if (sFile.exists()) { - FileUtil().delAllFile(subTaskFilePath) + FileUtil.delAllFile(subTaskFilePath) } else { sFile.mkdirs() } @@ -196,7 +290,7 @@ i++ } if (pFile.exists()) { - FileUtil().delAllFile(pPath) + FileUtil.delAllFile(pPath) } else { pFile.mkdirs() } @@ -205,11 +299,12 @@ mediafileMapper.selectByExample(Example(Mediafile::class.java).apply { createCriteria().andEqualTo("businessguid", p.guid) }).forEach { m -> - val picPath = Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + m.extension1 + m.guid + ".jpg" + val picPath = + imgPath + File.separator + m.extension1 + m.guid + ".jpg" val fromFile = File(picPath) val picName = p.problemname + "_" + p.location + "($y).jpg" val toFile = File(pPath + File.separator + picName) - FileUtil().copy(fromFile, toFile) + FileUtil.copy(fromFile, toFile) y++ } } @@ -241,15 +336,12 @@ return response } - override fun downloadPic2( - sceneType: Int, - topTaskId: String, - response: HttpServletResponse - ): HttpServletResponse { + override fun downloadPic2(sceneType: Int, topTaskId: String, response: HttpServletResponse): HttpServletResponse { //寤虹珛绗竴灞傜洰褰曪紝鍖呭惈鎵�鏈夌殑浠诲姟 val topTask = taskMapper.selectByPrimaryKey(topTaskId) - val time = DateUtil().DateToString(Date(), "yyyy-MM-dd_HH-mm-ss") - val basePath = Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + "temp" + File.separator + topTask.name + val time = DateUtil.DateToString(Date(), "yyyy-MM-dd_HH-mm-ss") + val basePath = + imgPath + File.separator + "temp" + File.separator + topTask.name val file = File(basePath) if (!file.exists()) { file.mkdirs() @@ -268,7 +360,7 @@ //寤虹珛涓�涓瓙浠诲姟鏂囦欢澶� var subTaskFilePath = "${basePath}${File.separator}(${ - dateUtil.DateToString( + DateUtil.DateToString( it.planstarttime, DateUtil.DateStyle.YYYY_MM_DD_CN ) @@ -281,7 +373,7 @@ i++ } if (sFile.exists()) { - FileUtil().delAllFile(subTaskFilePath) + FileUtil.delAllFile(subTaskFilePath) } else { sFile.mkdirs() } @@ -311,18 +403,18 @@ i++ } if (pFile.exists()) { - FileUtil().delAllFile(pPath) + FileUtil.delAllFile(pPath) } else { pFile.mkdirs() } u.forEach { f -> val picPath = - Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + f.extension1 + f.guid + ".jpg" + imgPath + File.separator + f.extension1 + f.guid + ".jpg" val fromFile = File(picPath) val picName = f.description val toFile = File(pPath + File.separator + picName) - FileUtil().copy(fromFile, toFile) + FileUtil.copy(fromFile, toFile) } } } @@ -358,7 +450,13 @@ return response } - override fun searchScore4JingAn(token: String, year: Int, month: Int, page: Int?, perPage: Int?): BaseResponse<List<ScoreVo>> { + override fun searchScore4JingAn( + token: String, + year: Int, + month: Int, + page: Int?, + perPage: Int?, + ): BaseResponse<List<ScoreVo>> { if (token != "jingan") { return BaseResponse(false) } @@ -381,305 +479,12 @@ return BaseResponse(true, head = DataHead(p.pageNum, p.pages), data = result) } - - - private fun getTableTitles(): List<String> = listOf( - "搴忓彿", "浠诲姟", "鍦烘櫙", "缁忓害", "绾害", - "绫诲瀷", - "寮�濮嬫椂闂�", "缁撴潫鏃堕棿", - "鐘舵��", "缁勯暱", - "缁勫憳", "闂绫诲瀷","闂璇︽儏", "琛楅晣", "瀹℃牳" - ) - - /** - * 鐩告瘮浜巊etTableContents() 锛屽垹鍑忎簡閮ㄥ垎鍒� - */ - private fun getTableTitles2(): List<String> = listOf( -// "搴忓彿", - "浠诲姟", -// "鍦烘櫙", "缁忓害", "绾害", - "绫诲瀷", - "寮�濮嬫椂闂�", -// "缁撴潫鏃堕棿", - "鐘舵��", "缁勯暱", - "缁勫憳", "闂绫诲瀷","闂璇︽儏", "琛楅晣", "瀹℃牳" - ) - - private fun getTableContents(config: ExcelConfigVo): List<Array<Any>> { - val townName = if (config.townCode == null) { - null - } else { - val l = townMapper.selectByExample(Example(Town::class.java).apply { - createCriteria().andEqualTo("towncode", config.townCode) - }) - if (l.isNotEmpty()) { - l[0].townname - } else { - null - } - } - val subTaskExample = Example(Subtask::class.java).apply { - if (config.subTaskIdList != null && config.subTaskIdList.isNotEmpty()) { - createCriteria().apply { - config.subTaskIdList.forEach { - orEqualTo("stguid", it) - } - } - } else { - createCriteria() - .andEqualTo("tguid", config.topTaskGuid) - .andGreaterThanOrEqualTo("planstarttime", config.startTime) - .andLessThanOrEqualTo("planendtime", config.endTime).apply { - config.provinceCode?.let { - andEqualTo("provincecode", it) - } - config.cityCode?.let { - andEqualTo("citycode", it) - } - config.districtCode?.let { - andEqualTo("districtcode", it) - } -// config.townCode?.let { -// andEqualTo("towncode", it) -// } - } - } - orderBy("planstarttime") - } - - val contents = mutableListOf<Array<Any>>() - - val subTasks = mutableListOf<Subtask>() - var i = 1 - subtaskMapper.selectByExample(subTaskExample).forEach { - //鏌ヨ璇ヤ换鍔″搴旂殑鍦烘櫙 - val scene = scenseMapper.selectByPrimaryKey(it.scenseid) - - //鏍规嵁鍦烘櫙鏉′欢绛涢�� - val need = if (config.sceneType != null) { - scene.typeid == config.sceneType.toByte() - } else { - true - } - if (need) { - //璁板綍鏌ヨ鍒板瓙浠诲姟 - subTasks.add(it) - - val problemTypes = mutableListOf<String>() - val problems = mutableListOf<String>() - val districts = mutableListOf<String>() - val checkStatus= mutableListOf<String>() - - //鏌ヨ瀛愪换鍔″搴旂殑闂锛屽苟涓旀牴鎹潯浠惰繘琛岀瓫閫� - val problemlistExample = Example(Problemlist::class.java).apply { - createCriteria().andEqualTo("stguid", it.stguid).apply { - config.problemName?.let {p-> - andEqualTo("problemname", p) - } - townName?.let {t-> - andLike("location", "%$t%") - } - } - } - - var y=1 - problemlistMapper.selectByExample(problemlistExample).forEach problemType@{p-> - val result = problemtypeMapper.selectByPrimaryKey(p.ptguid) - if (config.problemTypeName != null) { - if (result.typename != config.problemTypeName) { - return@problemType - } - } - problemTypes.add(result.typename ?: "") - problems.add("$y銆�${p.problemname}") - districts.add(p.location ?: "") - val status = when (p.extension3) { - Constant.PROBLEM_UNCHECKED -> "鏈鏍�" - Constant.PROBLEM_CHECK_PASS-> "閫氳繃" - Constant.PROBLEM_CHECK_FAIL -> "鏈�氳繃" - else->"鏈鏍�" - } - checkStatus.add(status) - y++ - } - - - //褰撴湁闂浣滀负绛涢�夋潯浠舵椂锛屽鏋滄病鏈夋壘鍒板搴旈棶棰橈紝鍒欒娆′换鍔″幓闄� - if ( (config.problemTypeName != null || config.problemName != null || townName != null) - && (problemTypes.isEmpty() && problems.isEmpty())) { - return@forEach - } - - val rowContent = arrayOf<Any>( - "$i", it.name ?: "", it.scensename ?: "", scene.longitude.toString(), scene.latitude.toString(), - scene.type ?: "", - DateUtil().DateToString(it.executionstarttime, "yyyy-MM-dd HH:mm:ss") ?: "", DateUtil().DateToString(it.executionendtime, "yyyy-MM-dd hh:mm:ss") ?: "", - it.status ?: "", it.assessorrealname?.replace("#", "銆�") ?: "", - it.executorrealtimes?.replace("#", "銆�") ?: "", problemTypes.toTypedArray(), problems.toTypedArray(), districts.toTypedArray(), checkStatus.toTypedArray() - ) - - contents.add(rowContent) - i++ - } - } - - return contents - } - - /** - * 鐩告瘮浜巊etTableContents() 锛屽垹鍑忎簡閮ㄥ垎鍒� - */ - private fun getTableContents2(config: ExcelConfigVo): List<Array<Any>> { - val townName = if (config.townCode == null) { - null - } else { - val l = townMapper.selectByExample(Example(Town::class.java).apply { - createCriteria().andEqualTo("towncode", config.townCode) - }) - if (l.isNotEmpty()) { - l[0].townname - } else { - null - } - } - val subTaskExample = Example(Subtask::class.java).apply { - if (config.subTaskIdList != null && config.subTaskIdList.isNotEmpty()) { - createCriteria().apply { - config.subTaskIdList.forEach { - orEqualTo("stguid", it) - } - } - } else { - createCriteria() - .andEqualTo("tguid", config.topTaskGuid) - .andGreaterThanOrEqualTo("planstarttime", config.startTime) - .andLessThanOrEqualTo("planendtime", config.endTime).apply { - config.provinceCode?.let { - andEqualTo("provincecode", it) - } - config.cityCode?.let { - andEqualTo("citycode", it) - } - config.districtCode?.let { - andEqualTo("districtcode", it) - } -// config.townCode?.let { -// andEqualTo("towncode", it) -// } - } - } - orderBy("planstarttime") - } - - val contents = mutableListOf<Array<Any>>() - - val subTasks = mutableListOf<Subtask>() - var i = 1 - subtaskMapper.selectByExample(subTaskExample).forEach { - //鏌ヨ璇ヤ换鍔″搴旂殑鍦烘櫙 - val scene = scenseMapper.selectByPrimaryKey(it.scenseid) - - //鏍规嵁鍦烘櫙鏉′欢绛涢�� - val need = if (config.sceneType != null) { - scene.typeid == config.sceneType.toByte() - } else { - true - } - if (need) { - //璁板綍鏌ヨ鍒板瓙浠诲姟 - subTasks.add(it) - - val problemTypes = mutableListOf<String>() - val problems = mutableListOf<String>() - val districts = mutableListOf<String>() - val checkStatus= mutableListOf<String>() - - //鏌ヨ瀛愪换鍔″搴旂殑闂锛屽苟涓旀牴鎹潯浠惰繘琛岀瓫閫� - val problemlistExample = Example(Problemlist::class.java).apply { - createCriteria().andEqualTo("stguid", it.stguid).apply { - config.problemName?.let {p-> - andEqualTo("problemname", p) - } - townName?.let {t-> - andLike("location", "%$t%") - } - } - } - - var y=1 - problemlistMapper.selectByExample(problemlistExample).forEach problemType@{p-> - val result = problemtypeMapper.selectByPrimaryKey(p.ptguid) - if (config.problemTypeName != null) { - if (result?.typename != config.problemTypeName) { - return@problemType - } - } - problemTypes.add(result?.typename ?: "") - problems.add("$y銆�${p.problemname}") - districts.add(p.location ?: "") - val status = when (p.extension3) { - Constant.PROBLEM_UNCHECKED -> "鏈鏍�" - Constant.PROBLEM_CHECK_PASS-> "閫氳繃" - Constant.PROBLEM_CHECK_FAIL -> "鏈�氳繃" - else->"鏈鏍�" - } - checkStatus.add(status) - y++ - } - - - //褰撴湁闂浣滀负绛涢�夋潯浠舵椂锛屽鏋滄病鏈夋壘鍒板搴旈棶棰橈紝鍒欒娆′换鍔″幓闄� - if ( (config.problemTypeName != null || config.problemName != null || townName != null) - && (problemTypes.isEmpty() && problems.isEmpty())) { - return@forEach - } - -// val lineMaxSize =3 -// -// val leader = it.assessorrealname?.split("#") -// val leaderStr = StringBuilder() -// for (t in 0 until (leader?.size ?: 0)) { -// if (t > 0) { -// leaderStr.append("銆�") -// } -// if (t == lineMaxSize - 1) { -// leaderStr.append("\r\n") -// } -// leaderStr.append(leader?.get(t)) -// } -// -// val member = it.executorrealtimes?.split("#") -// val memberStr = StringBuilder() -// for (t in 0 until (member?.size ?: 0)) { -// if (t > 0) { -// memberStr.append("銆�") -// } -// if (t == lineMaxSize - 1) { -// memberStr.append("\r\n") -// } -// memberStr.append(member?.get(t)) -// } - - val rowContent = arrayOf<Any>( -// "$i", - it.name ?: "", -// it.scensename ?: "", scene.longitude.toString(), scene.latitude.toString(), - scene.type ?: "", - DateUtil().DateToString(it.executionstarttime, "yyyy-MM-dd HH:mm:ss") ?: "", -// DateUtil().DateToString(it.executionendtime, "yyyy-MM-dd hh:mm:ss") ?: "", - it.status ?: "", it.assessorrealname?.replace("#", "銆�") ?: "", - it.executorrealtimes?.replace("#", "銆�") ?: "", problemTypes.toTypedArray(), problems.toTypedArray(), districts.toTypedArray(), checkStatus.toTypedArray() - ) - - contents.add(rowContent) - i++ - } - } - - return contents - } - - override fun searchSubTaskByKeyword(userId: String, keyword: String, page: Int, perPage: Int): BaseResponse<List<SubtaskVo>> { + override fun searchSubTaskByKeyword( + userId: String, + keyword: String, + page: Int, + perPage: Int, + ): BaseResponse<List<SubtaskVo>> { val userInfo = userinfoMapper.selectByPrimaryKey(userId) if (userInfo.usertypeid?.toInt() == 3) return BaseResponse(false, "浼佷笟鐢ㄦ埛鏃犳煡璇㈡潈闄�")//浼佷笟鐢ㄦ埛鏃犳硶鏌ヨ val result = mutableListOf<SubtaskVo>() @@ -688,7 +493,8 @@ createCriteria().andLike("name", "%${keyword}%") .apply { when (userInfo.usertypeid?.toInt()) { - 0 -> {} //绠$悊鍛樼敤鎴锋煡璇㈡棤鍏朵粬闄愬埗 + 0 -> { + } //绠$悊鍛樼敤鎴锋煡璇㈡棤鍏朵粬闄愬埗 1 -> andLike("executorguids", "%${userId}%")//瀵逛簬涓�鑸殑宸℃煡浜哄憳锛屽彧鑳芥煡璇㈠埌鑷繁鍙備笌鐨勫瓙浠诲姟 2 -> andEqualTo("districtcode", userInfo.dGuid)//姝ゅ瀵逛簬鏀垮簻鐢ㄦ埛锛宒Guid瀛樺偍鐨勬槸鍖哄幙缂栧彿 } @@ -700,6 +506,73 @@ result.add(vo) } - return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages) ,data = result) + return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages), data = result) + } + + override fun getDailyReport(config: ExcelConfigVo): BaseTableVo { + if (config.districtCode == null || config.startTime == null) return BaseTableVo(emptyList(), emptyList()) + + val dbMapper = DbMapper( + scenseMapper, + problemlistMapper, + problemtypeMapper, + subtaskMapper, + monitorobjectversionMapper, + sceneConstructionSiteMapper, + sceneMixingPlantMapper, + sceneStorageYardMapper, + sceneWharfMapper, + taskMapper, + evaluationruleMapper, evaluationsubruleMapper, evaluationMapper, itemevaluationMapper, + ledgerSubTypeMapper, ledgerRecordMapper, userinfoMapper, userMapMapper, townMapper + ) + val task = + taskService.getByDistrictCode(config.districtCode, config.startTime).takeIf { it.isNotEmpty() }?.get(0) + config.topTaskGuid = task?.tguid ?: "" + config.allScene = false + val dataSource = mutableListOf<DataSource>() +// config.sceneType = Constant.SceneType.TYPE1.value.toInt() + dataSource.add(DataSource(config, dbMapper)) + +// val config2 = config.copy(sceneType = Constant.ScenseType.TYPE2.value.toInt()) +// dataSource.add(DataSource(config2, dbMapper)) +// +// val config3 = config.copy(sceneType = Constant.ScenseType.TYPE3.value.toInt()) +// dataSource.add(DataSource(config3, dbMapper)) +// +// val config4 = config.copy(sceneType = Constant.ScenseType.TYPE14.value.toInt()) +// dataSource.add(DataSource(config4, dbMapper)) + + val t = DailyReportSummary(dataSource) + t.execute() + val result = t.toTableRows() + + return BaseTableVo(result.first, result.second) + } + + override fun getScoreDetail(subTaskId: String): ScoreDetail { + //鍦烘櫙淇℃伅 + val scene = sceneRep.findBySubTask(subTaskId) + //鎬诲垎 + val evaluation = evaluationRep.findBySubtask(subTaskId) + //瀛愯鍒欓�愭潯寰楀垎 + val subRuleScores = evaluationRep.findItemEvaluation(subTaskId) + if (subRuleScores.isEmpty()) throw BizException("鏃犺瘎浼拌褰�") + //璇勫垎鎬昏鍒� + val rule = evaluationRuleRep.findAutoEvaluationRule(subTaskId) ?: throw BizException("鏈壘鍒扮浉鍏宠嚜鍔ㄨ瘎浼拌鍒�") + //鎬昏鍒欏搴旂殑璇勫垎瀛愯鍒� + val subRules = evaluationRuleRep.findSubRule(rule.guid) + //鏌ヨ缁撴灉 + val result = ScoreDetail() + result.status = if (scene?.extension1.equals("1")) "鍦ㄥ缓" else "瀹屽伐" + + result.updateTime = evaluation?.updatedate + subRules.forEach { + it.ertype ?: return@forEach + result.addDetail(result.details, it, it.ertype!! - 1, subRuleScores, true) + } + result.calScore() + + return result } } \ No newline at end of file -- Gitblit v1.9.3