| | |
| | | package cn.flightfeather.supervision.lightshare.service.impl |
| | | |
| | | import cn.flightfeather.supervision.business.AutoScore |
| | | import cn.flightfeather.supervision.business.AutoScore2 |
| | | import cn.flightfeather.supervision.business.storage.StAutoScore |
| | | import cn.flightfeather.supervision.business.storage.item.StScoreItem_1 |
| | | import cn.flightfeather.supervision.business.storage.item.StScoreItem_2 |
| | | import cn.flightfeather.supervision.business.autooutput.score.AopEvaluation |
| | | import cn.flightfeather.supervision.domain.ds1.entity.* |
| | | import cn.flightfeather.supervision.domain.ds1.mapper.* |
| | | import cn.flightfeather.supervision.common.utils.Constant |
| | |
| | | import tk.mybatis.mapper.entity.Example |
| | | import tk.mybatis.mapper.util.StringUtil |
| | | import java.util.* |
| | | import kotlin.math.ceil |
| | | |
| | | @Service |
| | | class SubtaskServiceImpl(val subtaskMapper: SubtaskMapper) : SubtaskService { |
| | | class SubtaskServiceImpl( |
| | | private val subtaskMapper: SubtaskMapper, |
| | | private val aopEvaluation: AopEvaluation, |
| | | ) : SubtaskService { |
| | | |
| | | val dateUtil = DateUtil() |
| | | |
| | | @Autowired |
| | | lateinit var scoreItem1: StScoreItem_1 |
| | | @Autowired |
| | | lateinit var scoreItem2: StScoreItem_2 |
| | | @Autowired |
| | | lateinit var taskService: TaskService |
| | | @Autowired |
| | |
| | | if (StringUtil.isNotEmpty(areaVo.towncode)) |
| | | criteria.andEqualTo("towncode", areaVo.towncode) |
| | | criteria.andBetween("planstarttime", areaVo.starttime, areaVo.endtime) |
| | | if (!Objects.equals(userGuid, Constant.UserType.ALLUSER.text)) |
| | | if (!Objects.equals(userGuid, Constant.UserType.ALL_USER.des)) |
| | | criteria.andLike("executorguids","%"+userGuid+"%") |
| | | var completecount = 0 |
| | | var subtasklist = subtaskMapper.selectByExample(example) |
| | |
| | | criteria.andEqualTo("stguid", subtask.stguid) |
| | | val result = evaluationMapper.selectByExample(example) |
| | | if (result.isEmpty()) { |
| | | if (subtask.districtname == "徐汇区") { |
| | | val autoScore = AutoScore2() |
| | | autoScore.subtask = subtask |
| | | autoScore.calculateScore() |
| | | } else { |
| | | val autoScore = AutoScore() |
| | | autoScore.subtask = subtask |
| | | autoScore.calculateScore() |
| | | } |
| | | // val autoScore = StAutoScore(scoreItem1, scoreItem2) |
| | | // autoScore.sceneType = Constant.ScenseType.TYPE1 |
| | | aopEvaluation.executeBySubTask(subtask) |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | val tempResult = BaseSearchResultVo() |
| | | val result = BaseSearchResultVo() |
| | | |
| | | val _sceneType = sceneType ?: 1 |
| | | val _districtCode = "310106" |
| | |
| | | } |
| | | } |
| | | |
| | | val example = Example(Subtask::class.java).apply { |
| | | createCriteria().andEqualTo("districtcode", _districtCode) |
| | | .andGreaterThanOrEqualTo("planstarttime", _startTime) |
| | | .andLessThanOrEqualTo("planendtime", _endTime) |
| | | } |
| | | |
| | | var counts = 0 |
| | | |
| | | |
| | | // val offset = (perPage ?: 30).times((page ?: 1).minus(1)) |
| | | // PageHelper.offsetPage<Subtask>(offset, perPage ?: 30) |
| | | |
| | | subtaskMapper.selectByExample(example).forEach { s -> |
| | | |
| | | val scene = scenseMapper.selectByPrimaryKey(s.scenseid) |
| | | val inspection = inspectionMapper.selectByExample(Example(Inspection::class.java).apply { |
| | | createCriteria().andEqualTo("stguid", s.stguid) |
| | | }).takeIf { it.isNotEmpty() }?.get(0) |
| | | val evaluation = evaluationMapper.selectByExample(Example(Evaluation::class.java).apply { |
| | | createCriteria().andEqualTo("stguid", s.stguid) |
| | | }).takeIf { it.isNotEmpty() }?.get(0) |
| | | |
| | | if (scene.typeid != _sceneType.toByte()) { |
| | | return@forEach |
| | | val subtaskMap = mutableMapOf<String?, SubtaskSearchResultVo>() |
| | | val problemMap = mutableMapOf<String?, ProblemDetail>() |
| | | // 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() |
| | | BeanUtils.copyProperties(it, vo) |
| | | subtaskMap[it.subTaskId] = vo |
| | | } |
| | | if (!problemMap.containsKey(it.problemId)) { |
| | | val problemDetail = ProblemDetail() |
| | | BeanUtils.copyProperties(it, problemDetail) |
| | | problemMap[it.problemId] = problemDetail |
| | | subtaskMap[it.subTaskId]?.problemList?.add(problemDetail) |
| | | } |
| | | val url = it.mExtension1 + it.mGuid+ ".jpg" |
| | | if (it.isChanged == true) { |
| | | problemMap[it.problemId]?.rectificationPics?.add(url) |
| | | } else { |
| | | counts++ |
| | | } |
| | | |
| | | |
| | | val subtaskSearchResultVo = SubtaskSearchResultVo().apply { |
| | | this.districtName = scene.districtname |
| | | this.townName = scene.townname |
| | | this.sceneName = scene.name |
| | | this.sceneAddress = scene.location |
| | | this.planStartTime = s.planstarttime |
| | | this.planEndTime = s.planendtime |
| | | this.status = s.status |
| | | this.path= inspection?.extension1 |
| | | this.score = evaluation?.resultscorebef?.toIntOrNull() |
| | | this.level = when { |
| | | score == null -> null |
| | | score!! >= 54 -> "合格" |
| | | else -> "不合格" |
| | | } |
| | | } |
| | | tempResult.data.add(subtaskSearchResultVo) |
| | | |
| | | problemlistMapper.selectByExample(Example(Problemlist::class.java).apply { |
| | | createCriteria().andEqualTo("stguid", s.stguid) |
| | | }).forEach { p -> |
| | | val problem = ProblemDetail().apply { |
| | | this.problemName = p.problemname |
| | | this.longitude = p.longitude?.toDouble() |
| | | this.latitude = p.latitude?.toDouble() |
| | | this.location = p.location |
| | | this.rectification = p.ischanged |
| | | this.rectificationTime = p.changedtime |
| | | } |
| | | subtaskSearchResultVo.problemList.add(problem) |
| | | |
| | | mediafileMapper.selectByExample(Example(Mediafile::class.java).apply { |
| | | createCriteria().andEqualTo("businessguid", p.guid) |
| | | }).forEach { m -> |
| | | val url = m.extension1 + m.guid + ".jpg" |
| | | if (m.ischanged == true) { |
| | | problem.rectificationPics.add(url) |
| | | } else { |
| | | problem.problemPics.add(url) |
| | | } |
| | | } |
| | | problemMap[it.problemId]?.problemPics?.add(url) |
| | | } |
| | | } |
| | | |
| | | val totalPage = Math.ceil(counts.toDouble() / (perPage ?: 30).toDouble()).toInt() |
| | | |
| | | val result = BaseSearchResultVo() |
| | | |
| | | val totalPage = ceil(subtaskMap.size.toDouble() / (perPage ?: 30).toDouble()).toInt() |
| | | result.head = DataHead().apply { |
| | | this.page = page ?: 1 |
| | | this.totalPage = totalPage |
| | | this.totalCount = subtaskMap.size.toLong() |
| | | } |
| | | |
| | | val firstIndex = 0 + ((page ?: 1) - 1).times(perPage ?: 30) |
| | | val lastIndex = firstIndex + (perPage ?: 30) - 1 |
| | | |
| | | for (i in firstIndex until tempResult.data.size) { |
| | | if (i > lastIndex) { |
| | | break |
| | | var count = 0 |
| | | val startIndex = ((page ?: 1) - 1) * (perPage ?: 30) |
| | | val endIndex = startIndex + (perPage ?: 30) - 1 |
| | | with(subtaskMap) exit@{ |
| | | subtaskMap.forEach { |
| | | if (count in startIndex..endIndex) { |
| | | result.data.add(it.value) |
| | | } |
| | | count++ |
| | | if (count > endIndex) return@exit |
| | | } |
| | | result.data.add(tempResult.data[i]) |
| | | } |
| | | |
| | | |
| | | // val example = Example(Subtask::class.java).apply { |
| | | // createCriteria().andEqualTo("districtcode", _districtCode) |
| | | // .andGreaterThanOrEqualTo("planstarttime", _startTime) |
| | | // .andLessThanOrEqualTo("planendtime", _endTime) |
| | | // } |
| | | // |
| | | // var counts = 0 |
| | | // |
| | | // val p = PageHelper.startPage<Subtask>(page ?: 1, perPage ?: 30) |
| | | // |
| | | // subtaskMapper.selectByExample(example).forEach { s -> |
| | | // |
| | | // val scene = scenseMapper.selectByPrimaryKey(s.scenseid) |
| | | // val inspection = inspectionMapper.selectByExample(Example(Inspection::class.java).apply { |
| | | // createCriteria().andEqualTo("stguid", s.stguid) |
| | | // }).takeIf { it.isNotEmpty() }?.get(0) |
| | | // val evaluation = evaluationMapper.selectByExample(Example(Evaluation::class.java).apply { |
| | | // createCriteria().andEqualTo("stguid", s.stguid) |
| | | // }).takeIf { it.isNotEmpty() }?.get(0) |
| | | // |
| | | // if (scene.typeid != _sceneType.toByte()) { |
| | | // return@forEach |
| | | // } else { |
| | | // counts++ |
| | | // } |
| | | // |
| | | // |
| | | // val subtaskSearchResultVo = SubtaskSearchResultVo().apply { |
| | | // this.subTaskId = s.stguid |
| | | // this.districtName = scene.districtname |
| | | // this.townName = scene.townname |
| | | // this.sceneName = scene.name |
| | | // this.sceneAddress = scene.location |
| | | // this.planStartTime = s.planstarttime |
| | | // this.planEndTime = s.planendtime |
| | | // this.status = s.status |
| | | // this.path= inspection?.extension1 |
| | | // this.score = evaluation?.resultscorebef?.toIntOrNull() |
| | | // this.level = when { |
| | | // score == null -> null |
| | | // score!! >= 54 -> "合格" |
| | | // else -> "不合格" |
| | | // } |
| | | // } |
| | | // tempResult.data.add(subtaskSearchResultVo) |
| | | // |
| | | // problemlistMapper.selectByExample(Example(Problemlist::class.java).apply { |
| | | // createCriteria().andEqualTo("stguid", s.stguid) |
| | | // }).forEach { p -> |
| | | // val problem = ProblemDetail().apply { |
| | | // this.problemId = p.guid |
| | | // this.problemName = p.problemname |
| | | // this.longitude = p.longitude?.toDouble() |
| | | // this.latitude = p.latitude?.toDouble() |
| | | // this.location = p.location |
| | | // this.rectification = p.ischanged |
| | | // this.rectificationTime = p.changedtime |
| | | // } |
| | | // subtaskSearchResultVo.problemList.add(problem) |
| | | // |
| | | // mediafileMapper.selectByExample(Example(Mediafile::class.java).apply { |
| | | // createCriteria().andEqualTo("businessguid", p.guid) |
| | | // }).forEach { m -> |
| | | // val url = m.extension1 + m.guid + ".jpg" |
| | | // if (m.ischanged == true) { |
| | | // problem.rectificationPics.add(url) |
| | | // } else { |
| | | // problem.problemPics.add(url) |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // tempResult.head = DataHead().apply { |
| | | // this.page = p.pageNum |
| | | // this.totalPage = p.pages |
| | | // } |
| | | |
| | | return result |
| | | } |
| | |
| | | result.head = DataHead().apply { |
| | | this.page = p.pageNum |
| | | this.totalPage = p.pages |
| | | this.totalCount = p.total |
| | | } |
| | | |
| | | subtasklist.forEach { |
| | |
| | | } |
| | | val subtaskMap = mutableMapOf<String?, SubtaskSearchResultVo>() |
| | | val problemMap = mutableMapOf<String?, ProblemDetail>() |
| | | // 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() |
| | |
| | | result.head = DataHead().apply { |
| | | this.page = 1 |
| | | this.totalPage = 1 |
| | | this.totalCount = subtaskMap.size.toLong() |
| | | } |
| | | subtaskMap.forEach { |
| | | result.data.add(it.value) |
| | |
| | | result.head = DataHead().apply { |
| | | this.page = p.pageNum |
| | | this.totalPage = p.pages |
| | | this.totalCount = p.total |
| | | } |
| | | |
| | | subtasklist.forEach { |
| | |
| | | } |
| | | val subtaskMap = mutableMapOf<String?, SubtaskSearchResultVo>() |
| | | val problemMap = mutableMapOf<String?, ProblemDetail>() |
| | | // 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() |
| | |
| | | result.head = DataHead().apply { |
| | | this.page = 1 |
| | | this.totalPage = 1 |
| | | this.totalCount = subtaskMap.size.toLong() |
| | | } |
| | | subtaskMap.forEach { |
| | | result.data.add(it.value) |