package cn.flightfeather.supervision.lightshare.service.impl
|
|
import cn.flightfeather.supervision.domain.ds1.entity.NightConstruction
|
import cn.flightfeather.supervision.domain.ds1.mapper.NightConstructionMapper
|
import cn.flightfeather.supervision.domain.ds1.mapper.UserinfoMapper
|
import cn.flightfeather.supervision.lightshare.service.NightConstructionService
|
import cn.flightfeather.supervision.lightshare.vo.BaseResponse
|
import cn.flightfeather.supervision.lightshare.vo.DataHead
|
import cn.flightfeather.supervision.lightshare.vo.NightWorkSummary
|
import com.github.pagehelper.PageHelper
|
import org.springframework.stereotype.Service
|
import tk.mybatis.mapper.entity.Example
|
|
@Service
|
class NightConstructionImpl(
|
val nightConstructionMapper: NightConstructionMapper,
|
val userinfoMapper: UserinfoMapper
|
) : NightConstructionService {
|
|
override fun getRecord(cityCode: String?, districtCode: String, page: Int, perPage: Int): BaseResponse<List<NightConstruction?>> {
|
val p = PageHelper.startPage<NightConstruction>(page, perPage)
|
val result = nightConstructionMapper.selectByExample(Example(NightConstruction::class.java).apply {
|
createCriteria().andEqualTo("ncCityCode", cityCode ?: "3100")
|
.andEqualTo("ncDistrictCode", districtCode)
|
orderBy("ncRead").orderBy("ncId").desc()
|
})
|
return BaseResponse(true, head = DataHead(p.pageNum, p.pages), data = result)
|
}
|
|
override fun getNightWorkFile(userId: String, isRead: Boolean?, page: Int, perPage: Int): BaseResponse<List<NightConstruction?>> {
|
val userInfo = userinfoMapper.selectByPrimaryKey(userId)
|
val p = PageHelper.startPage<NightConstruction>(page, perPage)
|
val result = nightConstructionMapper.selectByExample(Example(NightConstruction::class.java).apply {
|
createCriteria().orEqualTo("ncUserId", userId)
|
.orEqualTo("ncSceneId", userInfo.dGuid)
|
and(createCriteria().apply {
|
isRead?.let {
|
if (isRead) {
|
andEqualTo("ncRead", true)
|
} else {
|
orEqualTo("ncRead", false)
|
.orIsNull("ncRead")
|
}
|
}
|
})
|
orderBy("ncCreateTime").desc()
|
})
|
|
return BaseResponse(true, head = DataHead(p.pageNum, p.pages), data = result)
|
}
|
|
override fun signFile(userId: String, fileNum: String, id: Int): BaseResponse<Int> {
|
val record = nightConstructionMapper.selectByExample(Example(NightConstruction::class.java).apply {
|
createCriteria().andEqualTo("ncId", id)
|
.andEqualTo("ncNum", fileNum)
|
.andEqualTo("ncUserId", userId)
|
})
|
return if (record.isNotEmpty()) {
|
record[0]?.ncRead = true
|
val result = nightConstructionMapper.updateByPrimaryKey(record[0])
|
BaseResponse(true, data = result)
|
} else {
|
BaseResponse(false, "夜间许可证记录不存在")
|
}
|
}
|
|
override fun getSummary(cityCode: String?, districtCode: String): BaseResponse<NightWorkSummary> {
|
val total = nightConstructionMapper.selectCountByExample(Example(NightConstruction::class.java).apply {
|
createCriteria().andEqualTo("ncCityCode", cityCode ?: "3100")
|
.andEqualTo("ncDistrictCode", districtCode)
|
})
|
val signed = nightConstructionMapper.selectCountByExample(Example(NightConstruction::class.java).apply {
|
createCriteria().andEqualTo("ncCityCode", cityCode ?: "3100")
|
.andEqualTo("ncDistrictCode", districtCode)
|
.andEqualTo("ncRead", true)
|
})
|
return BaseResponse(true, data = NightWorkSummary(total, signed))
|
}
|
}
|