Riku
2024-09-28 bda3bf8923acb5216f6f46b5d903cac24c842143
1. 新增监测数据得分批量更新接口(待完成)
已修改5个文件
已添加1个文件
68 ■■■■■ 文件已修改
src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ItemevaluationService.kt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ItemevaluationServiceImpl.kt 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaEvaVo.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/EvaluationUpdateVo.kt 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ItemevaluationController.kt 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt
@@ -7,6 +7,7 @@
import cn.flightfeather.supervision.domain.ds2.entity.LedgerSubType
import cn.flightfeather.supervision.domain.ds2.entity.UserMap
import cn.flightfeather.supervision.domain.ds2.entity.UserinfoTZ
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import cn.flightfeather.supervision.lightshare.vo.EvaluationSubRuleVo
import org.springframework.beans.BeanUtils
import tk.mybatis.mapper.entity.Example
@@ -39,6 +40,12 @@
        }
    }
//    fun setResource(areaVo: AreaVo) {
//        val task = taskRep.findOneTask(areaVo)
//        val taskId = task?.tguid
//        val sceneType = areaVo.scensetypeid?.toInt() ?: throw BizException("场景类型未设置,无法评估")
//    }
    fun setResource(config: AopDataConfig) {
        config.sceneType ?: return
        evaluationScene.config = config
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ItemevaluationService.kt
@@ -1,6 +1,8 @@
package cn.flightfeather.supervision.lightshare.service
import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import cn.flightfeather.supervision.lightshare.vo.EvaluationUpdateVo
import cn.flightfeather.supervision.lightshare.vo.ItemEvaluationVo
@@ -29,4 +31,6 @@
    fun createItemEvaluation(subTaskId: String, ruleId: String?, itemList: List<String>): Boolean
    fun updateItemEvaluation(subTaskId: String, ruleId: String?, itemList: List<String>): Boolean
    fun updateMonitorDataEva(evaVo: EvaluationUpdateVo): Boolean
}
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ItemevaluationServiceImpl.kt
@@ -9,7 +9,10 @@
import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation
import cn.flightfeather.supervision.domain.ds1.mapper.ItemevaluationMapper
import cn.flightfeather.supervision.domain.ds1.repository.SubTaskRep
import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
import cn.flightfeather.supervision.lightshare.service.ItemevaluationService
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import cn.flightfeather.supervision.lightshare.vo.EvaluationUpdateVo
import cn.flightfeather.supervision.lightshare.vo.ItemEvaluationVo
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Service
@@ -22,6 +25,7 @@
    private val aopOutput: AopOutput,
    private val aopSceneTypeCheck: AopSceneTypeCheck,
    private val subTaskRep: SubTaskRep,
    private val taskRep: TaskRep,
) : ItemevaluationService {
    //批量修改单项评估
@@ -106,4 +110,24 @@
            throw BizException("出现系统内部错误")
        }
    }
    override fun updateMonitorDataEva(evaVo: EvaluationUpdateVo): Boolean {
        val task = taskRep.findOneTask(evaVo)
        val taskId = task?.tguid
        val sceneType = evaVo.scensetypeid?.toInt() ?: throw BizException("场景类型未设置,无法更新分数")
        val source = AopDataSource(aopDbMapper, aopSceneTypeCheck)
        source.setResource(taskId, sceneType, null, null)
        try {
            source.loop() { _, evaluationScene ->
                if (evaluationScene.noRecord()) throw BizException("巡查任务不存在")
                // å°†åˆ†æ•°èµ‹å€¼åˆ°å¯¹åº”的评估规则下,并且自动计算其余规则的得分
                ScoreUtil.scoreAssign(evaluationScene, itemList)
                // èŽ·å–æ€»åˆ†å’Œå­é¡¹å¾—åˆ†æ•°æ®åº“è¡¨ç»“æž„ä½“ï¼Œå¹¶å…¥åº“
                ScoreUtil.updateEvaRecord(evaluationScene)?.let { aopOutput.updateDbEvaluation(evaluationScene, it) }
            }
            return true
        } catch (e: Exception) {
            throw BizException("出现系统内部错误")
        }
    }
}
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaEvaVo.kt
@@ -6,7 +6,7 @@
 * è¯„估规则查询条件
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
class AreaEvaVo : AreaVo() {
open class AreaEvaVo : AreaVo() {
    // è¯„估规则类型,1:巡查情况评估;99:自动评估
    var taskTypeId: Int = 1
}
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/EvaluationUpdateVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
package cn.flightfeather.supervision.lightshare.vo
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty
/**
 * å·¡æŸ¥ä»»åŠ¡ç›‘æµ‹æ•°æ®å¼‚å¸¸æ‰£åˆ†
 * @date 2024/9/28
 * @author feiyu02
 */
@ApiModel("巡查任务监测数据异常扣分")
class EvaluationUpdateVo : AreaEvaVo() {
    @ApiModelProperty("巡查任务主键")
    var subTaskId: String? = null
    @ApiModelProperty("评估规则id")
    var ruleId: String? = null
    @ApiModelProperty("具体评估条目是否勾选", notes = "对象结构为评估条目的主键和是否勾选形成的键值对列表")
    var subRule: List<Pair<String, Boolean>>? = null
}
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ItemevaluationController.kt
@@ -3,12 +3,11 @@
import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation
import cn.flightfeather.supervision.lightshare.service.ItemevaluationService
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import cn.flightfeather.supervision.lightshare.vo.EvaluationUpdateVo
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.web.bind.annotation.*
import springfox.documentation.annotations.ApiIgnore
import javax.servlet.http.HttpServletResponse
@Api(tags = ["ItemevaluationController"], description = "评估子项得分API接口")
@RestController
@@ -55,4 +54,10 @@
        @RequestParam(required = false) ruleId: String?,
        @ApiParam(value = "具体扣分条目主键(只传最小级别的评估项)") @RequestBody itemList: List<String>,
    ) = resPack { itemevaluationService.updateItemEvaluation(subTaskId, ruleId, itemList) }
    @ApiOperation(value = "批量更新评估结果")
    @PostMapping("/update/multiple")
    fun updateMonitorDataEva(
        @ApiParam("得分修改细节") @RequestBody evaVo: EvaluationUpdateVo,
    ) = resPack { itemevaluationService.updateMonitorDataEva(evaVo) }
}