feiyu02
2025-09-30 6904763f0e74d9a9fa4dbc39f635d2aee39416c6
2025.9.30
已修改12个文件
78 ■■■■■ 文件已修改
src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/bgtask/TaskController.kt 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/bgtask/maintenance/MTJinAnHourlyDustData.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/common/risk/RiskAssessment.kt 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/common/score/EvaluationUtil.kt 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/config/CorsConfig.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/config/WebMvcConfig.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/CORSFilter.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/RiskServiceImpl.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ConfigController.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/scheduler/ScheduleService.kt 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/cn/flightfeather/supervision/bgtask/maintenance/MTJinAnHourlyDustDataTest.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt
@@ -32,11 +32,12 @@
        taskController.run()
        // 2023.8.20 应用于安卓app后台,后续应该合并于小程序后台
        if (mode == "proapp") {
            webSocketServer.start()
//            webSocketServer.start()
        }
        // 应用于微信小程序后台
        else if (mode == "pro") {
            wxTokenManager.run()
            webSocketServer.start()
        }
        println("mode: $mode")
    }
src/main/kotlin/cn/flightfeather/supervision/bgtask/TaskController.kt
@@ -45,9 +45,11 @@
        timeTask.clear()
        //飞羽环境,获取voc数据、推送油烟数据
        if (mode == "proapp") {
//            timeTask.add(fetchVOC)
//            timeTask.add(pushFume)
        } else if (mode == "pro") {
            timeTask.add(fetchVOC)
            timeTask.add(pushFume)
        } else if (mode == "pro") {
            //微信小程序(中小企业守法自助),台账复制、定时任务推送等
//        timeTask.add(ledgerCopy)
            timeTask.add(ledgerRemind)
src/main/kotlin/cn/flightfeather/supervision/bgtask/maintenance/MTJinAnHourlyDustData.kt
@@ -28,7 +28,7 @@
     */
    fun handle() {
        val end = LocalDate.now().atStartOfDay()
        val start = end.minusDays(7)
        val start = end.withDayOfMonth(1)
        handle(start, end)
    }
src/main/kotlin/cn/flightfeather/supervision/common/risk/RiskAssessment.kt
@@ -2,6 +2,7 @@
import cn.flightfeather.supervision.common.score.EvaluationUtil
import cn.flightfeather.supervision.domain.entity.Evaluation
import cn.flightfeather.supervision.domain.entity.Evaluationrule
import cn.flightfeather.supervision.domain.entity.Userinfo
import cn.flightfeather.supervision.infrastructure.utils.DateUtil
import com.github.pagehelper.PageHelper
@@ -33,24 +34,33 @@
    fun getResult(user: Userinfo, config: DataSource.Config, dbMapper: DbMapper): Triple<Boolean, Int?, String> {
        reset()
        val sTime = LocalDateTime.of(config.year, config.month, 1, 0, 0, 0, 0)
        val eTime = sTime.plusMonths(1)
        val rule = dbMapper.evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply {
            createCriteria().andEqualTo("scensetypeid", config.sceneType)
                .andEqualTo("ruletype", 0)
        }).takeIf { it.isNotEmpty() }?.get(0)
        // 根据评估的提交周期(单位:月),计算对应的月份范围
        val period = rule?.scensesubtypeid?.toInt() ?: 1
        // 提交周期下的起止月份
        val startM = DateUtil.getStartMonthByPeriod(config.month, period)
        val endM = startM?.plus(period)?.minus(1)
        // 查询开始时间为周期下的首个月份
        val sTime = LocalDateTime.of(config.year, startM ?: config.month, 1, 0, 0, 0, 0)
        // 查询结束时间为统计的月份
        val eTime = LocalDateTime.of(config.year, config.month, 1, 0, 0, 0, 0)
            .plusMonths(1).minusSeconds(1)
        PageHelper.startPage<Evaluation>(1, 1)
        val result = dbMapper.evaluationMapper.selectByExample((Example(Evaluation::class.java).apply {
            createCriteria().andEqualTo("evaluatorguid", user.guid)
                .andEqualTo("ertype", 0)
//                .andBetween("createdate", sTime, eTime)
                .andBetween("createdate", sTime, eTime)
            orderBy("createdate").desc()
        }))
        if (result.isEmpty()) {
            return Triple(false, null, "/")
        } else {
            val rule = dbMapper.evaluationruleMapper.selectByPrimaryKey(result[0].stguid)
            totalScore = rule.resultrange?.toInt() ?: 0
            // 根据评估的提交周期(单位:月),计算对应的月份范围
            val period = rule.scensesubtypeid?.toInt() ?: 1
            val startM = DateUtil.getStartMonthByPeriod(config.month, period)
            val endM = startM?.plus(period)?.minus(1)
            totalScore = rule?.resultrange?.toInt() ?: 0
            // 计算评估记录对应的周期(哪年的几月到几月)
            val list1 = result[0].scensename?.split("/") ?: return Triple(false, null, "/")
src/main/kotlin/cn/flightfeather/supervision/common/score/EvaluationUtil.kt
@@ -10,15 +10,15 @@
        var evaluateLevel: String = ""
    }
    fun getEvaluationLevel(totalPoint: Int, rule: Evaluationrule): EvaluationLevel {
    fun getEvaluationLevel(totalPoint: Int, rule: Evaluationrule?): EvaluationLevel {
        val pointLevel = mutableListOf<Pair<Int, Int>>()
        rule.extension1?.split("#")?.forEach {
        rule?.extension1?.split("#")?.forEach {
            val pStr = it.split(",")
            pointLevel.add(Pair(pStr[0].toInt(), pStr[1].toInt()))
        }
        val evaluateLevel = rule.extension2?.split("#") ?: emptyList()
        val creditTexts = rule.extension3?.split("#") ?: emptyList()
        val levelColors = rule.remark?.split(";") ?: emptyList()
        val evaluateLevel = rule?.extension2?.split("#") ?: emptyList()
        val creditTexts = rule?.extension3?.split("#") ?: emptyList()
        val levelColors = rule?.remark?.split(";") ?: emptyList()
        val result = EvaluationLevel()
        if (pointLevel.isEmpty() || evaluateLevel.isEmpty() || creditTexts.isEmpty() || levelColors.isEmpty()) {
src/main/kotlin/cn/flightfeather/supervision/config/CorsConfig.kt
@@ -6,7 +6,8 @@
import org.springframework.web.cors.UrlBasedCorsConfigurationSource
import org.springframework.web.filter.CorsFilter
@Configuration
@Deprecated("使用tomcat的web.xml配置跨域")
//@Configuration
class CorsConfig {
    private fun buildConfig(): CorsConfiguration {
@@ -18,7 +19,7 @@
        }
    }
    @Bean
//    @Bean
    fun corsFilter(): CorsFilter {
        val source = UrlBasedCorsConfigurationSource().apply {
            registerCorsConfiguration("/**", buildConfig())
src/main/kotlin/cn/flightfeather/supervision/config/WebMvcConfig.kt
@@ -7,7 +7,7 @@
/**
 * web配置
 */
@Configuration
//@Configuration
class WebMvcConfig : WebMvcConfigurer {
    override fun addInterceptors(registry: InterceptorRegistry) {
src/main/kotlin/cn/flightfeather/supervision/lightshare/CORSFilter.kt
@@ -16,8 +16,9 @@
 * @author riku
 * Date: 2020/8/11
 */
@Order(1)
@WebFilter(filterName = "corsFilter", urlPatterns = ["/*"])
@Deprecated("使用tomcat的web.xml配置跨域")
//@Order(1)
//@WebFilter(filterName = "corsFilter", urlPatterns = ["/*"])
class CORSFilter : Filter {
    @Throws(ServletException::class)
    override fun init(filterConfig: FilterConfig) {
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/RiskServiceImpl.kt
@@ -100,7 +100,7 @@
        val riskAnalysis = RiskAnalysis(dataSource, toDatabase = false, toFile = true)
//        val fName = Base64.getEncoder().encodeToString("risk.xlsx".toByteArray())
        val fName = "risk.xls"
        val fName = "${year}-${month} risk.xls"
        response.apply {
            setHeader("Content-Disposition", "attachment;filename=$fName")
            setHeader("fileName", fName)
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ConfigController.kt
@@ -25,7 +25,7 @@
        @ApiParam("查询条件") @RequestBody condition: UserSearchCondition,
    ) = resPack { configService.getCommitmentTemplate(condition) }
    @ApiOperation(value = "获取用户类型可用的场景范围")
    @ApiOperation(value = "获取用户的权限配置信息")
    @GetMapping("/user/config")
    fun getUserConfig(
        @ApiParam("用户id") @RequestParam("userId") userId: String,
src/main/kotlin/cn/flightfeather/supervision/scheduler/ScheduleService.kt
@@ -8,6 +8,7 @@
import org.springframework.scheduling.annotation.Async
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Component
import java.time.LocalDate
import java.time.LocalDateTime
/**
@@ -32,7 +33,6 @@
    @Async
    @Scheduled(cron = "0 0 * * * *")
    fun eachHour() {
        if (mode != "proapp") return
        logger.info("=====>>>>>每小时任务执行 {}", System.currentTimeMillis())
        taskJinAnHourlyDustData.doTask(LocalDateTime.now())
        logger.info("=====>>>>>每小时任务结束 {}", System.currentTimeMillis())
@@ -49,9 +49,18 @@
    @Async
    @Scheduled(cron = "0 0 0 * * SUN")
    fun eachSunday() {
        if (mode != "proapp") return
        logger.info("=====>>>>>每周日零点任务执行 {}", System.currentTimeMillis())
        mTaskJinAnHourlyDustData.handle()
        logger.info("=====>>>>>每周日零点任务结束 {}", System.currentTimeMillis())
    }
    @Async
    @Scheduled(cron = "0 0 3 1 * *")
    fun eachMonth() {
        logger.info("=====>>>>>每月初任务执行 {}", System.currentTimeMillis())
        // 执行上个月的静安工地扬尘数据补全任务
        val now = LocalDate.now().minusMonths(1)
        mTaskJinAnHourlyDustData.handle(now.year, now.monthValue)
        logger.info("=====>>>>>每月初任务结束 {}", System.currentTimeMillis())
    }
}
src/test/kotlin/cn/flightfeather/supervision/bgtask/maintenance/MTJinAnHourlyDustDataTest.kt
@@ -20,7 +20,7 @@
    @Test
    fun handleMonth() {
        mTJinAnHourlyDustData.handle(2024, 5)
        mTJinAnHourlyDustData.handle(2025, 5)
    }
    @Test