package cn.flightfeather.supervision.lightshare.service.impl
|
|
import cn.flightfeather.supervision.business.autooutput.score.AopEvaluation
|
import cn.flightfeather.supervision.common.exception.BizException
|
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.domain.ds1.repository.SubTaskRep
|
import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
|
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.time.LocalDateTime
|
import java.util.*
|
import kotlin.math.ceil
|
|
@Service
|
class SubtaskServiceImpl(
|
private val subtaskMapper: SubtaskMapper,
|
private val aopEvaluation: AopEvaluation,
|
private val taskRep: TaskRep,
|
private val subTaskRep: SubTaskRep,
|
) : SubtaskService {
|
|
@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.ALL_USER.des))
|
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 {
|
if (it.stguid == null) it.stguid = UUIDGenerator.generate16ShortUUID()
|
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 {
|
if (subtask.stguid == null) subtask.stguid = UUIDGenerator.generate16ShortUUID()
|
return subtaskMapper.insert(subtask)
|
}
|
|
override fun update(subtask: Subtask): Int {
|
var res = 0
|
//根据子任务guid获取顶层任务
|
val toptaskVo = taskService.findByID(subtask.tguid.toString())
|
|
// //根据日期获取日任务
|
val daytaskVo = taskService.findByDate(subtask.tguid!!, DateUtil.getDate(subtask.planstarttime)!!)
|
|
//应该直接根据子任务的日任务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
|
res = 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)
|
//****************************************************************************************
|
res = subtaskMapper.updateByPrimaryKeySelective(subtask)
|
}
|
return res
|
}
|
|
override fun changeStatus(subtask: Subtask): Int {
|
val res = update(subtask)
|
//对已结束的子任务进行自动评分
|
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()) {
|
aopEvaluation.executeBySubTask(subtask)
|
}
|
}
|
|
return res
|
}
|
|
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 {
|
var count = it.extension1?.toIntOrNull() ?: 0
|
count--
|
if (count < 0) {
|
count = 0
|
}
|
it.extension1 = count.toString()
|
monitorobjectversionMapper.updateByPrimaryKeySelective(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 result = 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 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 {
|
problemMap[it.problemId]?.problemPics?.add(url)
|
}
|
}
|
|
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()
|
}
|
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
|
}
|
}
|
|
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
|
this.totalCount = p.total
|
}
|
|
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>()
|
// 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()
|
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
|
this.totalCount = subtaskMap.size.toLong()
|
}
|
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
|
this.totalCount = p.total
|
}
|
|
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>()
|
// 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()
|
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
|
this.totalCount = subtaskMap.size.toLong()
|
}
|
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> {
|
|
return subtaskMapper.selectByTopTask2(topTaskId, sceneTypeId)
|
}
|
|
override fun getSummary(topTaskId: String, sceneTypeId: Int?): List<SubTaskSummary> {
|
return subtaskMapper.getSummary(topTaskId, sceneTypeId)
|
}
|
|
override fun getTaskProgressByArea(areaVo: AreaVo): List<TaskProgressVo> {
|
// areaVo.scensetypeid ?: throw BizException("缺少场景类型参数")
|
val res = mutableListOf<TaskProgressVo>()
|
taskRep.findTasks(areaVo).forEach {t->
|
if (t?.tguid == null) return@forEach
|
val pro = TaskProgressVo().apply {
|
tguid = t.tguid
|
name = t.name
|
levelnum = t.levelnum
|
provinceCode = t.provincecode
|
provinceName = t.provincename
|
cityCode = t.citycode
|
cityName = t.cityname
|
districtCode = t.districtcode
|
districtName = t.districtname
|
townCode = t.towncode
|
townName = t.townname
|
subTaskSummary = subtaskMapper.getSummary(t.tguid!!, areaVo.scensetypeid?.toIntOrNull())
|
}
|
res.add(pro)
|
}
|
return res
|
}
|
|
override fun getByScene(sceneId: String, startTime: LocalDateTime?, endTime: LocalDateTime?): List<SubTaskSummary> {
|
return subtaskMapper.getSummaryByScene(sceneId, startTime, endTime)
|
}
|
|
override fun getSummaryByArea(areaVo: AreaVo): List<SubTaskSummary> {
|
return subTaskRep.findSummary(areaVo)
|
}
|
}
|