src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt
@@ -6,9 +6,12 @@
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.ds2.mapper.LedgerRecordMapper
import cn.flightfeather.supervision.domain.ds2.mapper.LedgerSubTypeMapper
import cn.flightfeather.supervision.domain.ds2.mapper.UserMapMapper
@@ -57,8 +60,10 @@
        val ledgerRecordMapper: LedgerRecordMapper,
        val userMapMapper: UserMapMapper,
        val taskService: TaskService,
    private val evaluationRep: EvaluationRep,
    private val evaluationRuleRep: EvaluationRuleRep,
        @Value("\${filePath}") var filePath: String,
        @Value("\${imgPath}") var imgPath: String
    @Value("\${imgPath}") var imgPath: String,
) : SearchService {
    private val dateUtil = DateUtil()
@@ -252,7 +257,8 @@
        //建立第一层目录,包含所有的任务
        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
        var basePath =
            Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + "temp" + File.separator + time
        var file = File(basePath)
        var i = 1
        while (file.exists() && i <= 100) {
@@ -303,7 +309,8 @@
                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 =
                        Constant.DEFAULT_FILE_PATH + File.separator + "images" + 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)
@@ -343,7 +350,8 @@
        //建立第一层目录,包含所有的任务
        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 basePath =
            Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + "temp" + File.separator + topTask.name
        val file = File(basePath)
        if (!file.exists()) {
            file.mkdirs()
@@ -452,7 +460,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)
        }
@@ -475,7 +489,12 @@
        return BaseResponse(true, head = DataHead(p.pageNum, p.pages), data = result)
    }
    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>()
@@ -517,7 +536,8 @@
            evaluationruleMapper, evaluationsubruleMapper, evaluationMapper, itemevaluationMapper,
            ledgerSubTypeMapper, ledgerRecordMapper, userinfoMapper, userMapMapper, townMapper
        )
        val task = taskService.getByDistrictCode(config.districtCode, config.startTime)?.takeIf { it.isNotEmpty() }?.get(0)
        val task =
            taskService.getByDistrictCode(config.districtCode, config.startTime)?.takeIf { it.isNotEmpty() }?.get(0)
        config.topTaskGuid = task?.tguid ?: ""
        val dataSource = mutableListOf<DataSource>()
        config.sceneType = Constant.SceneType.TYPE1.value.toInt()
@@ -538,4 +558,23 @@
        return BaseTableVo(result.first, result.second)
    }
    override fun getScoreDetail(subTaskId: String): ScoreDetail {
        //子规则逐条得分
        val subRuleScores = evaluationRep.findItemEvaluation(subTaskId)
        //评分总规则
        val rule = evaluationRuleRep.findAutoEvaluationRule(subTaskId) ?: throw BizException("未找到相关自动评估规则")
        //总规则对应的评分子规则
        val subRules = evaluationRuleRep.findSubRule(rule.guid)
        //查询结果
        val result = ScoreDetail()
        subRules.forEach {
            it.ertype ?: return@forEach
            result.addDetail(result.details, it, it.ertype!! - 1, subRuleScores, true)
        }
        result.calScore()
        return result
    }
}