package com.persagy.server.services.task

import com.persagy.database.SFilter
import com.persagy.database.functions.SLength
import com.persagy.mybatis.SMybatisDao
import com.persagy.server.datacenter.models.entities.task.EquipScanTaskQuery
import com.persagy.service.SObjectService
import com.persagy.service.SPageContext
import com.persagy.service.models.requests.SQueryRequest
import com.persagy.service.models.responses.SQueryResponse
import org.slf4j.LoggerFactory

/**
 * 设备台账任务
 *
 * @author  邓婷婷
 */
object EquipScanTaskQueryService : SObjectService<EquipScanTaskQuery>(SMybatisDao(EquipScanTaskQuery::class.java))  {

    // 日志
    private val logger = LoggerFactory.getLogger(EquipScanTaskQueryService::class.java)


    fun pageQuerys(request: SQueryRequest): SQueryResponse<EquipScanTaskQuery> {

        val withFilterList = ArrayList<SFilter>()
        withFilterList.add(SFilter.eq("projectId", SPageContext.getHeader("ProjectId").toString()))
        withFilterList.add(SFilter.lt(SLength("category"), 6))
        val pageQuery = pageQuery(request, withFilterList)
        if (!pageQuery.content.isNullOrEmpty()&&pageQuery.content!!.size>0){
            for (content in pageQuery.content!!){
                val exec = select(SFilter.eq("parentId", content.equipId!!),SFilter.eq("taskParentId", content.id!!)).exec()
                if (exec.size>0){
                    content.component = exec
                }
            }
        }
        return pageQuery
    } // Fun






} // Class EquipScanTaskService