From 0392c333ed3d987cb2ab3dac4e1a972cff405f21 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 25 四月 2024 17:42:08 +0800 Subject: [PATCH] 1. 新增后台任务关联模块 2. 新增自动评分后台任务; 3. 修复部分bug --- src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataDeviceMap.kt | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 111 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataDeviceMap.kt b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataDeviceMap.kt index 18706fb..bf7c41a 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataDeviceMap.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataDeviceMap.kt @@ -1,21 +1,32 @@ package cn.flightfeather.supervision.business.autooutput.dataanalysis +import cn.flightfeather.supervision.common.exception.BizException import cn.flightfeather.supervision.common.utils.Constant -import cn.flightfeather.supervision.domain.ds2.repository.JADustSiteMapRep -import cn.flightfeather.supervision.domain.ds3.repository.JSDustSiteMapRep +import cn.flightfeather.supervision.common.utils.ExcelUtil +import cn.flightfeather.supervision.domain.ds1.entity.Scense +import cn.flightfeather.supervision.domain.ds1.repository.SceneRep +import cn.flightfeather.supervision.domain.ds1.repository.TaskRep +import cn.flightfeather.supervision.domain.ds1.repository.UserInfoSVRep +import cn.flightfeather.supervision.domain.ds2.repository.JADustSiteRep +import cn.flightfeather.supervision.domain.ds3.repository.JSDustSiteRep import cn.flightfeather.supervision.domain.ds3.repository.XHFumeSiteMapRep -import cn.flightfeather.supervision.lightshare.vo.AreaVo -import cn.flightfeather.supervision.lightshare.vo.DeviceMapVo +import cn.flightfeather.supervision.lightshare.vo.* +import org.apache.poi.hssf.usermodel.HSSFWorkbook import org.springframework.stereotype.Component +import java.io.FileOutputStream +import java.util.* /** * 鐩戞祴鏁版嵁鍜岀郴缁熺敤鎴风殑鏄犲皠绠$悊 */ @Component class AopDataDeviceMap( - private val jaDustSiteMapRep: JADustSiteMapRep, - private val jsDustSiteMapRep: JSDustSiteMapRep, + private val jaDustSiteRep: JADustSiteRep, + private val jsDustSiteRep: JSDustSiteRep, private val xhFumeSiteMapRep: XHFumeSiteMapRep, + private val taskRep: TaskRep, + private val sceneRep: SceneRep, + private val userInfoSVRep: UserInfoSVRep, ) { /** @@ -50,7 +61,7 @@ //闈欏畨鍖� "310106" -> when (areaVo.scensetypeid) { //宸ュ湴 - Constant.SceneType.TYPE1.value -> jaDustSiteMapRep.findBySVUserId(userIdList) + Constant.SceneType.TYPE1.value -> jaDustSiteRep.findMapBySVUserId(userIdList) else -> emptyList() } //閲戝北鍖� @@ -59,7 +70,7 @@ Constant.SceneType.TYPE1.value, Constant.SceneType.TYPE2.value, Constant.SceneType.TYPE3.value, - -> jsDustSiteMapRep.findBySVUserId(userIdList) + -> jsDustSiteRep.findMapBySVUserId(userIdList) else -> emptyList() } //寰愭眹鍖� @@ -72,4 +83,96 @@ } } + + /** + * 杈撳嚭鐩戞祴鐐逛綅鍜岀洃娴嬭澶囩殑瀵瑰簲鍖归厤鍏崇郴 + * @param areaVo 鍖哄煙鏉′欢 + */ + fun outputMapSet(areaVo: AreaVo) { + // 鐩戠鎬讳换鍔� + val task = taskRep.findOneTask(areaVo) ?: throw BizException("褰撳墠鏌ヨ鏉′欢涓嬫湭鎵惧埌瀵瑰簲椤跺眰浠诲姟") + // 鎬讳换鍔″寘鍚搴旂被鍨嬬殑鍦烘櫙 + val scenes = sceneRep.findScene(task.tguid!!, areaVo.scensetypeid?.toInt(), areaVo.towncode) + val sceneIds = scenes.map { it?.guid } + val userIdList = userInfoSVRep.findUser(sceneIds).map { it?.guid } + // 鍦烘櫙鍜岀洃娴嬬偣鐨勫尮閰嶅叧绯� + val mapSet = this.findMapSet(areaVo, userIdList) + // 鐩戞祴璁惧淇℃伅 + val deviceSiteList = when (areaVo.districtcode) { + //闈欏畨鍖� + "310106" -> when (areaVo.scensetypeid) { + //宸ュ湴 + Constant.SceneType.TYPE1.value -> jaDustSiteRep.findSiteInfo() + else -> emptyList() + } + //閲戝北鍖� + "310116" -> when (areaVo.scensetypeid) { + //宸ュ湴,鐮佸ご姘存偿鎼呮媽绔� + Constant.SceneType.TYPE1.value, + Constant.SceneType.TYPE2.value, + Constant.SceneType.TYPE3.value, + -> jsDustSiteRep.findSiteInfo() + else -> emptyList() + } + //寰愭眹鍖� + "310104" -> when (areaVo.scensetypeid) { + //椁愰ギ + Constant.SceneType.TYPE5.value -> emptyList() + else -> emptyList() + } + else -> emptyList() + } + + outputMapSetToFile(areaVo, scenes, mapSet, deviceSiteList) + } + + /** + * 杈撳嚭鐩戞祴鐐逛綅鍜岀洃娴嬭澶囩殑瀵瑰簲鍖归厤鍏崇郴鍒版枃浠朵腑 + * @param scenes 鍦烘櫙淇℃伅鍒楄〃 + * @param mapSet 鍦烘櫙鍜岀洃娴嬬偣瀵瑰簲鍏崇郴 + * @param siteList 鐩戞祴鐐逛俊鎭垪琛� + */ + private fun outputMapSetToFile(areaVo: AreaVo, scenes: List<Scense?>, mapSet: List<DeviceMapVo>, siteList: + List<DeviceSiteVo>) { + val _scenes = mutableListOf<Scense?>().also { it.addAll(scenes) } + val _siteList = mutableListOf<DeviceSiteVo>().also { it.addAll(siteList) } + + val sceneDeviceList = mutableListOf<SceneDeviceVo>() + //琛ㄥご + val head = sceneDeviceList.tableHead() + scenes.forEach { + val sceneDeviceVo = SceneDeviceVo() + sceneDeviceVo.scene = it + val user = userInfoSVRep.findUser(it?.guid) + mapSet.findBySVUserId(user?.guid).forEach { map -> + val site = siteList.findByMNCode(map.deviceCode) + sceneDeviceVo.deviceList.add(site) + _siteList.remove(site) + } + sceneDeviceList.add(sceneDeviceVo) + } + //鍐呭 + val contents = sceneDeviceList.tableContent() + + + val workbook = HSSFWorkbook() + ExcelUtil.write(head, contents, workbook, sheetName = "鍦烘櫙璁惧鍖归厤") + + val head2 = sceneDeviceList.tableHeadDevice() + val contents2 = mutableListOf<Array<Any>>() + _siteList.forEach { + contents2.add(arrayOf(it.id ?: "", it.mnCode ?: "", it.name ?: "", it.address ?: "", it.beginDate ?: "", it + .dutyCompany ?: "", it.groupName ?: "")) + } + ExcelUtil.write(head2, contents2, workbook, sheetName = "鏈尮閰嶈澶�") + + val path = "target/" + val fileName = "${areaVo.districtname}-鍦烘櫙璁惧淇℃伅-${Date().time}.xls" + val out = FileOutputStream(path + fileName) + workbook.write(out) + workbook.close() + out.flush() + out.close() + } + } \ No newline at end of file -- Gitblit v1.9.3