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.domain.ds1.entity.*
|
import cn.flightfeather.supervision.domain.ds1.mapper.*
|
import cn.flightfeather.supervision.common.utils.Constant
|
import cn.flightfeather.supervision.common.utils.DateUtil
|
import cn.flightfeather.supervision.common.utils.UUIDGenerator
|
import cn.flightfeather.supervision.lightshare.service.SubtaskService
|
import cn.flightfeather.supervision.lightshare.service.TaskService
|
import cn.flightfeather.supervision.lightshare.vo.*
|
import com.github.pagehelper.PageHelper
|
import org.springframework.beans.BeanUtils
|
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.stereotype.Service
|
import org.springframework.transaction.annotation.Transactional
|
import tk.mybatis.mapper.entity.Example
|
import tk.mybatis.mapper.util.StringUtil
|
import java.util.*
|
|
@Service
|
class SubtaskServiceImpl(val subtaskMapper: SubtaskMapper) : SubtaskService {
|
|
val dateUtil = DateUtil()
|
|
@Autowired
|
lateinit var scoreItem1: StScoreItem_1
|
@Autowired
|
lateinit var scoreItem2: StScoreItem_2
|
@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
|
|
//获取用户的子任务完成情况
|
override fun getTaskProgress(areaVo: AreaVo, userGuid: String): TaskVo {
|
val taskProgressVo = TaskVo()
|
val example = Example(Subtask::class.java)
|
val criteria = example.createCriteria()
|
if (StringUtil.isNotEmpty(areaVo.provincecode))
|
criteria.andEqualTo("provincecode", areaVo.provincecode)
|
if (StringUtil.isNotEmpty(areaVo.citycode))
|
criteria.andEqualTo("citycode", areaVo.citycode)
|
if (StringUtil.isNotEmpty(areaVo.districtcode))
|
criteria.andEqualTo("districtcode", areaVo.districtcode)
|
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))
|
criteria.andLike("executorguids","%"+userGuid+"%")
|
var completecount = 0
|
var subtasklist = subtaskMapper.selectByExample(example)
|
subtasklist.forEach {
|
if (Objects.equals(it.status, Constant.TaskProgress.RUNINGSTATUS3.text)){
|
completecount++
|
}
|
}
|
taskProgressVo.totaltask = subtasklist.size
|
taskProgressVo.completetask = completecount
|
|
return taskProgressVo
|
}
|
|
//根据日任务信息查询子任务
|
override fun findByDayTaskID(taskId: String): List<SubtaskVo> {
|
val subtaskVoList = mutableListOf<SubtaskVo>()
|
val example = Example(Subtask::class.java)
|
val criteria = example.createCriteria()
|
criteria.andEqualTo("tsguid", taskId)
|
val subtasklist = subtaskMapper.selectByExample(example)
|
if (subtasklist.isNotEmpty()) {
|
subtasklist.forEach {
|
val subtaskVo = SubtaskVo()
|
BeanUtils.copyProperties(it, subtaskVo)
|
subtaskVoList.add(subtaskVo)
|
}
|
}
|
return subtaskVoList
|
}
|
|
override fun findByDayTaskID(dayTaskId: String, userId: String, userType: String): List<Subtask> {
|
val example = Example(Subtask::class.java)
|
val criteria = example.createCriteria()
|
criteria.andEqualTo("tsguid", dayTaskId)
|
if (userType == "1") {
|
example.and(
|
example.createCriteria().orLike("executorguids", "%$userId%")
|
.orLike("stAssessorguid", "%$userId%")
|
)
|
}
|
example.orderBy("name")
|
val result = subtaskMapper.selectByExample(example).apply{
|
forEach breaking@{
|
//已审核提示
|
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 ->
|
//子任务中有问题未审核时,设置未审核提示
|
if (problem.extension3 == Constant.PROBLEM_UNCHECKED) {
|
it.remark= Constant.PROBLEM_UNCHECKED
|
return@breaking
|
}
|
}
|
}
|
}
|
return result
|
}
|
|
//根据顶层任务信息获取子任务
|
override fun findByTaskID(taskId: String, time: String?): List<SubtaskVo> {
|
val subtaskVoList = mutableListOf<SubtaskVo>()
|
val example = Example(Subtask::class.java)
|
val criteria = example.createCriteria()
|
criteria.andEqualTo("tguid", taskId)
|
val subtasklist = subtaskMapper.selectByExample(example)
|
if (subtasklist.isNotEmpty()) {
|
subtasklist.forEach {
|
val subtaskVo = SubtaskVo()
|
BeanUtils.copyProperties(it, subtaskVo)
|
subtaskVoList.add(subtaskVo)
|
}
|
}
|
return subtaskVoList
|
}
|
|
//批量保存子任务
|
@Transactional
|
override fun saveList(subtasklist: List<Subtask>): Int {
|
subtasklist.forEach {
|
subtaskMapper.insert(it)
|
}
|
return subtasklist.size
|
}
|
|
//根据时间,执行人员guid,查询类型,用户类型,获取三个月的全部任务(临时)
|
override fun getTaskPackList(date: String, guid: String, type: String, userType: String): List<TaskPack> {
|
val taskPackList = mutableListOf<TaskPack>()
|
//定义三个月变量
|
var one: String? = null
|
var two: String? = null
|
var three: String? = null
|
|
val guidd = if (guid == "0") {
|
""
|
} else {
|
guid
|
}
|
val userTypeId = if (userType == "主管部门"){
|
"2"
|
}else if (userType == "飞羽用户") {
|
"1"
|
} else if(userType == "管理员"){
|
"0"
|
}else if (userType == "场景") {
|
"3"
|
} else {
|
userType
|
}
|
var dateString: String? = null
|
//判断参数长度,并处理
|
if (date.length < 7) {
|
return taskPackList
|
} else {
|
dateString = date.substring(0, 7)
|
}
|
//判断参数是否正确
|
if (dateUtil.StringToDate(dateString) == null) {
|
return taskPackList
|
}
|
//根据type类型,得到具体是要哪三个月数据
|
when (type) {
|
"Middle" -> {
|
one = dateUtil.addMonth(dateString, -1)
|
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
|
}
|
}
|
//分别调用三个月获取三个月数据
|
taskPackList.add(getTaskPack(one!!, guidd, userTypeId))
|
taskPackList.add(getTaskPack(two!!, guidd, userTypeId))
|
taskPackList.add(getTaskPack(three!!, guidd, userTypeId))
|
//返回
|
return taskPackList
|
}
|
|
//根据时间,执行人员guid,查询类型,获取三个月的全部任务
|
override fun getTaskPackList(date: String, guid: String, type: String): List<TaskPack> {
|
val taskPackList = mutableListOf<TaskPack>()
|
//定义三个月变量
|
var one: String? = null
|
var two: String? = null
|
var three: String? = null
|
|
val guidd = if (guid == "0") {
|
""
|
} else {
|
guid
|
}
|
var dateString: String? = null
|
//判断参数长度,并处理
|
if (date.length < 7) {
|
return taskPackList
|
} else {
|
dateString = date.substring(0, 7)
|
}
|
//判断参数是否正确
|
if (dateUtil.StringToDate(dateString) == null) {
|
return taskPackList
|
}
|
//根据type类型,得到具体是要哪三个月数据
|
when (type) {
|
"Middle" -> {
|
one = dateUtil.addMonth(dateString, -1)
|
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
|
}
|
}
|
//分别调用三个月获取三个月数据
|
taskPackList.add(getTaskPack(one!!, guidd))
|
taskPackList.add(getTaskPack(two!!, guidd))
|
taskPackList.add(getTaskPack(three!!, guidd))
|
//返回
|
return taskPackList
|
}
|
|
override fun getTaskPack(date: String, guid: String, userType: String): TaskPack {
|
//根据参数查询出所有月任务和日任务
|
val taskPack = TaskPack()
|
//查询出月任务
|
val taskVoMonthList = taskService.getMonthTaskList(date, guid, userType)
|
//根据月任务查询出日任务
|
val taskVoDayList = taskService.getDayTaskList(taskVoMonthList, date, guid, userType)
|
//根据日任务,循环获取子任务
|
taskVoDayList.forEach {
|
//获取任务的日任务
|
val taskVoDays = it.daytaskList
|
//判断日任务是否为空
|
if (taskVoDays != null) {
|
//判断日任务个数是否为空
|
if (!taskVoDays.isEmpty()) {
|
//循环获取子任务
|
taskVoDays.forEach {
|
val subtaskVoList1 = mutableListOf<SubtaskVo>()
|
//构造查询条件
|
val example = Example(Subtask::class.java)
|
val criteria = example.createCriteria()
|
criteria.andEqualTo("tsguid", it.tguid)
|
if (userType == "1") {
|
criteria.andLike("executorguids", "%$guid%")
|
}
|
//根据条件查询
|
val subtaskList = subtaskMapper.selectByExample(example)
|
//判断结果是否为空
|
if (!subtaskList.isEmpty()) {
|
//循环entity转Vo,并把Vo添加到list
|
subtaskList.forEach {
|
val subtaskVo = SubtaskVo()
|
BeanUtils.copyProperties(it, subtaskVo)
|
subtaskVoList1.add(subtaskVo)
|
}
|
}
|
//把子任务赋值到任务字段
|
it.subtaskList = subtaskVoList1
|
}
|
}
|
|
}
|
}
|
//封装包
|
taskPack.upperTaskList = taskVoDayList
|
taskPack.date = date
|
//返回
|
return taskPack
|
}
|
|
//根据日期和执行人员guid,获取全部任务
|
override fun getTaskPack(date: String, guid: String): TaskPack {
|
//根据参数查询出所有月任务和日任务
|
val taskPack = TaskPack()
|
//查询出月任务
|
val taskVoMonthList = taskService.getMonthTaskList(date, guid)
|
//根据月任务查询出日任务
|
val taskVoDayList = taskService.getDayTaskList(taskVoMonthList, date, guid)
|
//根据日任务,循环获取子任务
|
taskVoDayList.forEach {
|
//获取任务的日任务
|
val taskVoDays = it.daytaskList
|
//判断日任务是否为空
|
if (taskVoDays != null) {
|
//判断日任务个数是否为空
|
if (!taskVoDays.isEmpty()) {
|
//循环获取子任务
|
taskVoDays.forEach {
|
val subtaskVoList1 = mutableListOf<SubtaskVo>()
|
//构造查询条件
|
val example = Example(Subtask::class.java)
|
val criteria = example.createCriteria()
|
criteria.andEqualTo("tsguid", it.tguid)
|
criteria.andLike("executorguids", "%$guid%")
|
//根据条件查询
|
val subtaskList = subtaskMapper.selectByExample(example)
|
//判断结果是否为空
|
if (!subtaskList.isEmpty()) {
|
//循环entity转Vo,并把Vo添加到list
|
subtaskList.forEach {
|
val subtaskVo = SubtaskVo()
|
BeanUtils.copyProperties(it, subtaskVo)
|
subtaskVoList1.add(subtaskVo)
|
}
|
}
|
//把子任务赋值到任务字段
|
it.subtaskList = subtaskVoList1
|
}
|
}
|
|
}
|
}
|
//封装包
|
taskPack.upperTaskList = taskVoDayList
|
taskPack.date = date
|
//返回
|
return taskPack
|
}
|
|
//根据id获取子任务
|
override fun findByID(id: String): SubtaskVo {
|
val subtaskVo = SubtaskVo()
|
val subtask = subtaskMapper.selectByPrimaryKey(id)
|
if (subtask != null)
|
BeanUtils.copyProperties(subtask, subtaskVo)
|
return subtaskVo
|
}
|
|
override fun findAll(): MutableList<Subtask> = subtaskMapper.selectAll()
|
|
override fun save(subtask: Subtask): Int = subtaskMapper.insert(subtask)
|
|
//更新子任务
|
override fun update(subtask: Subtask): Int {
|
//根据子任务guid获取顶层任务
|
val toptaskVo = taskService.findByID(subtask.tguid.toString())
|
|
// //根据日期获取日任务
|
// val daytaskVo = taskService.findByDate(dateUtil.getDate(subtask.planstarttime)!!)
|
|
//2019.3.1 by Riku 应该直接根据子任务的日任务id查询日任务
|
val daytaskVo = taskService.findByID(subtask.tsguid!!)
|
|
//判断是否有日任务
|
if (StringUtil.isEmpty(daytaskVo.tguid)) {
|
val task = Task()
|
//日任务继承顶层任务信息
|
BeanUtils.copyProperties(toptaskVo, task)
|
val guid = UUIDGenerator.generate16ShortUUID()
|
task.tsguid = toptaskVo.tguid
|
task.tguid = guid
|
task.name = subtask.name
|
task.starttime = dateUtil.StringToDate(dateUtil.getDate(subtask.planstarttime)!!.substring(0, 10))
|
task.endtime =
|
dateUtil.StringToDate(dateUtil.getDate(subtask.planstarttime)!!.substring(0, 10) + " 23:59:59")
|
//****日任务执行状态继承子任务的状态*(修改)***
|
task.runingstatus = subtask.status
|
//********************************************
|
taskService.save(task)
|
subtask.tsguid = guid
|
subtaskMapper.updateByPrimaryKeySelective(subtask)
|
} else {
|
// subtask.tsguid = daytaskVo.tguid
|
//*(修改)*日任务正在执行,子任务结束,遍历所有其余子任务,都是结束时才将日任务修改为结束****
|
if (subtask.status == Constant.TaskProgress.RUNINGSTATUS3.text
|
&& daytaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS2.text){
|
val subtaskVolist = findByDayTaskID(daytaskVo.tguid!!)
|
var bool = false
|
subtaskVolist.forEach {
|
if (it.status != Constant.TaskProgress.RUNINGSTATUS3.text){
|
bool = true
|
}
|
}
|
if (!bool){
|
daytaskVo.runingstatus = Constant.TaskProgress.RUNINGSTATUS3.text
|
}
|
}
|
//两者状态相同时不做修改,其余情况日任务都为正在执行
|
else if (subtask.status != daytaskVo.runingstatus){
|
daytaskVo.runingstatus = Constant.TaskProgress.RUNINGSTATUS2.text
|
}
|
val daytask = Task()
|
BeanUtils.copyProperties(daytaskVo, daytask)
|
taskMapper.updateByPrimaryKeySelective(daytask)
|
//****************************************************************************************
|
subtaskMapper.updateByPrimaryKeySelective(subtask)
|
}
|
|
//判断对应顶层任务的执行状态
|
val daytaskVolist = taskService.getDayTaskByTaskID(toptaskVo.tguid!!)
|
val iterator: Iterator<TaskVo> = daytaskVolist.iterator()
|
if (daytaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS3.text
|
&& toptaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS2.text) {
|
var bool = false
|
while (iterator.hasNext()) {
|
val tmp = iterator.next()
|
if (tmp.runingstatus != Constant.TaskProgress.RUNINGSTATUS3.text) {
|
bool = true
|
break
|
}
|
}
|
if (!bool){
|
toptaskVo.runingstatus = Constant.TaskProgress.RUNINGSTATUS3.text
|
}
|
}
|
else if (daytaskVo.runingstatus != toptaskVo.runingstatus){
|
toptaskVo.runingstatus = Constant.TaskProgress.RUNINGSTATUS2.text
|
}
|
val toptask = Task()
|
BeanUtils.copyProperties(toptaskVo, toptask)
|
taskMapper.updateByPrimaryKeySelective(toptask)
|
|
//对已结束的子任务进行自动评分
|
if (subtask.status == Constant.TaskProgress.RUNINGSTATUS3.text) {
|
val example = Example(Evaluation::class.java)
|
val criteria = example.createCriteria()
|
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
|
}
|
}
|
|
return 1
|
}
|
|
override fun delete(id: String): Int{
|
val subtask = subtaskMapper.selectByPrimaryKey(id)
|
val dayTaskId = subtask.tsguid
|
subtaskMapper.deleteByPrimaryKey(id)
|
|
// 当日任务对应的子任务为0时,同时删除日任务
|
val subtasklist = findByDayTaskID(dayTaskId.toString())
|
if (subtasklist.isEmpty()) {
|
taskMapper.deleteByPrimaryKey(dayTaskId)
|
}
|
|
// 同时更新监管版本中的巡查计数
|
val topTaskId = subtask.tguid
|
val sceneId = subtask.scenseid
|
val mList = monitorobjectversionMapper.selectByExample(Example(Monitorobjectversion::class.java).apply {
|
createCriteria().andEqualTo("tid", topTaskId).andEqualTo("sguid", sceneId)
|
})
|
mList.forEach {
|
if (it.monitornum == null) {
|
it.monitornum = 0
|
} else {
|
it.monitornum = it.monitornum!! - 1
|
if (it.monitornum!! < 0) {
|
it.monitornum = 0
|
}
|
}
|
monitorobjectversionMapper.insert(it)
|
}
|
|
// 同时删除对应问题和巡查记录
|
inspectionMapper.deleteByExample(Example(Inspection::class.java).apply { createCriteria().andEqualTo("stguid", id) })
|
problemlistMapper.deleteByExample(Example(Problemlist::class.java).apply { createCriteria().andEqualTo("stguid", id) })
|
|
return 1
|
}
|
|
|
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 {
|
this.page = 0
|
totalPage = 0
|
}
|
}
|
}
|
|
val tempResult = BaseSearchResultVo()
|
|
val _sceneType = sceneType ?: 1
|
val _districtCode = "310106"
|
val _startTime = if (startTime.isNullOrBlank()) {
|
val cal = Calendar.getInstance()
|
cal.set(Calendar.HOUR_OF_DAY, 0)
|
cal.set(Calendar.MINUTE, 0)
|
cal.set(Calendar.SECOND, 0)
|
cal.set(Calendar.MILLISECOND, 0)
|
cal.time
|
} else {
|
DateUtil().StringToDate(startTime!!)
|
}
|
|
val _endTime = if (endTime.isNullOrBlank()) {
|
val cal = Calendar.getInstance()
|
cal.set(Calendar.HOUR_OF_DAY, 23)
|
cal.set(Calendar.MINUTE, 59)
|
cal.set(Calendar.SECOND, 59)
|
cal.set(Calendar.MILLISECOND, 999)
|
cal.time
|
} else {
|
DateUtil().StringToDate(endTime!!)?.apply {
|
time += 24 * 60 * 60 * 1000
|
}
|
}
|
|
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
|
} 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)
|
}
|
}
|
}
|
}
|
|
val totalPage = Math.ceil(counts.toDouble() / (perPage ?: 30).toDouble()).toInt()
|
|
val result = BaseSearchResultVo()
|
|
result.head = DataHead().apply {
|
this.page = page ?: 1
|
this.totalPage = totalPage
|
}
|
|
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
|
}
|
result.data.add(tempResult.data[i])
|
}
|
|
return result
|
}
|
|
override fun searchSubTask2(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错误")
|
}
|
|
val time = if (updateTime != null) {
|
DateUtil().StringToDate(updateTime)
|
} else {
|
null
|
}
|
|
val result = BaseSearchResultVo()
|
|
val _sceneType = sceneType
|
val _districtCode = "310116"
|
|
if (!startTime.isNullOrBlank() && !endTime.isNullOrBlank()) {
|
val _startTime = if (startTime.isNullOrBlank()) {
|
val cal = Calendar.getInstance()
|
cal.set(Calendar.HOUR_OF_DAY, 0)
|
cal.set(Calendar.MINUTE, 0)
|
cal.set(Calendar.SECOND, 0)
|
cal.set(Calendar.MILLISECOND, 0)
|
cal.time
|
} else {
|
DateUtil().StringToDate(startTime!!)
|
}
|
|
val _endTime = if (endTime.isNullOrBlank()) {
|
val cal = Calendar.getInstance()
|
cal.set(Calendar.HOUR_OF_DAY, 23)
|
cal.set(Calendar.MINUTE, 59)
|
cal.set(Calendar.SECOND, 59)
|
cal.set(Calendar.MILLISECOND, 999)
|
cal.time
|
} else {
|
DateUtil().StringToDate(endTime!!)?.apply {
|
this.time += 24 * 60 * 60 * 1000
|
}
|
}
|
|
|
val p = PageHelper.startPage<Subtask>(page ?: 1, perPage ?: 30)
|
|
val subtasklist = subtaskMapper.getSubtask(_districtCode, _startTime, _endTime, _sceneType?.toByte())
|
|
subtasklist.forEach { s ->
|
|
problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
|
createCriteria().andEqualTo("stguid", s.subTaskId)
|
.andNotEqualTo("extension3", Constant.PROBLEM_UNCHECKED)
|
.andNotEqualTo("extension3", Constant.PROBLEM_CHECK_FAIL)
|
.andNotEqualTo("extension3", Constant.CHANGE_CHECK_FAIL)
|
.andIsNotNull("extension3")
|
time?.let {
|
and(createCriteria().orGreaterThan("time", it)
|
.orGreaterThan("changedtime", it))
|
}
|
}).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
|
|
/**
|
*
|
* 问题更新时间说明 (2020.09.04)
|
* 未整改时,提交问题时间为更新时间
|
* 整改后,整改时间即为更新时间,但有以下几种特殊情况:
|
* 1:整改有现场整改和用户提交整改两种方式,目前现场整改由于bug不会更新整改时间字段,
|
* 因此使用问题提交时间加1小时作为更新时间,以作区分;
|
* 2:原本用户提交整改后需要经过审核才能表示整改通过,但目前由于部分原因导致大量的整改并未审核,但整改是通过的,
|
* 因此暂时将未审核视作已审核
|
*/
|
this.updateTime = when {
|
p.ischanged == false -> p.time
|
p.changedtime == null -> Date(p.time?.time?.plus(1 * 60 * 60 * 1000) ?: Date().time)
|
else -> p.changedtime
|
}
|
}
|
|
s.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)
|
}
|
}
|
}
|
}
|
|
result.head = DataHead().apply {
|
this.page = p.pageNum
|
this.totalPage = p.pages
|
}
|
|
subtasklist.forEach {
|
if (it.problemList.isNotEmpty()) {
|
result.data.add(it)
|
}
|
}
|
} else {
|
val time2 = time?.apply {
|
this.time.minus(60 * 60 * 1000)
|
}
|
val subtaskMap = mutableMapOf<String?, SubtaskSearchResultVo>()
|
val problemMap = mutableMapOf<String?, ProblemDetail>()
|
subtaskMapper.getSubtask2(time, time2, _districtCode, _sceneType?.toByte(), null, null).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 {
|
problemMap[it.problemId]?.problemPics?.add(url)
|
}
|
}
|
result.head = DataHead().apply {
|
this.page = 1
|
this.totalPage = 1
|
}
|
subtaskMap.forEach {
|
result.data.add(it.value)
|
}
|
}
|
|
|
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> {
|
if (token != "jinshan") {
|
return BaseResponse(false, "请求token错误")
|
}
|
|
val time = if (updateTime != null) {
|
DateUtil().StringToDate(updateTime)
|
} else {
|
null
|
}
|
|
val result = BaseSearchResultVo()
|
|
val _sceneType = sceneType
|
val _districtCode = "310116"
|
|
if (!startTime.isNullOrBlank() && !endTime.isNullOrBlank()) {
|
val _startTime = if (startTime.isNullOrBlank()) {
|
val cal = Calendar.getInstance()
|
cal.set(Calendar.HOUR_OF_DAY, 0)
|
cal.set(Calendar.MINUTE, 0)
|
cal.set(Calendar.SECOND, 0)
|
cal.set(Calendar.MILLISECOND, 0)
|
cal.time
|
} else {
|
DateUtil().StringToDate(startTime!!)
|
}
|
|
val _endTime = if (endTime.isNullOrBlank()) {
|
val cal = Calendar.getInstance()
|
cal.set(Calendar.HOUR_OF_DAY, 23)
|
cal.set(Calendar.MINUTE, 59)
|
cal.set(Calendar.SECOND, 59)
|
cal.set(Calendar.MILLISECOND, 999)
|
cal.time
|
} else {
|
DateUtil().StringToDate(endTime!!)?.apply {
|
this.time += 24 * 60 * 60 * 1000
|
}
|
}
|
|
|
val p = PageHelper.startPage<Subtask>(page ?: 1, perPage ?: 30)
|
|
val subtasklist = subtaskMapper.getSubtask(_districtCode, _startTime, _endTime, _sceneType?.toByte())
|
|
subtasklist.forEach { s ->
|
|
problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
|
createCriteria().andEqualTo("stguid", s.subTaskId)
|
.andNotEqualTo("extension3", Constant.PROBLEM_UNCHECKED)
|
.andNotEqualTo("extension3", Constant.PROBLEM_CHECK_FAIL)
|
.andNotEqualTo("extension3", Constant.CHANGE_CHECK_FAIL)
|
.andIsNotNull("extension3")
|
time?.let {
|
and(createCriteria().orGreaterThan("time", it)
|
.orGreaterThan("changedtime", it))
|
}
|
}).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
|
|
/**
|
*
|
* 问题更新时间说明 (2020.09.04)
|
* 未整改时,提交问题时间为更新时间
|
* 整改后,整改时间即为更新时间,但有以下几种特殊情况:
|
* 1:整改有现场整改和用户提交整改两种方式,目前现场整改由于bug不会更新整改时间字段,
|
* 因此使用问题提交时间加1小时作为更新时间,以作区分;
|
* 2:原本用户提交整改后需要经过审核才能表示整改通过,但目前由于部分原因导致大量的整改并未审核,但整改是通过的,
|
* 因此暂时将未审核视作已审核
|
*/
|
this.updateTime = when {
|
p.ischanged == false -> p.time
|
p.changedtime == null -> Date(p.time?.time?.plus(1 * 60 * 60 * 1000) ?: Date().time)
|
else -> p.changedtime
|
}
|
}
|
|
// 问题唯一编号
|
problemtypeMapper.selectByPrimaryKey(p.ptguid)?.let {
|
problem.problemCode = it.extension1
|
}
|
|
s.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)
|
}
|
}
|
}
|
}
|
|
result.head = DataHead().apply {
|
this.page = p.pageNum
|
this.totalPage = p.pages
|
}
|
|
subtasklist.forEach {
|
if (it.problemList.isNotEmpty()) {
|
result.data.add(it)
|
}
|
}
|
} else {
|
val time2 = time?.apply {
|
this.time.minus(60 * 60 * 1000)
|
}
|
val subtaskMap = mutableMapOf<String?, SubtaskSearchResultVo>()
|
val problemMap = mutableMapOf<String?, ProblemDetail>()
|
subtaskMapper.getSubtask2(time, time2, _districtCode, _sceneType?.toByte(), null, null).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 {
|
problemMap[it.problemId]?.problemPics?.add(url)
|
}
|
}
|
result.head = DataHead().apply {
|
this.page = 1
|
this.totalPage = 1
|
}
|
subtaskMap.forEach {
|
result.data.add(it.value)
|
}
|
}
|
|
|
return BaseResponse(true, "请求成功", data = result)
|
}
|
|
override fun findByDate(date: String, userId: String): List<SubtaskVo> {
|
val time = DateUtil().StringToDate(date)
|
|
val resultList = mutableListOf<SubtaskVo>()
|
|
subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
|
createCriteria().andLessThanOrEqualTo("planstarttime", time)
|
.andGreaterThanOrEqualTo("planendtime", time)
|
}).forEach {
|
val vo = SubtaskVo()
|
BeanUtils.copyProperties(it, vo)
|
resultList.add(vo)
|
}
|
|
return resultList
|
}
|
|
override fun getByTopTaskAndDate(topTaskId: String, startTime: String?, endTime: String?, sceneTypeId: Int?): List<Subtask> {
|
// val startDate = dateUtil.StringToDate(startTime)
|
// val endDate = dateUtil.StringToDate(endTime)
|
//
|
// val cal = Calendar.getInstance().apply { time = startDate }
|
// val _startTime = dateUtil.DateToString(cal.time, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) ?: startTime
|
//
|
// if (endDate == null) {
|
// cal.add(Calendar.MONTH, 1)
|
// cal.add(Calendar.DAY_OF_MONTH, -1)
|
// } else {
|
// cal.time = endDate
|
// }
|
// cal.set(Calendar.HOUR_OF_DAY, 23)
|
// cal.set(Calendar.MINUTE, 59)
|
// cal.set(Calendar.SECOND, 59)
|
// val _endTime = dateUtil.DateToString(cal.time, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) ?: endTime
|
|
val resultList = subtaskMapper.selectByTopTask2(topTaskId, sceneTypeId)
|
|
return resultList
|
}
|
|
override fun getSummary(topTaskId: String, sceneTypeId: Int?): List<SubTaskSummary> {
|
// val result = mutableListOf<SubTaskSummary>()
|
|
// subtaskMapper.selectByTopTask2(topTaskId, sceneTypeId).forEach {
|
// val scene = scenseMapper.selectByPrimaryKey(it.scenseid)
|
// var p = 0
|
// var c = 0
|
// var pc = 0
|
// var cc = 0
|
// problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
|
// createCriteria().andEqualTo("stguid", it.stguid)
|
// }).forEach {pro ->
|
// p++
|
// if (pro.ischanged == true) c++
|
// if (pro.extension3 != Constant.PROBLEM_UNCHECKED) pc++
|
// if (pro.extension3 == Constant.CHANGE_CHECK_PASS || pro.extension3 == Constant.CHANGE_CHECK_FAIL) cc++
|
// }
|
// val ins = inspectionMapper.selectByExample(Example(Inspection::class.java).apply {
|
// createCriteria().andEqualTo("stguid", it.stguid)
|
// })
|
// result.add(SubTaskSummary().apply {
|
// stGuid = it.stguid
|
// stName = it.name
|
// if (ins.isNotEmpty()) insGuid = ins[0].guid
|
// sceneId = it.scenseid
|
// sceneName = scene.name
|
// sceneType = scene.type
|
// stPlanTime = it.planstarttime
|
// proNum = p
|
// changeNum = c
|
// proCheckedNum = pc
|
// changeCheckedNum = cc
|
// })
|
// }
|
|
// return result
|
|
return subtaskMapper.getSummary(topTaskId, sceneTypeId)
|
|
}
|
}
|