| | |
| | | import com.flightfeather.uav.lightshare.bean.DataHead |
| | | import com.flightfeather.uav.lightshare.bean.DataVo |
| | | import com.flightfeather.uav.lightshare.bean.ElectricVo |
| | | import com.flightfeather.uav.lightshare.eunm.ElectricityType |
| | | import com.flightfeather.uav.lightshare.service.ElectricityService |
| | | import com.flightfeather.uav.socket.bean.AirData |
| | | import com.github.pagehelper.PageHelper |
| | |
| | | createCriteria().andEqualTo("cdCompanyId", cId) |
| | | }) |
| | | //产线风机 |
| | | var d1: String? = null |
| | | var d1: CompanyDevice? = null |
| | | //废气净化装置 |
| | | var d2: String? = null |
| | | var d2: CompanyDevice? = null |
| | | |
| | | deviceCodeList.forEach { |
| | | // FIXME: 2021/11/5 此处暂时写死,后续修改 |
| | | if (it?.cdDeviceCode == "31011020210602" || it?.cdDeviceCode == "31011020210603") { |
| | | d1 = it.cdDeviceCode |
| | | }else if (it?.cdDeviceCode == "31011020210601" || it?.cdDeviceCode == "31011020210604") { |
| | | d2 = it.cdDeviceCode |
| | | if (it?.cdType == ElectricityType.ProductionLine.value) { |
| | | d1 = it |
| | | }else if (it?.cdType == ElectricityType.Purify.value) { |
| | | d2 = it |
| | | } |
| | | } |
| | | |
| | | var pageInfo = PageHelper.startPage<ElectricMinuteValue>(p, perP) |
| | | val dataList1 = electricMinuteValueMapper.selectByExample(Example(ElectricMinuteValue::class.java).apply { |
| | | createCriteria().andEqualTo("mvStatCode", d1) |
| | | createCriteria().andEqualTo("mvStatCode", d1?.cdDeviceCode) |
| | | .apply { |
| | | sTime?.let { andGreaterThanOrEqualTo("mvDataTime", it) } |
| | | eTime?.let { andLessThanOrEqualTo("mvDataTime", it) } |
| | |
| | | } |
| | | pageInfo = PageHelper.startPage<ElectricMinuteValue>(p, perP) |
| | | val dataList2 = electricMinuteValueMapper.selectByExample(Example(ElectricMinuteValue::class.java).apply { |
| | | createCriteria().andEqualTo("mvStatCode", d2) |
| | | createCriteria().andEqualTo("mvStatCode", d2?.cdDeviceCode) |
| | | .apply { |
| | | sTime?.let { andGreaterThanOrEqualTo("mvDataTime", it) } |
| | | eTime?.let { andLessThanOrEqualTo("mvDataTime", it) } |
| | |
| | | d1eA = d?.mvElectricityA ?: .0 |
| | | d1eB = d?.mvElectricityB ?: .0 |
| | | d1eC = d?.mvElectricityC ?: .0 |
| | | d1Status = getStatus(d) |
| | | val s = getStatus(d, d1) |
| | | d1Status = s.first |
| | | d1StatusName = s.second |
| | | } |
| | | dataList1.removeAt(0) |
| | | } |
| | |
| | | d2eA = d?.mvElectricityA ?: .0 |
| | | d2eB = d?.mvElectricityB ?: .0 |
| | | d2eC = d?.mvElectricityC ?: .0 |
| | | d2Status = getStatus(d) |
| | | val s = getStatus(d, d2) |
| | | d2Status = s.first |
| | | d2StatusName = s.second |
| | | } |
| | | dataList2.removeAt(0) |
| | | } |
| | |
| | | } |
| | | |
| | | // FIXME: 2021/11/5 此处暂时写死,后续修改 |
| | | private fun getStatus(e: ElectricMinuteValue?): String { |
| | | var values = listOf(1, 100) |
| | | var status = listOf("0", "2", "3") |
| | | private fun getStatus(e: ElectricMinuteValue?, d: CompanyDevice?): Pair<String, String> { |
| | | var values = mutableListOf<Int>().apply { |
| | | d?.cdLimits?.split(";")?.forEach { |
| | | it.toIntOrNull()?.let { i -> add(i) } |
| | | } |
| | | } |
| | | var status = d?.cdStatus?.split(";") ?: emptyList() |
| | | var statusNames = d?.cdStatusName?.split(";") ?: emptyList() |
| | | if (values.isEmpty()) values = mutableListOf(1, 100) |
| | | if (status.isEmpty()) status = listOf("0", "2", "3") |
| | | if (statusNames.isEmpty()) statusNames = listOf("待机", "运行", "超负荷") |
| | | if (e == null) { |
| | | return status.first() |
| | | return Pair(status.first(), statusNames.first()) |
| | | } |
| | | when (e.mvStatCode) { |
| | | "31011020210601" -> { |
| | | values = listOf(1, 100) |
| | | status = listOf("0", "2", "3") |
| | | } |
| | | "31011020210602" -> { |
| | | values = listOf(13, 30) |
| | | status = listOf("0", "2", "3") |
| | | } |
| | | "31011020210603" -> { |
| | | values = listOf(1, 50, 80) |
| | | status = listOf("0", "1", "2", "3") |
| | | } |
| | | "31011020210604" -> { |
| | | values = listOf(15, 90, 125) |
| | | status = listOf("0", "1", "2", "3") |
| | | } |
| | | } |
| | | |
| | | val electricityList = mutableListOf<Double>() |
| | | electricityList.add(e.mvElectricityA) |
| | | electricityList.add(e.mvElectricityB) |
| | |
| | | val avg = electricityList.average() |
| | | for (i in values.indices) { |
| | | if (avg < values[i]) { |
| | | return status[i] |
| | | return Pair(status[i], statusNames[i]) |
| | | } |
| | | } |
| | | return status.last() |
| | | return Pair(status.last(), statusNames.last()) |
| | | } |
| | | } |