feiyu02
2025-12-20 5a003a42d2b34e8362910ac1d3e5a8866768e5fe
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt
@@ -33,20 +33,28 @@
    @Autowired
    lateinit var taskService: TaskService
    @Autowired
    lateinit var taskMapper: TaskMapper
    @Autowired
    lateinit var evaluationMapper: EvaluationMapper
    @Autowired
    lateinit var problemlistMapper: ProblemlistMapper
    @Autowired
    lateinit var mediafileMapper: MediafileMapper
    @Autowired
    lateinit var scenseMapper: ScenseMapper
    @Autowired
    lateinit var inspectionMapper: InspectionMapper
    @Autowired
    lateinit var monitorobjectversionMapper: MonitorobjectversionMapper
    @Autowired
    lateinit var problemtypeMapper: ProblemtypeMapper
@@ -65,11 +73,11 @@
            criteria.andEqualTo("towncode", areaVo.towncode)
        criteria.andBetween("planstarttime", areaVo.starttime, areaVo.endtime)
        if (!Objects.equals(userGuid, Constant.UserType.ALL_USER.des))
            criteria.andLike("executorguids","%"+userGuid+"%")
            criteria.andLike("executorguids", "%" + userGuid + "%")
        var completecount = 0
        var subtasklist = subtaskMapper.selectByExample(example)
        subtasklist.forEach {
            if (Objects.equals(it.status, Constant.TaskProgress.RUNINGSTATUS3.text)){
            if (Objects.equals(it.status, Constant.TaskProgress.RUNINGSTATUS3.text)) {
                completecount++
            }
        }
@@ -102,24 +110,26 @@
        criteria.andEqualTo("tsguid", dayTaskId)
        if (userType == "1") {
            example.and(
                    example.createCriteria().orLike("executorguids", "%$userId%")
                            .orLike("stAssessorguid", "%$userId%")
                example.createCriteria().orLike("executorguids", "%$userId%")
                    .orLike("stAssessorguid", "%$userId%")
            )
        }
        example.orderBy("name")
        val result = subtaskMapper.selectByExample(example).apply{
        val result = subtaskMapper.selectByExample(example).apply {
            forEach breaking@{
                //已审核提示
                it.remark= Constant.PROBLEM_CHECK_PASS
                it.remark = Constant.PROBLEM_CHECK_PASS
                problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
                    createCriteria().andEqualTo("stguid", it.stguid)
                    and(createCriteria().orIsNull("remark")
                            .orNotEqualTo("remark", Constant.PROBLEM_DELETED))
                }).forEach {problem ->
                    and(
                        createCriteria().orIsNull("remark")
                            .orNotEqualTo("remark", Constant.PROBLEM_DELETED)
                    )
                }).forEach { problem ->
                    //子任务中有问题未审核时,设置未审核提示
                    if (problem.extension3 == Constant.PROBLEM_UNCHECKED) {
                        it.remark= Constant.PROBLEM_UNCHECKED
                        it.remark = Constant.PROBLEM_UNCHECKED
                        return@breaking
                    }
                }
@@ -168,13 +178,13 @@
        } else {
            guid
        }
        val userTypeId = if (userType == "主管部门"){
        val userTypeId = if (userType == "主管部门") {
            "2"
        }else if (userType == "飞羽用户") {
        } else if (userType == "飞羽用户") {
            "1"
        } else if(userType == "管理员"){
        } else if (userType == "管理员") {
            "0"
        }else if (userType == "场景") {
        } else if (userType == "场景") {
            "3"
        } else {
            userType
@@ -197,16 +207,19 @@
                two = dateString
                three = DateUtil.addMonth(dateString, 1)
            }
            "Left" -> {
                one = DateUtil.addMonth(dateString, 1)
                two = DateUtil.addMonth(dateString, 2)
                three = DateUtil.addMonth(dateString, 3)
            }
            "Right" -> {
                one = DateUtil.addMonth(dateString, -1)
                two = DateUtil.addMonth(dateString, -2)
                three = DateUtil.addMonth(dateString, -3)
            }
            else -> {
                //参数不正确就返回
                return taskPackList
@@ -251,16 +264,19 @@
                two = dateString
                three = DateUtil.addMonth(dateString, 1)
            }
            "Left" -> {
                one = DateUtil.addMonth(dateString, 1)
                two = DateUtil.addMonth(dateString, 2)
                three = DateUtil.addMonth(dateString, 3)
            }
            "Right" -> {
                one = DateUtil.addMonth(dateString, -1)
                two = DateUtil.addMonth(dateString, -2)
                three = DateUtil.addMonth(dateString, -3)
            }
            else -> {
                //参数不正确就返回
                return taskPackList
@@ -422,21 +438,22 @@
            subtask.tsguid = daytaskVo.tguid
            //*(修改)*日任务正在执行,子任务结束,遍历所有其余子任务,都是结束时才将日任务修改为结束****
            if (subtask.status == Constant.TaskProgress.RUNINGSTATUS3.text
                && daytaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS2.text){
                && daytaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS2.text
            ) {
                val subtaskVolist = findByDayTaskID(daytaskVo.tguid!!)
                var bool = false
                subtaskVolist.forEach {
                    if (it.status != Constant.TaskProgress.RUNINGSTATUS3.text){
                    if (it.status != Constant.TaskProgress.RUNINGSTATUS3.text) {
                        bool = true
                    }
                }
                if (!bool){
                if (!bool) {
                    daytaskVo.runingstatus = Constant.TaskProgress.RUNINGSTATUS3.text
                }
            }
            //两者状态相同时不做修改,其余情况日任务都为正在执行
            else if (subtask.status != daytaskVo.runingstatus){
            else if (subtask.status != daytaskVo.runingstatus) {
                daytaskVo.runingstatus = Constant.TaskProgress.RUNINGSTATUS2.text
            }
            val daytask = Task()
@@ -464,7 +481,8 @@
        return res
    }
    override fun delete(id: String): Int{
    @Transactional
    override fun delete(id: String): Int {
        val subtask = subtaskMapper.selectByPrimaryKey(id)
        val dayTaskId = subtask.tsguid
        subtaskMapper.deleteByPrimaryKey(id)
@@ -499,7 +517,15 @@
    }
    override fun searchSubTask(token: String, sceneType: Int?, districtCode: String?, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseSearchResultVo {
    override fun searchSubTask(
        token: String,
        sceneType: Int?,
        districtCode: String?,
        startTime: String?,
        endTime: String?,
        page: Int?,
        perPage: Int?,
    ): BaseSearchResultVo {
        if (token != "jingan") {
            return BaseSearchResultVo().apply {
                head = DataHead().apply {
@@ -542,7 +568,7 @@
//        val  p = PageHelper.startPage<Subtask>(page ?: 1, perPage ?: 30)
        subtaskMapper.getSubtask2(null, null, _districtCode, _sceneType.toByte(), _startTime, _endTime).forEach {
            if (!subtaskMap.containsKey(it.subTaskId)) {
                val vo =SubtaskSearchResultVo()
                val vo = SubtaskSearchResultVo()
                BeanUtils.copyProperties(it, vo)
                subtaskMap[it.subTaskId] = vo
            }
@@ -552,7 +578,7 @@
                problemMap[it.problemId] = problemDetail
                subtaskMap[it.subTaskId]?.problemList?.add(problemDetail)
            }
            val url = it.mExtension1 + it.mGuid+ ".jpg"
            val url = it.mExtension1 + it.mGuid + ".jpg"
            if (it.isChanged == true) {
                problemMap[it.problemId]?.rectificationPics?.add(url)
            } else {
@@ -633,7 +659,7 @@
            }
            val p = PageHelper.startPage<Subtask>(page ?: 1, perPage ?: 30)
            val p = PageHelper.startPage<SubtaskSearchResultVo>(page ?: 1, perPage ?: 30)
            val subtasklist = subtaskMapper.getSubtask(_districtCode, _startTime, _endTime, _sceneType?.toByte())
@@ -646,8 +672,10 @@
                        .andNotEqualTo("extension3", Constant.CHANGE_CHECK_FAIL)
                        .andIsNotNull("extension3")
                    time?.let {
                        and(createCriteria().orGreaterThan("time", it)
                            .orGreaterThan("changedtime", it))
                        and(
                            createCriteria().orGreaterThan("time", it)
                                .orGreaterThan("changedtime", it)
                        )
                    }
                }).forEach { p ->
                    val problem = ProblemDetail().apply {
@@ -742,7 +770,16 @@
        return BaseResponse(true, "请求成功", data = result)
    }
    override fun searchSubTask3(token: String, updateTime: String?, sceneType: Int?, districtCode: String?, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseResponse<BaseSearchResultVo> {
    override fun searchSubTask3(
        token: String,
        updateTime: String?,
        sceneType: Int?,
        districtCode: String?,
        startTime: String?,
        endTime: String?,
        page: Int?,
        perPage: Int?,
    ): BaseResponse<BaseSearchResultVo> {
        if (token != "jinshan") {
            return BaseResponse(false, "请求token错误")
        }
@@ -784,7 +821,7 @@
            }
            val p = PageHelper.startPage<Subtask>(page ?: 1, perPage ?: 30)
            val p = PageHelper.startPage<SubtaskSearchResultVo>(page ?: 1, perPage ?: 30)
            val subtasklist = subtaskMapper.getSubtask(_districtCode, _startTime, _endTime, _sceneType?.toByte())
@@ -797,8 +834,10 @@
                        .andNotEqualTo("extension3", Constant.CHANGE_CHECK_FAIL)
                        .andIsNotNull("extension3")
                    time?.let {
                        and(createCriteria().orGreaterThan("time", it)
                            .orGreaterThan("changedtime", it))
                        and(
                            createCriteria().orGreaterThan("time", it)
                                .orGreaterThan("changedtime", it)
                        )
                    }
                }).forEach { p ->
                    val problem = ProblemDetail().apply {
@@ -867,7 +906,7 @@
//            val p = PageHelper.startPage<Subtask>(page ?: 1, perPage ?: 30)
            subtaskMapper.getSubtask2(time, time2, _districtCode, _sceneType?.toByte(), null, null).forEach {
                if (!subtaskMap.containsKey(it.subTaskId)) {
                    val vo =SubtaskSearchResultVo()
                    val vo = SubtaskSearchResultVo()
                    BeanUtils.copyProperties(it, vo)
                    subtaskMap[it.subTaskId] = vo
                }
@@ -877,7 +916,7 @@
                    problemMap[it.problemId] = problemDetail
                    subtaskMap[it.subTaskId]?.problemList?.add(problemDetail)
                }
                val url = it.mExtension1 + it.mGuid+ ".jpg"
                val url = it.mExtension1 + it.mGuid + ".jpg"
                if (it.isChanged == true) {
                    problemMap[it.problemId]?.rectificationPics?.add(url)
                } else {
@@ -898,15 +937,37 @@
        return BaseResponse(true, "请求成功", data = result)
    }
    override fun findByDate(date: String, userId: String): List<SubtaskVo> {
        val time = DateUtil.StringToDate(date)
    override fun findByDate(date: String?, userId: String?, sceneId: String?): List<SubtaskVo> {
        val time = if (date == null) null else DateUtil.StringToDate(date)
        val resultList = mutableListOf<SubtaskVo>()
        subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
            createCriteria().andLessThanOrEqualTo("planstarttime", time)
        val subtasks = if (time != null) {
            // 获取某一天的巡查任务
            subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
                createCriteria().andLessThanOrEqualTo("planstarttime", time)
                    .andGreaterThanOrEqualTo("planendtime", time)
        }).forEach {
                    .apply { sceneId?.let { andEqualTo("scenseid", it) } }
            })
        } else {
            // 获取最近一个月内的(某个场景的)所有巡查任务
            PageHelper.startPage<Subtask>(1, 1)
            val lastOne = subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
                createCriteria().apply {
                    sceneId?.let { andEqualTo("scenseid", it) }
                }
                orderBy("planstarttime").desc()
            }).takeIf { it.isNotEmpty() }?.get(0)
            if (lastOne == null) {
                emptyList()
            } else {
                subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
                    createCriteria().andEqualTo("tguid", lastOne.tguid)
                        .andEqualTo("scenseid", lastOne.scenseid)
                })
            }
        }
        subtasks.forEach {
            val vo = SubtaskVo()
            BeanUtils.copyProperties(it, vo)
            resultList.add(vo)
@@ -919,7 +980,7 @@
        topTaskId: String,
        startTime: String?,
        endTime: String?,
        sceneTypeId: Int?
        sceneTypeId: Int?,
    ): List<Subtask> {
        return subtaskMapper.selectByTopTask2(topTaskId, sceneTypeId)
@@ -932,7 +993,7 @@
    override fun getTaskProgressByArea(areaVo: AreaVo): List<TaskProgressVo> {
//        areaVo.scensetypeid ?: throw BizException("缺少场景类型参数")
        val res = mutableListOf<TaskProgressVo>()
        taskRep.findTasks(areaVo).forEach {t->
        taskRep.findTasks(areaVo).forEach { t ->
            if (t?.tguid == null) return@forEach
            val pro = TaskProgressVo().apply {
                tguid = t.tguid