| | |
| | | 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.entity.* |
| | | import cn.flightfeather.supervision.domain.ds1.mapper.* |
| | | import cn.flightfeather.supervision.domain.ds1.repository.ProblemRep |
| | | import cn.flightfeather.supervision.domain.ds1.repository.SubTaskRep |
| | |
| | | import com.fasterxml.jackson.databind.ObjectMapper |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.beans.BeanUtils |
| | | import org.springframework.beans.factory.annotation.Value |
| | | import org.springframework.stereotype.Service |
| | | import org.springframework.web.multipart.MultipartFile |
| | | import tk.mybatis.mapper.entity.Example |
| | |
| | | private val subTaskRep: SubTaskRep, |
| | | private val problemRep: ProblemRep, |
| | | private val bizLog: BizLog, |
| | | @Value("\${filePath}") var filePath: String, |
| | | @Value("\${imgPath}") var imgPath: String, |
| | | ) : ProblemlistService { |
| | | |
| | | @Resource |
| | |
| | | @Resource |
| | | lateinit var mediafileService: MediafileService |
| | | |
| | | override fun getByTopTask(tguid: String): List<ProblemlistVo> { |
| | | override fun getByTopTask(tguid: String): List<ProblemListVo> { |
| | | TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
| | | } |
| | | |
| | | //根据场景id和时间获取对应顶层任务下的所有问题 |
| | | override fun getProblemByScene(sceneId: String, date: String): List<ProblemlistVo> { |
| | | override fun getProblemByScene(sceneId: String, date: String): List<ProblemListVo> { |
| | | val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") |
| | | val date1 = simpleDateFormat.parse(date) |
| | | val scene = scenseMapper.selectByPrimaryKey(sceneId) |
| | | val district = scene.districtcode |
| | | val taskVolist = taskService.getByDistrictCode(district!!, date1) |
| | | val problemlistVolistTemp1 = mutableListOf<ProblemlistVo>() |
| | | val problemListVolistTemp1 = mutableListOf<ProblemListVo>() |
| | | if (!taskVolist.isEmpty()) { |
| | | val problemlists = (problemlistMapper.getProblemByScene(sceneId, taskVolist[0].tguid!!)) |
| | | problemlists.forEach { |
| | | // 限制企业查看未审核的问题 |
| | | if (it.extension3 != Constant.PROBLEM_UNCHECKED && it.extension3 != Constant.PROBLEM_CHECK_FAIL) { |
| | | val problemVo = ProblemlistVo(); |
| | | val problemVo = ProblemListVo(); |
| | | BeanUtils.copyProperties(it, problemVo) |
| | | problemlistVolistTemp1.add(problemVo) |
| | | problemListVolistTemp1.add(problemVo) |
| | | } |
| | | } |
| | | problemlistVolistTemp1.forEach { |
| | | problemListVolistTemp1.forEach { |
| | | if (it.ptguid != null) { |
| | | val tmp1 = problemtypeMapper.selectByPrimaryKey(it.ptguid) |
| | | if (tmp1 != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | return problemlistVolistTemp1 |
| | | return problemListVolistTemp1 |
| | | } |
| | | |
| | | //获取某顶层任务下,某个场景下的问题整改情况 |
| | |
| | | |
| | | //根据区县、场景类型、时间获取各个问题数量 |
| | | override fun getStatisticalResult(areaVo: AreaVo): List<StatisticsVo> { |
| | | val districtcode = areaVo.districtcode |
| | | val sceneType = areaVo.scensetypeid |
| | | 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) |
| | | // val districtcode = areaVo.districtcode |
| | | // val sceneType = areaVo.scensetypeid |
| | | // 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(areaVo) |
| | | } |
| | | |
| | | override fun getChargeResult(areaVo: AreaVo): ChargeInfoVo { |
| | |
| | | } |
| | | |
| | | //根据地域获取问题 |
| | | override fun getByArea(areaVo: AreaVo): List<ProblemlistVo> { |
| | | val problemlist = mutableListOf<ProblemlistVo>() |
| | | override fun getByArea(areaVo: AreaVo): List<ProblemListVo> { |
| | | val problemlist = mutableListOf<ProblemListVo>() |
| | | // val tmpproblemlsit = mutableListOf<Problemlist>() |
| | | val example = Example(Scense::class.java) |
| | | val criteria = example.createCriteria() |
| | |
| | | tmpcriteria.andBetween("time", areaVo.starttime, areaVo.endtime) |
| | | val tmp = problemlistMapper.selectByExample(tmpexample) |
| | | tmp.forEach { |
| | | val problem = ProblemlistVo(); |
| | | val problem = ProblemListVo(); |
| | | BeanUtils.copyProperties(it, problem) |
| | | problemlist.add(problem) |
| | | } |
| | |
| | | } |
| | | |
| | | //根据巡查ID获取问题 |
| | | override fun findByInspectionID(inspectionID: String): List<ProblemlistVo> { |
| | | val problemlistVoList = mutableListOf<ProblemlistVo>() |
| | | override fun findByInspectionID(inspectionID: String): List<ProblemListVo> { |
| | | val problemListVoList = mutableListOf<ProblemListVo>() |
| | | val problemlist = Problemlist() |
| | | problemlist.iguid = inspectionID |
| | | val problemlists = problemlistMapper.select(problemlist) |
| | | problemlists.forEach { |
| | | val problemlistVo = ProblemlistVo() |
| | | val problemlistVo = ProblemListVo() |
| | | if (it.remark != Constant.PROBLEM_DELETED) { |
| | | BeanUtils.copyProperties(it, problemlistVo) |
| | | problemlistVoList.add(problemlistVo) |
| | | problemListVoList.add(problemlistVo) |
| | | } |
| | | } |
| | | //排序 |
| | | problemlistVoList.sortBy { it.time } |
| | | return problemlistVoList |
| | | problemListVoList.sortBy { it.time } |
| | | return problemListVoList |
| | | } |
| | | |
| | | //新增一个问题 |
| | | override fun addProblem(problemlistVo: ProblemlistVo) { |
| | | override fun addProblem(problemlistVo: ProblemListVo) { |
| | | val probemlist = Problemlist() |
| | | BeanUtils.copyProperties(problemlistVo, probemlist) |
| | | problemlistMapper.insert(probemlist) |
| | | } |
| | | |
| | | //根据子任务ID查询问题 |
| | | override fun findBySubtaskId(subTaskID: String): List<ProblemlistVo> { |
| | | val problemlistVoList = mutableListOf<ProblemlistVo>() |
| | | override fun findBySubtaskId(subTaskID: String): List<ProblemListVo> { |
| | | val problemListVoList = mutableListOf<ProblemListVo>() |
| | | val problemlist = Problemlist() |
| | | problemlist.stguid = subTaskID |
| | | val problemlists = problemlistMapper.select(problemlist) |
| | | problemlists.forEach { |
| | | val problemlistVo = ProblemlistVo() |
| | | val problemlistVo = ProblemListVo() |
| | | BeanUtils.copyProperties(it, problemlistVo) |
| | | problemlistVoList.add(problemlistVo) |
| | | problemListVoList.add(problemlistVo) |
| | | } |
| | | return problemlistVoList |
| | | return problemListVoList |
| | | } |
| | | |
| | | //根据问题ID获取一个问题 |
| | | override fun findByID(id: String): ProblemlistVo { |
| | | val problemlistVo = ProblemlistVo() |
| | | override fun findByID(id: String): ProblemListVo { |
| | | val problemlistVo = ProblemListVo() |
| | | val problemlist = problemlistMapper.selectByPrimaryKey(id) |
| | | if (problemlist != null) { |
| | | BeanUtils.copyProperties(problemlist, problemlistVo) |
| | |
| | | response.success = false |
| | | response.message = "问题更新失败!" |
| | | } else { |
| | | bizLog.info(WorkStreamLogInfo(subtask?.executorguids, subtask?.executorrealtimes, event)) |
| | | bizLog.info(WorkStreamLogInfo(userId, userName, event)) |
| | | } |
| | | } |
| | | return response |
| | | } |
| | | |
| | | override fun newProblem(problem: String, files: Array<MultipartFile>): BaseResponse<String> { |
| | | val mapper = ObjectMapper() |
| | | |
| | | //json转object |
| | | val problemVo = mapper.readValue(problem, object : TypeReference<ProblemVo>() {}) |
| | | val problemVo = ObjectMapper().readValue(problem, object : TypeReference<ProblemVo>() {}) |
| | | |
| | | // 保存问题 |
| | | val inspection = inspectionMapper.selectByPrimaryKey(problemVo.insGuid) ?: return BaseResponse(false, "巡查记录不存在") |
| | | val scene = scenseMapper.selectByPrimaryKey(inspection.sguid) ?: return BaseResponse(false, "巡查记录对应场景不存在") |
| | | |
| | | val problemlist = Problemlist().apply { |
| | | guid = UUIDGenerator.generate16ShortUUID() |
| | | iguid = inspection.guid |
| | | stguid = inspection.stguid |
| | | sguid = inspection.sguid |
| | | sensename = inspection.scensename |
| | | senseaddress = inspection.scenseaddress |
| | | ptguid = problemVo.ptGuid |
| | | problemname = problemVo.proName |
| | | longitude = problemVo.longitude ?: scene.longitude |
| | | latitude = problemVo.latitude ?: scene.latitude |
| | | locationid = problemVo.locationId |
| | | location = problemVo.location |
| | | time = Date() |
| | | isrechecked = false |
| | | ischanged = false |
| | | advise = problemVo.advice |
| | | extension3 = Constant.PROBLEM_UNCHECKED |
| | | } |
| | | // 保存问题 |
| | | val problemlist = ProblemListVo.newPro(inspection, problemVo, scene) |
| | | problemlistMapper.insert(problemlist) |
| | | |
| | | // 保存图片 |
| | | val now = LocalDateTime.now() |
| | | for (image in files) { |
| | | val mediaFile = Mediafile().apply { |
| | | guid = UUIDGenerator.generate16ShortUUID() |
| | | iguid = inspection.guid |
| | | businessguid = problemlist.guid |
| | | longitude = problemlist.longitude |
| | | latitude = problemlist.latitude |
| | | address = problemlist.senseaddress |
| | | 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" |
| | | savetime = Date() |
| | | ischanged = false |
| | | extension1 = |
| | | scene.citycode + "/" + scene.districtcode + "/" + now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + "/" + scene.guid + "/" |
| | | remark = "已上传" |
| | | } |
| | | mediafileMapper.insert(mediaFile) |
| | | |
| | | val path = mediaFile.extension1 |
| | | val fileName = mediaFile.guid + ".jpg" |
| | | // val filePath = "E:\\work\\第三方监管app\\自动评分\\餐饮\\" |
| | | val filePath = "${Constant.DEFAULT_FILE_PATH}/images/$path/" |
| | | try { |
| | | //调用文件保存方法 |
| | | FileUtil.uploadFile(image.bytes, filePath, fileName) |
| | | } catch (e: Exception) { |
| | | // TODO: handle exception |
| | | } |
| | | } |
| | | mediafileService.saveMediaFile(files) { MediaFileVo.newProFile(inspection, problemlist, scene) } |
| | | |
| | | //更新巡查信息的问题数 |
| | | if (inspection.problemcount != null) { |
| | |
| | | return BaseResponse(true) |
| | | } |
| | | |
| | | override fun updateProblem(problem: ProblemListVo, deleteImg: List<String>, files: Array<MultipartFile>): String { |
| | | problemRep.findOne(problem.guid) ?: throw BizException("该问题不存在") |
| | | problemRep.update(problem) |
| | | val inspection = inspectionMapper.selectByPrimaryKey(problem.iguid) ?: throw BizException("巡查记录不存在") |
| | | val scene = scenseMapper.selectByPrimaryKey(inspection.sguid) ?: throw BizException("巡查记录对应场景不存在") |
| | | mediafileService.saveMediaFile(files) { MediaFileVo.newProFile(inspection, problem, scene) } |
| | | mediafileService.deleteList(deleteImg) |
| | | return "success" |
| | | } |
| | | |
| | | override fun changeProblem(problemId: String, files: Array<MultipartFile>): BaseResponse<String> { |
| | | // 更新问题 |
| | | // 问题和问题图片合法性检查 |
| | | val p = problemlistMapper.selectByPrimaryKey(problemId) ?: return BaseResponse(false, "问题不存在") |
| | | val mediaFiles = mediafileMapper.selectByExample(Example(Mediafile::class.java).apply { |
| | | createCriteria().andEqualTo("businessguid", p.guid) |
| | | .andEqualTo("businesstypeid", 1) |
| | | .andEqualTo("ischanged", false) |
| | | }) |
| | | if (mediaFiles.isEmpty()) return BaseResponse(false, "问题不存在或已整改,无法重复整改") |
| | | |
| | | // 更新问题 |
| | | p.apply { |
| | | ischanged = true |
| | | changedtime = Date() |
| | |
| | | } |
| | | problemlistMapper.updateByPrimaryKey(p) |
| | | |
| | | // 保存图片 |
| | | val now = LocalDateTime.now() |
| | | val mediaFiles = mediafileMapper.selectByExample(Example(Mediafile::class.java).apply { |
| | | createCriteria().andEqualTo("businessguid", p.guid) |
| | | .andEqualTo("businesstypeid", 1) |
| | | .andEqualTo("ischanged", false) |
| | | }) |
| | | if (mediaFiles.isEmpty()) return BaseResponse(false, "场景问题数量为0,无法整改") |
| | | // 保存整改图片 |
| | | val m = mediaFiles[0] |
| | | m.path = m.path + "整改/" |
| | | m.savetime = Date() |
| | | m.ischanged = true |
| | | |
| | | for (image in files) { |
| | | mediafileService.saveMediaFile(files) { |
| | | m.apply { |
| | | guid = UUIDGenerator.generate16ShortUUID() |
| | | description = p.problemname + " " + p.location + " 整改 " + UUIDGenerator.generateUUID(4) + ".jpg" |
| | | } |
| | | mediafileMapper.insert(m) |
| | | |
| | | val path = m.extension1 |
| | | val fileName = m.guid + ".jpg" |
| | | // val filePath = "E:\\work\\第三方监管app\\自动评分\\餐饮\\" |
| | | val filePath = "${Constant.DEFAULT_FILE_PATH}/images/$path" |
| | | try { |
| | | //调用文件保存方法 |
| | | FileUtil.uploadFile(image.bytes, filePath, fileName) |
| | | } catch (e: Exception) { |
| | | println(e) |
| | | } |
| | | } |
| | | |
| | | return BaseResponse(true) |
| | | } |
| | | |
| | | override fun getBySubTask(stGuid: String, all: Boolean?): List<ProblemlistVo> { |
| | | override fun updateChange(problemId: String, deleteImg: List<String>, files: Array<MultipartFile>): String { |
| | | val p = problemRep.findOne(problemId) ?: throw BizException("该问题不存在") |
| | | val mediaFiles = mediafileMapper.selectByExample(Example(Mediafile::class.java).apply { |
| | | createCriteria().andEqualTo("businessguid", problemId) |
| | | .andEqualTo("businesstypeid", 1) |
| | | .andEqualTo("ischanged", true) |
| | | }) |
| | | if (mediaFiles.isEmpty()) throw BizException("问题还未整改,无法修改整改") |
| | | |
| | | // 保存新的整改图片 |
| | | val m = mediaFiles[0] |
| | | m.savetime = Date() |
| | | mediafileService.saveMediaFile(files) { |
| | | m.apply { |
| | | guid = UUIDGenerator.generate16ShortUUID() |
| | | description = p.problemname + " " + p.location + " 整改 " + UUIDGenerator.generateUUID(4) + ".jpg" |
| | | } |
| | | } |
| | | mediafileService.deleteList(deleteImg) |
| | | return "success" |
| | | } |
| | | |
| | | override fun getBySubTask(stGuid: String, all: Boolean?): List<ProblemListVo> { |
| | | //根据子任务ID获取问题列表 |
| | | val problemListVo = mutableListOf<ProblemlistVo>() |
| | | val problemListVo = mutableListOf<ProblemListVo>() |
| | | if (all == false) { |
| | | //去除未审核以及审核不通过的问题 |
| | | findBySubtaskId(stGuid).forEach { |
| | |
| | | |
| | | 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("未找到对应的巡查总任务") |
| | | // 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) |
| | | val res = problemRep.selectSceneProSummary(areaVo) |
| | | return DataHead(p.pageNum, p.pages, p.total) to res |
| | | } |
| | | } |