From 82baf5d28ce79aa4d3b64956207d247596726924 Mon Sep 17 00:00:00 2001
From: hcong <1050828145@qq.com>
Date: 星期二, 10 十二月 2024 11:21:33 +0800
Subject: [PATCH] 1. BgTaskStatus状态属性序列化
---
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt | 120 ++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 93 insertions(+), 27 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt
index b7db654..278aa8c 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt
@@ -1,11 +1,14 @@
package cn.flightfeather.supervision.lightshare.service.impl
import cn.flightfeather.supervision.business.AutoScore2
-import cn.flightfeather.supervision.business.autooutput.AopTaskCtrl
+import cn.flightfeather.supervision.business.bgtask.AopTaskCtrl
import cn.flightfeather.supervision.business.autooutput.score.AopEvaluation
-import cn.flightfeather.supervision.common.executor.BackgroundTaskCtrl
+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.ReportTwo
+import cn.flightfeather.supervision.common.exception.BizException
import cn.flightfeather.supervision.common.executor.BgTaskStatus
-import cn.flightfeather.supervision.common.executor.BgTaskType
import cn.flightfeather.supervision.domain.ds1.entity.Domainitem
import cn.flightfeather.supervision.domain.ds1.entity.Evaluation
import cn.flightfeather.supervision.domain.ds1.entity.Subtask
@@ -18,15 +21,17 @@
import cn.flightfeather.supervision.domain.ds1.repository.EvaluationRep
import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
import cn.flightfeather.supervision.lightshare.service.EvaluationService
+import cn.flightfeather.supervision.lightshare.service.SearchService
import cn.flightfeather.supervision.lightshare.service.SubtaskService
-import cn.flightfeather.supervision.lightshare.vo.AreaVo
-import cn.flightfeather.supervision.lightshare.vo.AutoScoreResultVo
-import cn.flightfeather.supervision.lightshare.vo.BaseResponse
-import cn.flightfeather.supervision.lightshare.vo.EvaluateResVo
+import cn.flightfeather.supervision.lightshare.vo.*
import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Service
+import org.springframework.web.multipart.MultipartFile
import tk.mybatis.mapper.entity.Example
+import java.io.File
import java.util.*
+import javax.servlet.http.HttpServletResponse
import kotlin.Comparator
@Service
@@ -35,14 +40,20 @@
private val evaluationRep: EvaluationRep,
private val taskRep: TaskRep,
private val aopTaskCtrl: AopTaskCtrl,
+ private val dbMapper: DbMapper,
+ @Value("\${filePath}") private val filePath: String,
+ private val reportTaskCtrl: ReportTaskCtrl,
) : EvaluationService {
@Autowired
lateinit var subtaskService: SubtaskService
+
@Autowired
lateinit var domainitemMapper: DomainitemMapper
+
@Autowired
lateinit var subtaskMapper: SubtaskMapper
+
@Autowired
lateinit var aopEvaluation: AopEvaluation
private var isAutoScoreRunning = false
@@ -53,12 +64,13 @@
var areaVolist = mutableListOf<EvaluateResVo>()
//鑰冩牳绫诲瀷鏄鑼冭�冩牳
if (evaluationlist.isNotEmpty() &&
- Objects.equals(evaluationlist.get(0).ertype, Constant.RuleType.STANDARD.value)) {
+ Objects.equals(evaluationlist.get(0).ertype, Constant.RuleType.STANDARD.value)
+ ) {
//鑾峰彇瑙勮寖鑰冩牳鐨勮�冩牳鐣岄檺锛堥棶棰樻暟閲忥級
val example = Example(Domainitem::class.java)
val criteria = example.createCriteria()
criteria.andEqualTo("dcguid", Domain.STANDARDLEVEL.value)
- val standardlevel:String? = domainitemMapper.selectByExample(example).get(0).value
+ val standardlevel: String? = domainitemMapper.selectByExample(example).get(0).value
//鎸夎闀囪绠椾弗閲嶄笉瑙勮寖鍦烘櫙鏁伴噺骞舵寜鐧惧垎姣旀帓搴�
while (evaluationlist.isNotEmpty()) {
val tmplist = mutableListOf<Evaluation>()
@@ -68,9 +80,9 @@
val evaluation = evaluationlist.get(0)//鑾峰彇涓�绉嶈闀�
var areaVo = EvaluateResVo()
areaVo = transform(areaVo, evaluation)
- while (iterator.hasNext()){
+ while (iterator.hasNext()) {
val tmp = iterator.next()
- if (Objects.equals(tmp.towncode, evaluation.towncode)){
+ if (Objects.equals(tmp.towncode, evaluation.towncode)) {
if (tmp.resultscorebef!!.toInt() >= standardlevel!!.toInt())
areaVo.notstandardnum++
areaVo.allsensenum++
@@ -84,7 +96,8 @@
}
//鑰冩牳绫诲瀷鏄瘎鍒嗚�冩牳
else if (evaluationlist.isNotEmpty() &&
- Objects.equals(evaluationlist.get(0).ertype, Constant.RuleType.SCORE.value)){
+ Objects.equals(evaluationlist.get(0).ertype, Constant.RuleType.SCORE.value)
+ ) {
//鑾峰彇璇勫垎鑰冩牳鐨勮瘎鍒嗙晫闄�
val example = Example(Domainitem::class.java)
val criteria = example.createCriteria()
@@ -100,7 +113,7 @@
val evaluation = evaluationlist.get(0)//鑾峰彇涓�绉嶈闀�
var areaVo = EvaluateResVo()
areaVo = transform(areaVo, evaluation)
- while (iterator.hasNext()){
+ while (iterator.hasNext()) {
val tmp = iterator.next()
if (Objects.equals(tmp.towncode, evaluation.towncode)) {
if (tmp.resultscorebef!!.toInt() < scorelevellist.get(scorelevellist.size - 1).text!!.toInt())
@@ -136,7 +149,7 @@
override fun delete(id: String): Int = evaluationMapper.deleteByPrimaryKey(id)
//鑾峰彇鎸囧畾鍖哄煙锛堥《灞備换鍔★級鎸囧畾鍦烘櫙鐨勮瘎鍒嗕俊鎭�
- fun getRankInfo(tguid: String, scensetypeid: String?, ruletypeid: ByteArray?):MutableList<Evaluation>{
+ fun getRankInfo(tguid: String, scensetypeid: String?, ruletypeid: ByteArray?): MutableList<Evaluation> {
val evaluationlist = mutableListOf<Evaluation>()
val subtaskVolist = subtaskService.findByTaskID(tguid)
subtaskVolist.forEach {
@@ -148,11 +161,11 @@
criteria.andEqualTo("scensetypeid", scensetypeid)
if (ruletypeid != null)//璇勫垎绫诲瀷
criteria.andEqualTo("ertype", ruletypeid)
- else{
+ else {
criteria.andEqualTo("ertype", Constant.RuleType.STANDARD.value)
val result = evaluationMapper.selectByExample(example)//鏌ヨ鏄惁鏈夎鑼冩�ц瘎鍒嗚〃
//娌℃湁瑙勮寖琛ㄥ氨鏌ヨ璇勫垎琛�
- if (result.isEmpty()){
+ if (result.isEmpty()) {
val example1 = Example(Evaluation::class.java)
val criteria1 = example1.createCriteria()
criteria1.andEqualTo("stguid", it.stguid)//瀛愪换鍔d
@@ -162,8 +175,7 @@
val result1 = evaluationMapper.selectByExample(example1)
if (result1.size == 1)
evaluationlist.add(result1.get(0))
- }
- else
+ } else
if (result.size == 1)
evaluationlist.add(result.get(0))
}
@@ -172,7 +184,7 @@
}
//Evaluation浼犻�掓暟鎹粰AreaVo
- fun transform(areaVo: EvaluateResVo, evaluation: Evaluation):EvaluateResVo{
+ fun transform(areaVo: EvaluateResVo, evaluation: Evaluation): EvaluateResVo {
areaVo.provincecode = evaluation.provincecode
areaVo.provincename = evaluation.provincename
areaVo.citycode = evaluation.citycode
@@ -185,15 +197,15 @@
}
//鎸夎閬撲弗閲嶄笉瑙勮寖鍦烘櫙鐧惧垎姣旀帓搴�
- fun sort(areaVolist: MutableList<EvaluateResVo>):MutableList<EvaluateResVo>{
- Collections.sort(areaVolist, object : Comparator<EvaluateResVo>{
+ fun sort(areaVolist: MutableList<EvaluateResVo>): MutableList<EvaluateResVo> {
+ Collections.sort(areaVolist, object : Comparator<EvaluateResVo> {
override fun compare(o1: EvaluateResVo?, o2: EvaluateResVo?): Int {
var num1 = 0.0
if (o1!!.allsensenum != 0)
- num1 = (o1.notstandardnum/o1.allsensenum).toDouble()
+ num1 = (o1.notstandardnum / o1.allsensenum).toDouble()
var num2 = 0.0
if (o2!!.allsensenum != 0)
- num2 = (o2.notstandardnum/o2.allsensenum).toDouble()
+ num2 = (o2.notstandardnum / o2.allsensenum).toDouble()
return compareValues(num1, num2)
}
})
@@ -206,7 +218,7 @@
val example = Example(Subtask::class.java)
val criteria = example.createCriteria()
criteria.andEqualTo("districtcode", districtCode)
- val date = DateUtil().StringToDate(time)
+ val date = DateUtil.StringToDate(time)
criteria.andGreaterThanOrEqualTo("planstarttime", time)
val subTaskList = subtaskMapper.selectByExample(example)
subTaskList.forEach {
@@ -270,8 +282,62 @@
override fun findAutoEvaluation(areaVo: AreaVo): List<AutoScoreResultVo?>? {
//1. 鏌ユ壘鍘嗗彶璁板綍锛屾煡鐪嬭瘎浼版槸鍚﹀凡瀛樺湪
- areaVo.scensetypeid ?: throw IllegalStateException("鏌ヨ鏃跺繀椤婚�夋嫨涓�涓満鏅被鍨�")
- val task = taskRep.findOneTask(areaVo) ?: throw IllegalStateException("鏌ヨ鏃跺繀椤婚�夋嫨涓�涓満鏅被鍨�")
- return evaluationRep.findAutoScore(areaVo)
+// areaVo.scensetypeid ?: throw ResponseErrorException("鏌ヨ鏃跺繀椤婚�夋嫨涓�涓満鏅被鍨�")
+// val task = taskRep.findOneTask(areaVo) ?: throw ResponseErrorException("鏌ヨ鏃跺繀椤婚�夋嫨涓�涓満鏅被鍨�")
+ val evaList = evaluationRep.findAutoScore(areaVo)
+ evaList?.forEach {
+ it?.subTaskId?.let { id->
+ it.itemEvaluations = evaluationRep.findItemEvaluation(id)
+ }
+ }
+ return evaList
+ }
+
+ override fun downloadAutoEvaluation(areaVo: AreaVo, forceUpdate: Boolean, response: HttpServletResponse): Boolean {
+ areaVo.scensetypeid ?: throw BizException("蹇呴』閫夋嫨涓�涓満鏅被鍨�")
+ val topTask = taskRep.findOneTask(areaVo) ?: throw BizException("鏈壘鍒扮鍚堟潯浠剁殑椤跺眰浠诲姟")
+ val config = ExcelConfigVo(
+ topTask.tguid ?: "",
+ topTask.starttime,
+ topTask.endtime,
+ topTask.provincecode,
+ topTask.citycode,
+ topTask.districtcode,
+ topTask.towncode,
+ areaVo.scensetypeid?.toInt(),
+ forceUpdate = forceUpdate
+ )
+
+ val dataSource = DataSource(config, dbMapper)
+ val t = ReportTwo(dataSource)
+ 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 downloadAutoEvaTemplate(areaVo: AreaVo, response: HttpServletResponse) {
+ TODO("Not yet implemented")
+ }
+
+ override fun uploadAutoEvaluation(areaVo: AreaVo, file: MultipartFile): Boolean {
+ TODO("Not yet implemented")
}
}
\ No newline at end of file
--
Gitblit v1.9.3