| | |
| | | package cn.flightfeather.supervision.lightshare.service.impl |
| | | |
| | | import cn.flightfeather.supervision.common.exception.BizException |
| | | import cn.flightfeather.supervision.common.log.BizLog |
| | | import cn.flightfeather.supervision.common.log.WorkStreamLogInfo |
| | | import cn.flightfeather.supervision.domain.ds1.entity.Problemlist |
| | | import cn.flightfeather.supervision.domain.ds1.entity.Scense |
| | | import cn.flightfeather.supervision.common.utils.Constant |
| | | import cn.flightfeather.supervision.common.utils.FileUtil |
| | | import cn.flightfeather.supervision.common.utils.UUIDGenerator |
| | | import cn.flightfeather.supervision.domain.ds1.entity.Mediafile |
| | | import cn.flightfeather.supervision.domain.ds1.entity.Subtask |
| | | import cn.flightfeather.supervision.domain.ds1.mapper.* |
| | | import cn.flightfeather.supervision.domain.ds1.repository.ProblemRep |
| | | import cn.flightfeather.supervision.domain.ds1.repository.SubTaskRep |
| | | import cn.flightfeather.supervision.domain.ds1.repository.TaskRep |
| | | import cn.flightfeather.supervision.lightshare.service.MediafileService |
| | | import cn.flightfeather.supervision.lightshare.service.ProblemlistService |
| | | import cn.flightfeather.supervision.lightshare.service.TaskService |
| | | import cn.flightfeather.supervision.lightshare.vo.* |
| | | import com.fasterxml.jackson.core.type.TypeReference |
| | | import com.fasterxml.jackson.databind.ObjectMapper |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.beans.BeanUtils |
| | | import org.springframework.stereotype.Service |
| | | import org.springframework.web.multipart.MultipartFile |
| | |
| | | class ProblemlistServiceImpl( |
| | | val problemlistMapper: ProblemlistMapper, |
| | | val inspectionMapper: InspectionMapper, |
| | | val mediafileMapper: MediafileMapper |
| | | val mediafileMapper: MediafileMapper, |
| | | private val taskRep: TaskRep, |
| | | private val subTaskRep: SubTaskRep, |
| | | private val problemRep: ProblemRep, |
| | | private val bizLog: BizLog, |
| | | ) : ProblemlistService { |
| | | |
| | | @Resource |
| | | lateinit var scenseMapper: ScenseMapper |
| | | |
| | | @Resource |
| | | lateinit var problemtypeMapper: ProblemtypeMapper |
| | | |
| | | @Resource |
| | | lateinit var taskMapper: TaskMapper |
| | | |
| | | @Resource |
| | | lateinit var taskService: TaskService |
| | | |
| | | @Resource |
| | | lateinit var mediafileService: MediafileService |
| | | |
| | |
| | | override fun getStatisticalResult(areaVo: AreaVo): List<StatisticsVo> { |
| | | val districtcode = areaVo.districtcode |
| | | val sceneType = areaVo.scensetypeid |
| | | val startTime = areaVo.starttime |
| | | val endTime = areaVo.endtime |
| | | val maps = problemlistMapper.getStatisticalResult(districtcode,startTime, endTime, sceneType) |
| | | val statisticsVos = mutableListOf<StatisticsVo>() |
| | | maps.forEach { |
| | | if (!it.isEmpty() && it.get("name") != null) { |
| | | val statisticsVo = StatisticsVo() |
| | | statisticsVo.name = it.get("name").toString() |
| | | try { |
| | | statisticsVo.count = it.get("count").toString().toInt() |
| | | } catch (e: Exception) { |
| | | } |
| | | try { |
| | | statisticsVo.changeCount = it.get("changeCount").toString().toInt() |
| | | } catch (e: Exception) { |
| | | } |
| | | statisticsVos.add(statisticsVo) |
| | | } |
| | | } |
| | | return statisticsVos |
| | | val startTime = areaVo.starttime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) |
| | | val endTime = areaVo.endtime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) |
| | | return problemlistMapper.getStatisticalResult(districtcode, startTime, endTime, sceneType, areaVo.sceneId) |
| | | } |
| | | |
| | | override fun getChargeResult(areaVo: AreaVo): ChargeInfoVo { |
| | |
| | | // .andGreaterThanOrEqualTo("endtime", areaVo.endtime) |
| | | // .andEqualTo("districtcode", areaVo.districtcode) |
| | | val chargeInfoVo = ChargeInfoVo() |
| | | val sql = "select T_GUID, T_Name from tm_t_task where TS_GUID IS NULL and T_StartTime <= '" + areaVo.starttime + "' and T_EndTime >= '" + areaVo.endtime + "' and T_DistrictCode = '" + areaVo.districtcode +"'" |
| | | val sTime = areaVo.starttime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) |
| | | val eTime = areaVo.endtime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) |
| | | val sql = |
| | | "select T_GUID, T_Name from tm_t_task where TS_GUID IS NULL and T_StartTime <= '" + sTime + "' and T_EndTime" + |
| | | " >= '" + eTime + "' and T_DistrictCode = '" + areaVo.districtcode + "'" |
| | | |
| | | val maps1 = taskMapper.selectSE(sql) |
| | | var topTaskId = String() |
| | | var topTaskName = String() |
| | |
| | | } catch (e: Exception) { |
| | | } |
| | | try { |
| | | sceneInfo.changeCount =it.get("changeCount").toString().toInt() |
| | | sceneInfo.changeCount = it.get("changeCount").toString().toInt() |
| | | } catch (e: Exception) { |
| | | } |
| | | chargeInfoVo.sceneInfos.add(sceneInfo) |
| | |
| | | var curScore = -1 |
| | | if (it.get("scoreAft") != null) { |
| | | curScore = it.get("scoreAft").toString().toInt() |
| | | }else if (it.get("scoreBef") != null) { |
| | | } else if (it.get("scoreBef") != null) { |
| | | curScore = it.get("scoreBef").toString().toInt() |
| | | } |
| | | if (curScore >= 100) { |
| | | scoreInfo1.count++ |
| | | }else if (curScore >= 78 && curScore < 100) { |
| | | } else if (curScore >= 78 && curScore < 100) { |
| | | scoreInfo2.count++ |
| | | }else if (curScore >= 54 && curScore < 78) { |
| | | } else if (curScore >= 54 && curScore < 78) { |
| | | scoreInfo3.count++ |
| | | }else if (curScore < 54 && curScore >= 0) { |
| | | } else if (curScore < 54 && curScore >= 0) { |
| | | scoreInfo4.count++ |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | //根据地域获取问题 |
| | | override fun getByArea(areaVo: AreaVo):List<ProblemlistVo> { |
| | | override fun getByArea(areaVo: AreaVo): List<ProblemlistVo> { |
| | | val problemlist = mutableListOf<ProblemlistVo>() |
| | | // val tmpproblemlsit = mutableListOf<Problemlist>() |
| | | val example = Example(Scense::class.java) |
| | |
| | | criteria.andEqualTo("towncode", areaVo.towncode) |
| | | criteria.andEqualTo("typeid", areaVo.scensetypeid) |
| | | val result1 = scenseMapper.selectByExample(example) |
| | | if (result1.isNotEmpty()){ |
| | | result1.forEach{ |
| | | if (result1.isNotEmpty()) { |
| | | result1.forEach { |
| | | val tmpexample = Example(Problemlist::class.java) |
| | | val tmpcriteria = tmpexample.createCriteria() |
| | | //对于确定的每个场景,根据时间查询问题 |
| | |
| | | mediafileMapper.deleteByExample(Example(Mediafile::class.java).apply { |
| | | createCriteria().andEqualTo("businessguid", id) |
| | | }) |
| | | //更新巡查信息中的问题数量 |
| | | val inspection = inspectionMapper.selectByPrimaryKey(p.iguid) |
| | | if (inspection.problemcount != null && inspection.problemcount!! > 0) { |
| | | inspection.problemcount = inspection.problemcount!! - 1 |
| | | inspectionMapper.updateByPrimaryKey(inspection) |
| | | } |
| | | BaseResponse(true, "问题删除成功", data = i) |
| | | } |
| | | } |
| | |
| | | |
| | | override fun findMonthProblemById(taskId: String, sceneId: Int?): List<MonthProblemVo> { |
| | | val monthProblemlistVoList = mutableListOf<MonthProblemVo>() |
| | | var map = problemlistMapper.findMonthProblemById(taskId,sceneId) |
| | | var map = problemlistMapper.findMonthProblemById(taskId, sceneId) |
| | | map.forEach { m -> |
| | | val monthProblemVo = MonthProblemVo() |
| | | monthProblemVo.townCode =if(m.get("towncode")!= null) BigDecimal(m.get("towncode").toString()).toString() else null |
| | | monthProblemVo.townCode = |
| | | if (m.get("towncode") != null) BigDecimal(m.get("towncode").toString()).toString() else null |
| | | monthProblemVo.townName = if (m.get("townname") != null) m.get("townname").toString() else null |
| | | monthProblemVo.scenetype =if (m.get("scenetype") != null) m.get("scenetype").toString().toInt()else null |
| | | monthProblemVo.scenetypename =if(m.get("scenetypename") != null)m.get("scenetypename").toString()else null |
| | | monthProblemVo.totalscenecount =if(m.get("totalscenecount") != null)m.get("totalscenecount").toString().toInt()else null |
| | | monthProblemVo.problemscenes =if(m.get("problemscenes") != null)m.get("problemscenes").toString().toInt()else null |
| | | monthProblemVo.totalproblems =if(m.get("totalproblems") != null)m.get("totalproblems").toString().toInt()else null |
| | | monthProblemVo.changedproblems =if(m.get("changedproblems") != null)m.get("changedproblems").toString().toInt()else null |
| | | monthProblemVo.scenetype = if (m.get("scenetype") != null) m.get("scenetype").toString().toInt() else null |
| | | monthProblemVo.scenetypename = |
| | | if (m.get("scenetypename") != null) m.get("scenetypename").toString() else null |
| | | monthProblemVo.totalscenecount = |
| | | if (m.get("totalscenecount") != null) m.get("totalscenecount").toString().toInt() else null |
| | | monthProblemVo.problemscenes = |
| | | if (m.get("problemscenes") != null) m.get("problemscenes").toString().toInt() else null |
| | | monthProblemVo.totalproblems = |
| | | if (m.get("totalproblems") != null) m.get("totalproblems").toString().toInt() else null |
| | | monthProblemVo.changedproblems = |
| | | if (m.get("changedproblems") != null) m.get("changedproblems").toString().toInt() else null |
| | | monthProblemlistVoList.add(monthProblemVo) |
| | | } |
| | | return monthProblemlistVoList; |
| | | } |
| | | |
| | | override fun check(pId: String, action: Byte, remark: String, userId: String, userName: String): BaseResponse<String> { |
| | | override fun check( |
| | | pId: String, |
| | | action: Byte, |
| | | remark: String, |
| | | userId: String, |
| | | userName: String, |
| | | ): BaseResponse<String> { |
| | | if (action !in 0..3) { |
| | | return BaseResponse(false, "非法的操作指令") |
| | | } |
| | | val p = problemlistMapper.selectByPrimaryKey(pId) ?: return BaseResponse(false, "问题不存在") |
| | | val subtask = p.stguid?.let { subTaskRep.findOne(it) } |
| | | val response = BaseResponse<String>(true) |
| | | var event = "" |
| | | |
| | | p.apply { |
| | | this.remark = userName |
| | | if (extension3 == Constant.PROBLEM_UNCHECKED) { |
| | | event = "在${subtask?.scensename}审核了一个问题" |
| | | when (action) { |
| | | 0.toByte() -> extension3 = Constant.PROBLEM_CHECK_PASS |
| | | 1.toByte() -> extension3 = Constant.PROBLEM_CHECK_FAIL |
| | | 0.toByte() -> { |
| | | extension3 = Constant.PROBLEM_CHECK_PASS |
| | | } |
| | | 1.toByte() -> { |
| | | extension3 = Constant.PROBLEM_CHECK_FAIL |
| | | } |
| | | 2.toByte(), |
| | | 3.toByte() -> { |
| | | 3.toByte(), |
| | | -> { |
| | | response.success = false |
| | | response.message = "问题提交还未审核,无法进行整改审核!" |
| | | } |
| | | } |
| | | }else if (extension3 == Constant.PROBLEM_CHECK_PASS || extension3 == Constant.PROBLEM_CHECK_FAIL) { |
| | | } else if (extension3 == Constant.PROBLEM_CHECK_PASS || extension3 == Constant.PROBLEM_CHECK_FAIL) { |
| | | when (action) { |
| | | 0.toByte() -> extension3 = Constant.PROBLEM_CHECK_PASS |
| | | 1.toByte() -> extension3 = Constant.PROBLEM_CHECK_FAIL |
| | | 2.toByte(), |
| | | 3.toByte() -> { |
| | | 3.toByte(), |
| | | -> { |
| | | if (ischanged == true && extension3 == Constant.PROBLEM_CHECK_PASS) { |
| | | response.success = true |
| | | extension3 = if (action == 2.toByte()) { |
| | | Constant.CHANGE_CHECK_PASS |
| | | }else{ |
| | | } else { |
| | | Constant.CHANGE_CHECK_FAIL |
| | | } |
| | | event = "在${subtask?.scensename}审核了一个整改" |
| | | } else { |
| | | response.success = false |
| | | response.message = "问题还未整改,无法进行整改审核!操作无效" |
| | | } |
| | | } |
| | | } |
| | | }else if (extension3 == Constant.CHANGE_UNCHECKED) { |
| | | } else if (extension3 == Constant.CHANGE_UNCHECKED) { |
| | | event = "在${subtask?.scensename}审核了一个整改" |
| | | when (action) { |
| | | 0.toByte(), |
| | | 1.toByte() -> { |
| | | 1.toByte(), |
| | | -> { |
| | | response.success = false |
| | | response.message = "问题提交已审核,并且已被整改。操作无效" |
| | | } |
| | | 2.toByte() -> extension3 = Constant.CHANGE_CHECK_PASS |
| | | 3.toByte() -> extension3 = Constant.CHANGE_CHECK_FAIL |
| | | } |
| | | }else if (extension3 == Constant.CHANGE_CHECK_PASS || extension3 == Constant.CHANGE_CHECK_FAIL) { |
| | | } else if (extension3 == Constant.CHANGE_CHECK_PASS || extension3 == Constant.CHANGE_CHECK_FAIL) { |
| | | when (action) { |
| | | 0.toByte(), |
| | | 1.toByte() -> { |
| | | 1.toByte(), |
| | | -> { |
| | | response.success = false |
| | | response.message = "问题提交已审核,并且已被整改。操作无效" |
| | | } |
| | |
| | | if (r != 1) { |
| | | response.success = false |
| | | response.message = "问题更新失败!" |
| | | } else { |
| | | bizLog.info(WorkStreamLogInfo(subtask?.executorguids, subtask?.executorrealtimes, event)) |
| | | } |
| | | } |
| | | return response |
| | |
| | | filetype = 1 |
| | | businesstype = "问题" |
| | | businesstypeid = 1 |
| | | path = "FlightFeather/Photo/" + scene.districtname + "/" + now.year + "年" + now.monthValue + "月/" + now.monthValue + "月" + now.dayOfMonth + "日/" + scene.name + "/" |
| | | description = problemlist.problemname + " " + problemlist.location + " " + UUIDGenerator.generateUUID(4) + ".jpg" |
| | | path = |
| | | "FlightFeather/Photo/" + scene.districtname + "/" + now.year + "年" + now.monthValue + "月/" + now.monthValue + "月" + now.dayOfMonth + "日/" + scene.name + "/" |
| | | description = |
| | | problemlist.problemname + " " + problemlist.location + " " + UUIDGenerator.generateUUID(4) + ".jpg" |
| | | savetime = Date() |
| | | ischanged = false |
| | | extension1 = scene.citycode + "/" + scene.districtcode + "/" + now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + "/" + scene.guid + "/" |
| | | extension1 = |
| | | scene.citycode + "/" + scene.districtcode + "/" + now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + "/" + scene.guid + "/" |
| | | remark = "已上传" |
| | | } |
| | | mediafileMapper.insert(mediaFile) |
| | |
| | | } catch (e: Exception) { |
| | | // TODO: handle exception |
| | | } |
| | | } |
| | | |
| | | //更新巡查信息的问题数 |
| | | if (inspection.problemcount != null) { |
| | | inspection.problemcount = inspection.problemcount!! + 1 |
| | | inspectionMapper.updateByPrimaryKey(inspection) |
| | | } |
| | | |
| | | problemlist.stguid?.let { |
| | | val subtask = subTaskRep.findOne(it) |
| | | val event = "在${subtask?.scensename}新增一个问题" |
| | | bizLog.info(WorkStreamLogInfo(subtask?.executorguids, subtask?.executorrealtimes, event)) |
| | | } |
| | | |
| | | return BaseResponse(true) |
| | |
| | | |
| | | return BaseResponse(true) |
| | | } |
| | | |
| | | override fun getBySubTask(stGuid: String, all: Boolean?): List<ProblemlistVo> { |
| | | //根据子任务ID获取问题列表 |
| | | val problemListVo = mutableListOf<ProblemlistVo>() |
| | | if (all == false) { |
| | | //去除未审核以及审核不通过的问题 |
| | | findBySubtaskId(stGuid).forEach { |
| | | if (it.extension3 != Constant.PROBLEM_UNCHECKED && it.extension3 != Constant.PROBLEM_CHECK_FAIL) { |
| | | problemListVo.add(it) |
| | | } |
| | | } |
| | | } else { |
| | | problemListVo.addAll(findBySubtaskId(stGuid)) |
| | | } |
| | | //根据每个问题,获取媒体文件 |
| | | problemListVo.forEach { |
| | | val mediafileVo = mediafileService.findByBusinessGUID(it.guid!!) |
| | | //判断是否有媒体资料 |
| | | if (mediafileVo.isNotEmpty()) { |
| | | //赋值 |
| | | it.mediafileList = mediafileVo |
| | | } |
| | | } |
| | | return problemListVo |
| | | } |
| | | |
| | | override fun getSceneByProType(areaVo: AreaVo, pType: String): List<Subtask?> { |
| | | areaVo.scensetypeid ?: throw BizException("缺少场景类型参数") |
| | | val task = taskRep.findOneTask(areaVo) ?: throw BizException("未找到对应的巡查总任务") |
| | | return subTaskRep.findSubtasks(task.tguid!!, areaVo.scensetypeid!!, pType) |
| | | } |
| | | |
| | | override fun getSceneProSummary( |
| | | areaVo: AreaVo, |
| | | sortBy: String, |
| | | page: Int, |
| | | per_page: Int, |
| | | ): Pair<DataHead?, List<SceneProblemSummary>?> { |
| | | areaVo.scensetypeid ?: throw BizException("缺少场景类型参数") |
| | | val task = taskRep.findOneTask(areaVo) ?: throw BizException("未找到对应的巡查总任务") |
| | | val p = PageHelper.startPage<SceneProblemSummary>(page, per_page) |
| | | val res = problemRep.getSceneProSummary(task.tguid!!, areaVo.scensetypeid!!, areaVo.sort, sortBy) |
| | | return DataHead(p.pageNum, p.pages, p.total) to res |
| | | } |
| | | } |