From d2727f231319a48019bc3b87439136ab49b97b9b Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期五, 08 十一月 2024 09:49:57 +0800 Subject: [PATCH] 1. 2024.11.08 修复部分bug --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/MonitorobjectversionServiceImpl.kt | 4 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/EvaluationsubruleService.kt | 3 src/main/kotlin/cn/flightfeather/supervision/business/report/BaseExcel.kt | 2 src/test/kotlin/cn/flightfeather/supervision/business/location/LocationRoadNearbyTest.kt | 9 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt | 1 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SubtaskController.kt | 6 src/main/kotlin/cn/flightfeather/supervision/business/report/template/DailyReportSummary.kt | 2 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DomainitemService.kt | 6 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DomainitemServiceImpl.kt | 21 + src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserinfoServiceImpl.kt | 5 src/main/kotlin/cn/flightfeather/supervision/business/location/UtilExcelDistance.kt | 62 ++++ src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/MonitorObjectVersionVo.kt | 1 src/main/kotlin/cn/flightfeather/supervision/business/location/LocationDistance.kt | 78 ++++++ src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/ExcelConfigVo.kt | 29 +- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/TaskService.kt | 4 src/main/kotlin/cn/flightfeather/supervision/business/location/UtilFile.kt | 4 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProductServiceImpl.kt | 81 ++++++ src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationsubruleServiceImpl.kt | 16 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DataProductService.kt | 18 + src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MenuController.kt | 2 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/UserinfoController.kt | 6 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductController.kt | 32 ++ src/main/kotlin/cn/flightfeather/supervision/lightshare/web/TaskController.kt | 3 src/main/kotlin/cn/flightfeather/supervision/business/location/BasePlace.kt | 12 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt | 63 ++-- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/UserinfoService.kt | 2 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MediafileController.kt | 4 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt | 42 +- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SubtaskService.kt | 6 src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt | 63 ++-- src/main/kotlin/cn/flightfeather/supervision/common/utils/Constant.kt | 7 src/test/kotlin/cn/flightfeather/supervision/SupervisionApplicationTests.kt | 10 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DomainitemController.kt | 17 + src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplateMulti.kt | 52 ++- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt | 53 +-- 35 files changed, 558 insertions(+), 168 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/location/BasePlace.kt b/src/main/kotlin/cn/flightfeather/supervision/business/location/BasePlace.kt new file mode 100644 index 0000000..7445878 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/location/BasePlace.kt @@ -0,0 +1,12 @@ +package cn.flightfeather.supervision.business.location + +/** + * + * @date 2024/10/24 + * @author feiyu02 + */ +data class BasePlace( + val name: String, + val sP: Pair<Double, Double>, + val eP: Pair<Double, Double>, +) \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/location/LocationDistance.kt b/src/main/kotlin/cn/flightfeather/supervision/business/location/LocationDistance.kt new file mode 100644 index 0000000..3abaa36 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/location/LocationDistance.kt @@ -0,0 +1,78 @@ +package cn.flightfeather.supervision.business.location + +import cn.flightfeather.supervision.common.utils.ExcelUtil +import cn.flightfeather.supervision.domain.ds1.entity.Scense +import cn.flightfeather.supervision.domain.ds1.mapper.ScenseMapper +import org.springframework.stereotype.Component +import tk.mybatis.mapper.entity.Example +import kotlin.math.round + +/** + * 璺濈璁$畻 + * @date 2024/10/24 + * @author feiyu02 + */ +@Component +class LocationDistance(private val scenseMapper: ScenseMapper) { + + private val utilFile = UtilExcelDistance(mutableListOf( + listOf( + ExcelUtil.MyCell("鐩戞祴鐐�", colSpan = 1), + ExcelUtil.MyCell("璺濈锛堝叕閲岋級", colSpan = 1), + ExcelUtil.MyCell("鍞竴搴忓彿", colSpan = 1), + ExcelUtil.MyCell("鍗曚綅鍚嶇О", colSpan = 1), + ExcelUtil.MyCell("绫诲瀷", colSpan = 1), + ExcelUtil.MyCell("鍗曚綅鍦板潃", colSpan = 1), + ExcelUtil.MyCell("缁忓害", colSpan = 1), + ExcelUtil.MyCell("绾害", colSpan = 1), + ExcelUtil.MyCell("鍖哄幙", colSpan = 1), + ExcelUtil.MyCell("琛楅亾", colSpan = 1), + ExcelUtil.MyCell("甯哥敤鑱旂郴浜�", colSpan = 1), + ExcelUtil.MyCell("鑱旂郴鏂瑰紡", colSpan = 1), + ).toTypedArray() + )) + + fun searchList(pList: List<BasePlace>, districtName: String) { + utilFile.reset() + pList.forEach { + val sceneList = findScenes(districtName) + if (sceneList.isEmpty()) { + utilFile.addRow(listOf(it.name)) + } + sceneList.forEachIndexed { index, s -> + var distance = CoordinateUtil.calculateDistance( + it.sP.first, it.sP.second, + s.longitude?.toDouble() ?: .0, s.latitude?.toDouble() ?: .0 + ) + distance = round(distance * 1000) / 1000 + utilFile.parseRow(listOf<Any>( + "", + distance, + s.index?.toDouble() ?: "", + s.name ?: "", + s.type ?: "", + s.location ?: "", + s.longitude?.toDouble() ?: .0, + s.latitude?.toDouble() ?: .0, + s.districtname ?: "", + s.townname ?: "", + s.contacts ?: "", + s.contactst ?: "" + ).toTypedArray()) + if (index == 0) { + utilFile.updateLastRow(0, ExcelUtil.MyCell(it.name, sceneList.size)) + } + } + utilFile.index = 1 + } + utilFile.outPutToFile(districtName) + } + + private fun findScenes(districtName: String): List<Scense> { + return scenseMapper.selectByExample(Example(Scense::class.java).apply { + createCriteria().andEqualTo("districtname", districtName) + and(createCriteria().orNotEqualTo("extension1", "0") + .orIsNull("extension1")) + }) + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/location/UtilExcelDistance.kt b/src/main/kotlin/cn/flightfeather/supervision/business/location/UtilExcelDistance.kt new file mode 100644 index 0000000..05ddbce --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/location/UtilExcelDistance.kt @@ -0,0 +1,62 @@ +package cn.flightfeather.supervision.business.location + +import cn.flightfeather.supervision.common.utils.DateUtil +import cn.flightfeather.supervision.common.utils.ExcelUtil +import cn.flightfeather.supervision.domain.ds1.entity.Scense +import org.apache.poi.hssf.usermodel.HSSFWorkbook +import java.io.File +import java.io.FileOutputStream +import java.util.* + +/** + * + * @date 2024/10/24 + * @author feiyu02 + */ +class UtilExcelDistance(head: List<Array<Any>>) { + + private val heads = mutableListOf<Array<Any>>() + private val contents = mutableListOf<Array<Any>>() + var index = 1 + + init { + heads.addAll(head) + } + + fun reset() { + index = 1 + contents.clear() + } + + fun addRow(row: List<Any>) { + contents.add(row.toTypedArray()) + } + + fun updateLastRow(index: Int, cell: Any) { + contents.last()[index] = cell + } + + /** + * 鐢熸垚涓�琛宔xcel鏁版嵁 + */ + fun parseRow(row: Array<Any>) { + contents.add(row) + index++ + } + + fun outPutToFile(districtName: String) { + val workbook = HSSFWorkbook() + val fileName = "${districtName}鐐逛綅璺濆浗鎺х偣璺濈-${DateUtil.DateToString(Date(), "yyyy-MM-ddhhmmss")}.xls" + val filePath = "C:\\work\\宸ヤ綔\\绗笁鏂圭洃绠\鐐逛綅璺濆浗鎺х偣璺濈\\$fileName" + val file = File(filePath) + if (!file.parentFile.exists()) { + file.parentFile.mkdirs() + } + val out = FileOutputStream(file) + ExcelUtil.write(heads, contents, workbook) + workbook.write(out) + workbook.close() + out.flush() + out.close() + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/location/UtilFile.kt b/src/main/kotlin/cn/flightfeather/supervision/business/location/UtilFile.kt index aee975c..87f3bdb 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/location/UtilFile.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/location/UtilFile.kt @@ -8,7 +8,7 @@ import java.io.FileOutputStream import java.util.* -class UtilFile { +class UtilFile(head: List<ExcelUtil.MyCell>? = null) { private val heads = mutableListOf<Array<Any>>() private val contents = mutableListOf<Array<Any>>() @@ -25,7 +25,7 @@ // ExcelUtil.MyCell("瀹堟硶鑷祴鑷瘎", colSpan = 3), // ExcelUtil.MyCell("绾夸笂鐩戠缁煎悎椋庨櫓鍒嗘瀽涓庡绛�", colSpan = 3), // ) - val h2 = listOf( + val h2 = head ?: listOf( ExcelUtil.MyCell("璺", colSpan = 1), ExcelUtil.MyCell("搴忓彿", colSpan = 1), ExcelUtil.MyCell("鍗曚綅鍚嶇О", colSpan = 1), diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseExcel.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseExcel.kt index 9f5e740..e182a98 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseExcel.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseExcel.kt @@ -19,7 +19,7 @@ // excel鏂囨。 private var workbook = HSSFWorkbook() - fun getReportName(): String = "${dataSource.areaName()}-${fileName}.xls" + fun getReportName(): String = "${dataSource.areaName()}-${fileName}.xlsx" fun toFile(path: String) { val fileName = getReportName() diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplateMulti.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplateMulti.kt index 7240490..ef49da5 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplateMulti.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplateMulti.kt @@ -81,19 +81,21 @@ val c = mutableListOf<Array<Any>>() head.forEach { h.add(it.toTypedArray()) } contents.forEach { c.add(it.toTypedArray()) } - val index = c[0][0] - //鎸夌収绗竴鍒楄繘琛屾帓搴� - if (index is Int) { - c.sortBy { - if (it[0] is Int) { - it[0] as Int - } else { - 0 + if (c.isNotEmpty() && c[0].isNotEmpty()) { + val index = c[0][0] + //鎸夌収绗竴鍒楄繘琛屾帓搴� + if (index is Int) { + c.sortBy { + if (it[0] is Int) { + it[0] as Int + } else { + 0 + } } - } - } else { - c.sortBy { - it[0].toString() + } else { + c.sortBy { + it[0].toString() + } } } return Pair(h, c) @@ -112,19 +114,21 @@ contents.forEach { c.add(it.toTypedArray()) } - val index = c[0][0] - //鎸夌収绗竴鍒楄繘琛屾帓搴� - if (index is Int) { - c.sortBy { - if (it[0] is Int) { - it[0] as Int - } else { - 0 + if (c.isNotEmpty() && c[0].isNotEmpty()) { + val index = c[0][0] + //鎸夌収绗竴鍒楄繘琛屾帓搴� + if (index is Int) { + c.sortBy { + if (it[0] is Int) { + it[0] as Int + } else { + 0 + } } - } - } else { - c.sortBy { - it[0].toString() + } else { + c.sortBy { + it[0].toString() + } } } return Pair(h, c) diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt index f91d3f6..575041e 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt @@ -59,7 +59,7 @@ */ fun reset() { rowData.index = 0 - rowData.subTask = sourceList.first() + rowData.subTask = if (sourceList.isEmpty()) null else sourceList.first() rowData.clear() } @@ -85,7 +85,7 @@ })?.takeIf { it.isNotEmpty() }?.get(0)?.let { area = it.townname ?: "" } } - dbMapper.taskMapper.selectByPrimaryKey(config.topTaskGuid).let { + dbMapper.taskMapper.selectByPrimaryKey(config.topTaskGuid)?.let { val time = LocalDateTime.ofInstant(it.starttime?.toInstant(), ZoneId.systemDefault()) this.year = time.year this.month = time.monthValue @@ -93,41 +93,44 @@ } //1. 鏌ユ壘鐗瑰畾鐨勫贰鏌ヤ换鍔℃垨鑰呮墍鏈夌殑璁″垝宸℃煡浠诲姟 - var taskSceneIdList = listOf<String>() - val subTaskList = if (config.subTaskIdList?.isNotEmpty() == true) { - dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { - createCriteria().apply { - andIn("stguid", config.subTaskIdList) - config.startTime?.let { andGreaterThanOrEqualTo("planstarttime", it) } - config.endTime?.let { andLessThanOrEqualTo("planendtime", it) } - config.districtCode?.let { andEqualTo("districtcode", it) } -// andEqualTo("tguid", config.topTaskGuid) - } - }) - } else { - taskSceneIdList = dbMapper.scenseMapper.getSceneByType(config.topTaskGuid, config - .sceneType, config.townCode).map { it.guid ?: "" } - dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { + val taskSceneIdList = dbMapper.scenseMapper.getSceneByType(config.topTaskGuid, config.sceneType, + config.townCode).map { it.guid ?: "" } + + // 缁熻鎬讳换鍔′笅鎵�鏈夊満鏅� + if (config.allScene) { + val subTaskList = dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { createCriteria().apply { if (taskSceneIdList.isNotEmpty()) andIn("scenseid", taskSceneIdList) }.andEqualTo("tguid", config.topTaskGuid) }) - } - - if (taskSceneIdList.isNotEmpty()) { - taskSceneIdList.forEach { - var subtask: Subtask? = null - for (s in subTaskList) { - if (s.scenseid == it) { - subtask = s - result.add(s) + // 缁欒繕鏈贰鏌ョ殑鍦烘櫙鐢熸垚绌虹殑瀛愪换鍔″璞� + if (taskSceneIdList.isNotEmpty()) { + taskSceneIdList.forEach { + var subtask: Subtask? = null + for (s in subTaskList) { + if (s.scenseid == it) { + subtask = s + result.add(s) + } + } + if (subtask == null) { + result.add(Subtask().apply { scenseid = it }) } } - if (subtask == null) { - result.add(Subtask().apply { scenseid = it }) - } + } else { + result.addAll(subTaskList) } - } else { + } + else { + val subTaskList = dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { + createCriteria().apply { + if (config.subTaskIdList?.isNotEmpty() == true) andIn("stguid", config.subTaskIdList) + config.startTime?.let { andGreaterThanOrEqualTo("planstarttime", it) } + config.endTime?.let { andLessThanOrEqualTo("planendtime", it) } + config.districtCode?.let { andEqualTo("districtcode", it) } + andEqualTo("tguid", config.topTaskGuid) + } + }) result.addAll(subTaskList) } diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/DailyReportSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/DailyReportSummary.kt index febe803..81fb58f 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/DailyReportSummary.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/DailyReportSummary.kt @@ -14,7 +14,7 @@ ColSceneName(), ColSceneBaseInfo(), ColTown(), - ColInspectionInfo(listOf(2, 3, 4, 5, 7, 8, 9)) + ColInspectionInfo(listOf(0, 2, 3, 4, 5, 7, 8, 9)) ) override val templateName: String = "鏃ユ姤缁熻" diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/utils/Constant.kt b/src/main/kotlin/cn/flightfeather/supervision/common/utils/Constant.kt index 0e08474..d250d1b 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/common/utils/Constant.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/common/utils/Constant.kt @@ -244,5 +244,12 @@ const val RESTAURANT_LOCATION_ID = "bMpvxuqHlB1CTYfh" // 姹戒慨闂浣嶇疆 const val Vehicle_LOCATION_ID = "PuToYNqdSLFQSSYk" + + // 浠诲姟绫诲瀷 + const val DOMAIN_GUID_TASK_TYPE = "qASRIAjgSfCuvJOi" + // 浠诲姟鏈熼檺绫诲瀷 + const val DOMAIN_GUID_TASK_DEADLINE_TYPE = "cS9MAkmXN1S37Tbv" + // 浠诲姟灞傛 + const val DOMAIN_GUID_TASK_LEVEL = "TzbIi3ckPWMzlsH6" } } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DataProductService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DataProductService.kt new file mode 100644 index 0000000..c263969 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DataProductService.kt @@ -0,0 +1,18 @@ +package cn.flightfeather.supervision.lightshare.service + +import cn.flightfeather.supervision.lightshare.vo.AreaVo +import cn.flightfeather.supervision.lightshare.vo.ExcelConfigVo +import javax.servlet.http.HttpServletResponse + +/** + * + * @date 2024/10/18 + * @author feiyu02 + */ +interface DataProductService { + + /** + * 涓嬭浇鏁版嵁浜у搧鎶ュ憡 + */ + fun downloadProduct(areaVo: AreaVo, type: Int, forceUpdate: Boolean, response: HttpServletResponse): Boolean +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DomainitemService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DomainitemService.kt index 72aeaea..dde9c25 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DomainitemService.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DomainitemService.kt @@ -22,4 +22,10 @@ fun findByLogName(name: String): List<DomainitemVo> fun getLocation(sceneType: Int): List<Domainitem> + + fun getTaskType(): List<Domainitem> + + fun getDeadlineType(): List<Domainitem> + + fun getLevelType(): List<Domainitem> } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/EvaluationsubruleService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/EvaluationsubruleService.kt index d96c2aa..3558f62 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/EvaluationsubruleService.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/EvaluationsubruleService.kt @@ -1,5 +1,6 @@ package cn.flightfeather.supervision.lightshare.service +import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule2 import cn.flightfeather.supervision.lightshare.vo.ScoreDetail @@ -7,7 +8,7 @@ interface EvaluationsubruleService { fun findOne(id:String): Evaluationsubrule2 - fun findAll(): MutableList<Evaluationsubrule2> + fun findAll(): MutableList<Evaluationsubrule> fun save(evaluationsubrule: Evaluationsubrule2): Int diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SubtaskService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SubtaskService.kt index 19fe742..1899e56 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SubtaskService.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SubtaskService.kt @@ -14,6 +14,12 @@ fun update(subtask: Subtask): Int + /** + * 鍙樻洿宸℃煡浠诲姟鐘舵�� + * 鎵ц浠诲姟鎴栫粨鏉熶换鍔� + */ + fun changeStatus(subtask: Subtask): Int + fun delete(id: String): Int fun getTaskPackList(date: String, guid: String, type: String): List<TaskPack> diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/TaskService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/TaskService.kt index 1bcb613..b656fe3 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/TaskService.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/TaskService.kt @@ -14,6 +14,8 @@ fun save(task: Task): Int + fun create(task: Task): Task + fun update(task: Task): Int fun delete(id: String): Int @@ -38,7 +40,7 @@ fun getDayTaskByTaskID(taskid: String): List<TaskVo> - fun findByDate(date: String): TaskVo + fun findByDate(topTaskId: String, date: String): TaskVo fun getTaskProgress(userid: String): List<TaskVo>//鑾峰彇椤跺眰浠诲姟瀵瑰簲鐨勫瓙浠诲姟瀹屾垚閲� diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/UserinfoService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/UserinfoService.kt index 529580d..6fca31c 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/UserinfoService.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/UserinfoService.kt @@ -12,7 +12,7 @@ fun findAll(): MutableList<Userinfo> - fun findByType(typeId: Byte): List<Userinfo> + fun findByType(typeId: Byte, enable: Boolean?): List<Userinfo> fun save(userinfo: Userinfo): Int diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProductServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProductServiceImpl.kt new file mode 100644 index 0000000..6d56e50 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProductServiceImpl.kt @@ -0,0 +1,81 @@ +package cn.flightfeather.supervision.lightshare.service.impl + +import cn.flightfeather.supervision.business.bgtask.ReportTaskCtrl +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.business.report.DbMapper +import cn.flightfeather.supervision.business.report.file.ReportOne +import cn.flightfeather.supervision.business.report.file.ReportThree +import cn.flightfeather.supervision.business.report.file.ReportTwo +import cn.flightfeather.supervision.common.exception.BizException +import cn.flightfeather.supervision.domain.ds1.repository.TaskRep +import cn.flightfeather.supervision.lightshare.service.DataProductService +import cn.flightfeather.supervision.lightshare.vo.AreaVo +import cn.flightfeather.supervision.lightshare.vo.ExcelConfigVo +import org.springframework.beans.factory.annotation.Value +import org.springframework.http.HttpHeaders +import org.springframework.http.MediaType +import org.springframework.stereotype.Service +import java.io.File +import java.util.* +import javax.servlet.http.HttpServletResponse + +/** + * + * @date 2024/10/18 + * @author feiyu02 + */ +@Service +class DataProductServiceImpl( + private val taskRep: TaskRep, + private val dbMapper: DbMapper, + @Value("\${filePath}") private val filePath: String, + private val reportTaskCtrl: ReportTaskCtrl, +) : DataProductService { + + override fun downloadProduct( + areaVo: AreaVo, type: Int, forceUpdate: Boolean, response: HttpServletResponse, + ): Boolean { + areaVo.scensetypeid ?: throw BizException("蹇呴』閫夋嫨涓�涓満鏅被鍨�") + val topTask = taskRep.findOneTask(areaVo) ?: throw BizException("鏈壘鍒扮鍚堟潯浠剁殑椤跺眰浠诲姟") + val config = ExcelConfigVo( + topTask.tguid ?: "", + topTask.starttime, + topTask.endtime, + topTask.provincecode, + topTask.citycode, + topTask.districtcode, + topTask.towncode, + areaVo.scensetypeid?.toInt(), + forceUpdate = forceUpdate + ) + val dataSource = DataSource(config, dbMapper) + val t = when (type) { + 1 -> ReportOne(dataSource) + 2 -> ReportTwo(dataSource) + 3 -> ReportThree(dataSource) + else -> throw BizException("鏈寚瀹氭暟鎹骇鍝佺被鍨嬶紝鏃犳硶涓嬭浇") + } + val fileName = t.getReportName() + val p = "$filePath/autoscore/" + val file = File(p + fileName) + if (config.forceUpdate || !file.exists()) { + val downloadUrl = "/autoscore/${fileName}" + reportTaskCtrl.startTask(t, downloadUrl) + return false + } else { + val fName = Base64.getEncoder().encodeToString(fileName.toByteArray()) + response.apply { + setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=$fName") + setHeader("fileName", fName) + addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "fileName") + contentType = "application/vnd.ms-excel;charset=UTF-8" +// contentType = MediaType.APPLICATION_OCTET_STREAM_VALUE + setHeader(HttpHeaders.PRAGMA, "no-cache") + setHeader(HttpHeaders.CACHE_CONTROL, "no-cache") + setDateHeader(HttpHeaders.EXPIRES, 0) + } + response.outputStream.write(file.readBytes()) + return true + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DomainitemServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DomainitemServiceImpl.kt index 4b27486..b950837 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DomainitemServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DomainitemServiceImpl.kt @@ -96,4 +96,25 @@ orderBy("index") }) } + + override fun getTaskType(): List<Domainitem> { + return domainitemMapper.selectByExample(Example(Domainitem::class.java).apply { + createCriteria().andEqualTo("dcguid", Constant.DOMAIN_GUID_TASK_TYPE) + orderBy("index") + }) + } + + override fun getDeadlineType(): List<Domainitem> { + return domainitemMapper.selectByExample(Example(Domainitem::class.java).apply { + createCriteria().andEqualTo("dcguid", Constant.DOMAIN_GUID_TASK_DEADLINE_TYPE) + orderBy("index") + }) + } + + override fun getLevelType(): List<Domainitem> { + return domainitemMapper.selectByExample(Example(Domainitem::class.java).apply { + createCriteria().andEqualTo("dcguid", Constant.DOMAIN_GUID_TASK_LEVEL) + orderBy("index") + }) + } } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt index dc5839d..278aa8c 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt @@ -40,7 +40,6 @@ private val evaluationRep: EvaluationRep, private val taskRep: TaskRep, private val aopTaskCtrl: AopTaskCtrl, - private val searchService: SearchService, private val dbMapper: DbMapper, @Value("\${filePath}") private val filePath: String, private val reportTaskCtrl: ReportTaskCtrl, diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationsubruleServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationsubruleServiceImpl.kt index 1c53c7b..0d3ba73 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationsubruleServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationsubruleServiceImpl.kt @@ -2,6 +2,7 @@ import cn.flightfeather.supervision.common.exception.BizException import cn.flightfeather.supervision.domain.ds1.entity.Evaluationrule +import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule2 import cn.flightfeather.supervision.domain.ds1.mapper.EvaluationruleMapper import cn.flightfeather.supervision.domain.ds1.mapper.EvaluationsubruleMapper @@ -16,23 +17,24 @@ @Service class EvaluationsubruleServiceImpl( - val evaluationsubruleMapper: EvaluationsubruleMapper2, + val evaluationsubruleMapper2: EvaluationsubruleMapper2, + val evaluationsubruleMapper: EvaluationsubruleMapper, val evaluationruleMapper: EvaluationruleMapper, private val evaluationRep: EvaluationRep, private val evaluationRuleRep: EvaluationRuleRep, private val sceneRep: SceneRep, ) : EvaluationsubruleService { - override fun findOne(id: String): Evaluationsubrule2 = evaluationsubruleMapper.selectByPrimaryKey(id) + override fun findOne(id: String): Evaluationsubrule2 = evaluationsubruleMapper2.selectByPrimaryKey(id) - override fun findAll(): MutableList<Evaluationsubrule2> = evaluationsubruleMapper.selectAll() + override fun findAll(): MutableList<Evaluationsubrule> = evaluationsubruleMapper.selectAll() - override fun save(evaluationsubrule: Evaluationsubrule2): Int = evaluationsubruleMapper.insert(evaluationsubrule) + override fun save(evaluationsubrule: Evaluationsubrule2): Int = evaluationsubruleMapper2.insert(evaluationsubrule) override fun update(evaluationsubrule: Evaluationsubrule2): Int = - evaluationsubruleMapper.updateByPrimaryKey(evaluationsubrule) + evaluationsubruleMapper2.updateByPrimaryKey(evaluationsubrule) - override fun delete(id: String): Int = evaluationsubruleMapper.deleteByPrimaryKey(id) + override fun delete(id: String): Int = evaluationsubruleMapper2.deleteByPrimaryKey(id) override fun findByRuleId(erguid: String): List<Evaluationsubrule2> { return evaluationRuleRep.findSubRule(erguid) @@ -44,7 +46,7 @@ createCriteria().andEqualTo("districtcode", districtCode) .andEqualTo("scensetypeid", sceneTypeId) }).takeIf { it.isNotEmpty() }?.get(0)?.let { rule -> - evaluationsubruleMapper.selectByExample(Example(Evaluationsubrule2::class.java).apply { + evaluationsubruleMapper2.selectByExample(Example(Evaluationsubrule2::class.java).apply { createCriteria().andEqualTo("erguid", rule.guid) }) }?.also { diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/MonitorobjectversionServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/MonitorobjectversionServiceImpl.kt index b0fe633..77b2a75 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/MonitorobjectversionServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/MonitorobjectversionServiceImpl.kt @@ -39,7 +39,8 @@ val monitorobjectversionlist = monitorobjectversionMapper.select(monitorobjectversion) return monitorobjectversionlist.filter { - val usedCount = it.extension1 ?: "0";it.monitornum.toString().toInt() - usedCount.toInt() > 0 + val usedCount = it.extension1 ?: "0" + it.monitornum.toString().toInt() - usedCount.toInt() > 0 }.sortedBy { it.displayid } } @@ -75,6 +76,7 @@ if (vo.sguid == scene.guid) { vo.sceneTypeId = scene.typeid?.toInt() ?: 0 vo.sceneType = scene.type + vo.scene = scene return@f } } diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt index b6b57b7..e0f8796 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt @@ -1,5 +1,6 @@ package cn.flightfeather.supervision.lightshare.service.impl +import cn.flightfeather.supervision.business.bgtask.ReportTaskCtrl import cn.flightfeather.supervision.business.report.DataSource import cn.flightfeather.supervision.business.report.DbMapper import cn.flightfeather.supervision.business.report.file.ReportOne @@ -66,6 +67,8 @@ private val sceneRep: SceneRep, @Value("\${filePath}") var filePath: String, @Value("\${imgPath}") var imgPath: String, + private val dbMapper: DbMapper, + private val reportTaskCtrl: ReportTaskCtrl, ) : SearchService { override fun writeToFile(config: ExcelConfigVo, mode: Int) { @@ -96,20 +99,6 @@ } override fun getExcel(config: ExcelConfigVo, response: HttpServletResponse): Boolean { - val dbMapper = DbMapper( - scenseMapper, - problemlistMapper, - problemtypeMapper, - subtaskMapper, - monitorobjectversionMapper, - sceneConstructionSiteMapper, - sceneMixingPlantMapper, - sceneStorageYardMapper, - sceneWharfMapper, - taskMapper, - evaluationruleMapper, evaluationsubruleMapper, evaluationMapper, itemevaluationMapper, - ledgerSubTypeMapper, ledgerRecordMapper, userinfoMapper, userMapMapper, townMapper - ) val dataSource = DataSource(config, dbMapper) val t = when (config.mode) { 1 -> ReportOne(dataSource) @@ -119,25 +108,26 @@ else -> ReportOne(dataSource) } val fileName = t.getReportName() - val fName = URLEncoder.encode(fileName, "UTF-8") - response.apply { - setHeader("Content-Disposition", "attachment;filename=$fName") - setHeader("fileName", fName) - addHeader("Access-Control-Expose-Headers", "fileName") - contentType = "application/vnd.ms-excel;charset=UTF-8" - setHeader("Pragma", "no-cache") - setHeader("Cache-Control", "no-cache") - setDateHeader("Expires", 0) - } - val p = "$filePath/autoscore/" val file = File(p + fileName) if (config.forceUpdate || !file.exists()) { - t.toFile(p) + val downloadUrl = "/autoscore/${fileName}" + reportTaskCtrl.startTask(t, downloadUrl) + return false + } else { + val fName = Base64.getEncoder().encodeToString(fileName.toByteArray()) + response.apply { + setHeader("Content-Disposition", "attachment;filename=$fName") + setHeader("fileName", fName) + addHeader("Access-Control-Expose-Headers", "fileName") + contentType = "application/vnd.ms-excel;charset=UTF-8" + setHeader("Pragma", "no-cache") + setHeader("Cache-Control", "no-cache") + setDateHeader("Expires", 0) + } + response.outputStream.write(file.readBytes()) + return true } - response.outputStream.write(file.readBytes()) - - return true } override fun getSubTaskDetail(config: ExcelConfigVo): SubTaskTableVo { @@ -537,10 +527,11 @@ ledgerSubTypeMapper, ledgerRecordMapper, userinfoMapper, userMapMapper, townMapper ) val task = - taskService.getByDistrictCode(config.districtCode, config.startTime)?.takeIf { it.isNotEmpty() }?.get(0) + taskService.getByDistrictCode(config.districtCode, config.startTime).takeIf { it.isNotEmpty() }?.get(0) config.topTaskGuid = task?.tguid ?: "" + config.allScene = false val dataSource = mutableListOf<DataSource>() - config.sceneType = Constant.SceneType.TYPE1.value.toInt() +// config.sceneType = Constant.SceneType.TYPE1.value.toInt() dataSource.add(DataSource(config, dbMapper)) // val config2 = config.copy(sceneType = Constant.ScenseType.TYPE2.value.toInt()) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt index d58addf..1d3bdbf 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt @@ -149,6 +149,7 @@ @Transactional override fun saveList(subtasklist: List<Subtask>): Int { subtasklist.forEach { + if (it.stguid == null) it.stguid = UUIDGenerator.generate16ShortUUID() subtaskMapper.insert(it) } return subtasklist.size @@ -383,18 +384,21 @@ override fun findAll(): MutableList<Subtask> = subtaskMapper.selectAll() - override fun save(subtask: Subtask): Int = subtaskMapper.insert(subtask) + 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 //鏍规嵁瀛愪换鍔uid鑾峰彇椤跺眰浠诲姟 val toptaskVo = taskService.findByID(subtask.tguid.toString()) // //鏍规嵁鏃ユ湡鑾峰彇鏃ヤ换鍔� -// val daytaskVo = taskService.findByDate(DateUtil.getDate(subtask.planstarttime)!!) + val daytaskVo = taskService.findByDate(subtask.tguid!!, DateUtil.getDate(subtask.planstarttime)!!) //搴旇鐩存帴鏍规嵁瀛愪换鍔$殑鏃ヤ换鍔d鏌ヨ鏃ヤ换鍔� - val daytaskVo = taskService.findByID(subtask.tsguid!!) +// val daytaskVo = taskService.findByID(subtask.tsguid!!) //鍒ゆ柇鏄惁鏈夋棩浠诲姟 if (StringUtil.isEmpty(daytaskVo.tguid)) { @@ -407,18 +411,18 @@ 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") + DateUtil.StringToDate(DateUtil.getDate(subtask.planstarttime)!!.substring(0, 10) + " 23:59:59") //****鏃ヤ换鍔℃墽琛岀姸鎬佺户鎵垮瓙浠诲姟鐨勭姸鎬�*锛堜慨鏀癸級*** task.runingstatus = subtask.status //******************************************** taskService.save(task) subtask.tsguid = guid - subtaskMapper.updateByPrimaryKeySelective(subtask) + res = subtaskMapper.updateByPrimaryKeySelective(subtask) } else { -// subtask.tsguid = daytaskVo.tguid + subtask.tsguid = daytaskVo.tguid //*锛堜慨鏀癸級*鏃ヤ换鍔℃鍦ㄦ墽琛岋紝瀛愪换鍔$粨鏉燂紝閬嶅巻鎵�鏈夊叾浣欏瓙浠诲姟锛岄兘鏄粨鏉熸椂鎵嶅皢鏃ヤ换鍔′慨鏀逛负缁撴潫**** if (subtask.status == Constant.TaskProgress.RUNINGSTATUS3.text - && daytaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS2.text){ + && daytaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS2.text){ val subtaskVolist = findByDayTaskID(daytaskVo.tguid!!) var bool = false subtaskVolist.forEach { @@ -439,9 +443,13 @@ BeanUtils.copyProperties(daytaskVo, daytask) taskMapper.updateByPrimaryKeySelective(daytask) //**************************************************************************************** - subtaskMapper.updateByPrimaryKeySelective(subtask) + 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) @@ -453,7 +461,7 @@ } } - return 1 + return res } override fun delete(id: String): Int{ @@ -474,15 +482,13 @@ createCriteria().andEqualTo("tid", topTaskId).andEqualTo("sguid", sceneId) }) mList.forEach { - if (it.monitornum == null) { - it.monitornum = 0 - } else { - it.monitornum = it.monitornum!! - 1 - if (it.monitornum!! < 0) { - it.monitornum = 0 - } + var count = it.extension1?.toIntOrNull() ?: 0 + count-- + if (count < 0) { + count = 0 } - monitorobjectversionMapper.insert(it) + it.extension1 = count.toString() + monitorobjectversionMapper.updateByPrimaryKeySelective(it) } // 鍚屾椂鍒犻櫎瀵瑰簲闂鍜屽贰鏌ヨ褰� diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt index bc6354d..87908bb 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt @@ -1,5 +1,6 @@ package cn.flightfeather.supervision.lightshare.service.impl +import cn.flightfeather.supervision.common.exception.BizException import cn.flightfeather.supervision.domain.ds1.entity.Problemlist import cn.flightfeather.supervision.domain.ds1.entity.Subtask import cn.flightfeather.supervision.domain.ds1.entity.Task @@ -8,6 +9,7 @@ import cn.flightfeather.supervision.domain.ds1.mapper.TaskMapper 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.* @@ -104,7 +106,7 @@ townRank.standardRate = it.get("standardRate").toString().toFloat() } catch (e: Exception) { } - val s =it.get("hasScoredNum").toString() + val s = it.get("hasScoredNum").toString() try { townRank.hasScoredNum = it.get("hasScoredNum").toString().toInt() } catch (e: Exception) { @@ -164,7 +166,7 @@ if (type == 0) return getAllTop() //鑾峰彇鏈畬鎴愰《灞備换鍔″強瀵瑰簲鏃ヤ换鍔″垪琛� - else if (type == 1){ + else if (type == 1) { val tmp = getAllTop() tmp.forEach { if (it.runingstatus != Constant.TaskProgress.RUNINGSTATUS3.text) { @@ -178,13 +180,13 @@ } //鏍规嵁鏃ユ湡鑾峰彇鏃ヤ换鍔� - override fun findByDate(date: String): TaskVo { + override fun findByDate(topTaskId: String, date: String): TaskVo { val taskVo = TaskVo() val example = Example(Task::class.java) val criteria = example.createCriteria() //gsguid涓嶄负绌轰负鏃ヤ换鍔�,鏃ヤ换鍔″紑濮嬫椂闂村拰缁撴潫鏃堕棿鍦ㄥ悓涓�澶�,杩囨护寮�濮嬫椂闂村氨ok criteria.andEqualTo("starttime", DateUtil.StringToDate(date.substring(0, 10))) - criteria.andIsNotNull("tsguid") + criteria.andEqualTo("tsguid", topTaskId) val tasklist = taskMapper.selectByExample(example) if (tasklist.isNotEmpty()) { BeanUtils.copyProperties(tasklist[0], taskVo) @@ -223,10 +225,10 @@ // .andEqualTo("districtcode", districtCode) // .andLessThanOrEqualTo("endtime", date) // example.or( - example.createCriteria().andIsNull("tsguid") - .andEqualTo("districtcode", districtCode) - .andLessThanOrEqualTo("starttime", date) - .andGreaterThanOrEqualTo("endtime", date) + example.createCriteria().andIsNull("tsguid") + .andEqualTo("districtcode", districtCode) + .andLessThanOrEqualTo("starttime", date) + .andGreaterThanOrEqualTo("endtime", date) // ) example.orderBy("starttime").desc() val tasklist = taskMapper.selectByExample(example) @@ -341,7 +343,7 @@ val complete = subtaskMapper.selectCountByExample(exampleComplete) var changed = 0 - problemListMapper.findUnchangedCount(it.tguid ?: "").forEach {i -> + problemListMapper.findUnchangedCount(it.tguid ?: "").forEach { i -> //缁撴灉琛ㄧず璇ュ瓙浠诲姟鏈暣鏀归棶棰樻暟 if (i == 0) { changed++ @@ -354,7 +356,7 @@ forEach { problemListMapper.selectByExample(Example(Problemlist::class.java).apply { createCriteria().andEqualTo("stguid", it.stguid) - }).forEach {problem -> + }).forEach { problem -> if (problem.extension3 == Constant.PROBLEM_UNCHECKED) { check = true return@breaking @@ -363,8 +365,8 @@ } } - resultList.add(DayTaskProgressVo( - it.tguid, it.starttime, taskId, complete, changed, total, check + resultList.add(DayTaskProgressVo( + it.tguid, it.starttime, taskId, complete, changed, total, check )) } @@ -522,25 +524,25 @@ val criteria2 = example.createCriteria() criteria2.orBetween( - "endtime", - startDate, - endDate + "endtime", + startDate, + endDate ).andIsNull("tsguid"); if (userType == "1") { criteria2.andLike("executorguids", "%$guid%") - } else if (userType == "2"){ + } else if (userType == "2") { criteria2.andEqualTo("districtcode", districtCode) } example.or(criteria2) val criteria3 = example.createCriteria() criteria3.orLessThan("starttime", startDate).andGreaterThan( - "endtime", - endDate + "endtime", + endDate ).andIsNull("tsguid"); if (userType == "1") { criteria3.andLike("executorguids", "%$guid%") - } else if (userType == "2"){ + } else if (userType == "2") { criteria3.andEqualTo("districtcode", districtCode) } example.or(criteria3) @@ -587,7 +589,7 @@ } return taskVoList } - + override fun save(task: Task): Int { // FIXME: 2021/10/9 鎸夌収褰撳墠鐨勯�昏緫锛屾鍑芥暟涓昏鐢ㄤ簬鏂板缓椤跺眰浠诲姟浠ュ強鏃ヤ换鍔★紝浣嗘槸鏃ヤ换鍔″唴瀹圭殑鐢熸垚閫昏緫鐩墠鐢卞墠绔痑pp瀹屾垚锛屽洜姝や細鍑虹幇涓�涓猙ug锛� // FIXME: 2021/10/9 褰撳墠绔涓敤鎴峰悓鏃跺湪鍚屼竴涓《灞備换鍔′笅鐨勬柊鐨勪竴澶╁垱寤轰换鍔℃椂锛屼細鍑虹幇鍚屼竴澶╂湁澶氫釜鏃ヤ换鍔★紝姝ゆ椂鍓嶇鍚庣画鏌ョ湅鍙兘鐪嬪埌鍏朵腑涓�涓棩浠诲姟涓嬬殑瀛愪换鍔� @@ -595,6 +597,7 @@ // FIXME: 2021/10/9 鍙﹀瀵逛簬椤跺眰浠诲姟涔熸坊鍔犵被浼奸�昏緫锛岀敱浜庨《灞備换鍔$殑浠诲姟鍚嶇О榛樿绯荤粺鑷姩鐢熸垚锛屽洜姝ゆ殏鏃跺彧鍒ゆ柇鍚屽悕鐨勯《灞備换鍔★紝褰撳瓨鍦ㄥ悓鍚嶉《灞備换鍔℃椂锛屼笉鍋氫繚瀛樻搷浣� var result = 0 + if (task.tguid == null) task.tguid = UUIDGenerator.generate16ShortUUID() // 1銆侀鍏堝垽鏂槸椤跺眰浠诲姟杩樻槸鏃ヤ换鍔� if (task.levelnum == 2) { //2.1銆� 鏄《灞備换鍔℃椂锛屽垽鏂槸鍚﹀凡鏈夊悓鍚嶄换鍔� @@ -608,7 +611,7 @@ } } else { //3.1銆� 褰撴槸鏃ヤ换鍔℃椂锛屽垽鏂湪鍚屼竴涓《灞備换鍔′笅锛屾槸鍚︽湁鍚屽悕鐨勬棩浠诲姟 - val r =taskMapper.selectByExample(Example(Task::class.java).apply { + val r = taskMapper.selectByExample(Example(Task::class.java).apply { createCriteria().andEqualTo("tsguid", task.tsguid) .andEqualTo("name", task.name) }) @@ -634,6 +637,14 @@ return result } + override fun create(task: Task): Task { + val res = save(task) + if (res < 1) + throw BizException("浠诲姟鍒涘缓澶辫触") + else + return task + } + //淇敼鏃ヤ换鍔′俊鎭�,鑻ユ湁瀛愪换鍔�,瀛愪换鍔′篃淇敼 override fun update(task: Task): Int { var re = 1 @@ -646,7 +657,7 @@ BeanUtils.copyProperties(it, subtask) subtask.planstarttime = task.starttime subtask.planendtime = task.endtime - subtaskService.update(subtask) + subtaskService.changeStatus(subtask) } } return re @@ -665,7 +676,7 @@ criteria.andIsNull("tsguid") example.orderBy("starttime").asc() val result = taskMapper.selectByExample(example) - if (result.isNotEmpty()){ + if (result.isNotEmpty()) { result.forEach { var mytotalcount = 0 var mycompletecount = 0 @@ -692,7 +703,7 @@ taskProgressVo.mycompletetask = mycompletecount val daytaskVolist = getDayTaskByTaskID(it.tguid!!) val daytasklist = mutableListOf<TaskVo>() - if (daytaskVolist.isNotEmpty()){ + if (daytaskVolist.isNotEmpty()) { daytaskVolist.forEach { var mytotalcount1 = 0 var mycompletecount1 = 0 @@ -704,7 +715,7 @@ if (Objects.equals(it.status!!, Constant.TaskProgress.RUNINGSTATUS3.text)) mycompletecount1++ } - if(Objects.equals(it.status, Constant.TaskProgress.RUNINGSTATUS3.text)) + if (Objects.equals(it.status, Constant.TaskProgress.RUNINGSTATUS3.text)) completecount1++ } val daytaskProgressVo = TaskVo() @@ -732,7 +743,7 @@ override fun findTaskProgress(areaVo: AreaVo): List<TaskProgressVo?> { val res = mutableListOf<TaskProgressVo?>() - taskRep.findTasks(areaVo).forEach {t-> + taskRep.findTasks(areaVo).forEach { t -> if (t?.tguid == null) return@forEach val pro = TaskProgressVo().apply { tguid = t.tguid diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserinfoServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserinfoServiceImpl.kt index 6de4b92..49b9890 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserinfoServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserinfoServiceImpl.kt @@ -47,9 +47,12 @@ } } - override fun findByType(typeId: Byte): List<Userinfo> { + override fun findByType(typeId: Byte, enable: Boolean?): List<Userinfo> { val result = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply { createCriteria().andEqualTo("usertypeid", typeId) + .apply { + enable?.let { andEqualTo("isenable", it) } + } }) return result diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/ExcelConfigVo.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/ExcelConfigVo.kt index c3fdc6a..2dbdce2 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/ExcelConfigVo.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/ExcelConfigVo.kt @@ -8,23 +8,26 @@ * 瀵煎嚭宸℃煡浠诲姟excel鏂囦欢 鏉′欢绫� */ data class ExcelConfigVo( - var topTaskGuid: String = "", + var topTaskGuid: String = "", - val startTime: Date? = null, - val endTime: Date? = null, + val startTime: Date? = null, + val endTime: Date? = null, - val provinceCode: String? = null, - val cityCode: String? = null, - val districtCode: String? = null, - val townCode: String? = null, + val provinceCode: String? = null, + val cityCode: String? = null, + val districtCode: String? = null, + val townCode: String? = null, - var sceneType: Int? = null, + var sceneType: Int? = null, - val subTaskIdList: List<String>? = null, + val subTaskIdList: List<String>? = null, - val problemTypeName: String? = null, - val problemName: String? = null, + val problemTypeName: String? = null, + val problemName: String? = null, - val mode: Int = 0, - val forceUpdate: Boolean = false + val mode: Int = 0, + val forceUpdate: Boolean = false, + + // 鍐冲畾鏄惁缁熻鎬讳换鍔′笅鎵�鏈夌殑鍦烘櫙鎴栧彧缁熻绛涢�夊嚭鐨勫瓙浠诲姟瀵瑰簲鐨勫満鏅� + var allScene: Boolean = true, ) \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/MonitorObjectVersionVo.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/MonitorObjectVersionVo.kt index 4a4d4d0..38161d1 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/MonitorObjectVersionVo.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/MonitorObjectVersionVo.kt @@ -14,4 +14,5 @@ */ var sceneType: String? = null + var scene: ScenseVo? = null } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductController.kt new file mode 100644 index 0000000..a76f7f4 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductController.kt @@ -0,0 +1,32 @@ +package cn.flightfeather.supervision.lightshare.web + +import cn.flightfeather.supervision.lightshare.service.DataProductService +import cn.flightfeather.supervision.lightshare.vo.AreaVo +import cn.flightfeather.supervision.lightshare.vo.ExcelConfigVo +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam +import org.springframework.web.bind.annotation.* +import springfox.documentation.annotations.ApiIgnore +import javax.servlet.http.HttpServletResponse + +/** + * 鏁版嵁浜у搧鐩稿叧API鎺ュ彛 + * @date 2024/10/18 + * @author feiyu02 + */ +@Api(tags = ["DataProductController"], description = "鏁版嵁浜у搧鐩稿叧API鎺ュ彛") +@RestController +@RequestMapping("/dataProduct") +class DataProductController(private val dataProductService: DataProductService) { + + @ApiOperation(value = "涓嬭浇鏁版嵁浜у搧鎶ュ憡") + @PostMapping("/download") + fun downloadProduct( + @ApiParam("鍖哄煙鏉′欢淇℃伅") @RequestBody areaVo: AreaVo, + @ApiParam("鎶ュ憡绫诲瀷", allowableValues = "1:闂涓庢暣鏀规眹鎬诲垎鏋愪笌鍔ㄦ�佽窡韪竻鍗�;2:瑙勮寖鎬ц瘎浼颁笌鍒嗘瀽娓呭崟;3:闂涓庢暣鏀瑰垎甯冨垎鏋愭竻鍗�;") + @RequestParam type: Int, + @ApiParam("鏄惁寮哄埗鐢熸垚鏂扮殑鎶ュ憡") @RequestParam forceUpdate: Boolean, + @ApiIgnore response: HttpServletResponse, + ) = resPack { dataProductService.downloadProduct(areaVo, type, forceUpdate, response) } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DomainitemController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DomainitemController.kt index 18b43b1..1500eea 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DomainitemController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DomainitemController.kt @@ -3,6 +3,8 @@ import cn.flightfeather.supervision.domain.ds1.entity.Domainitem import cn.flightfeather.supervision.lightshare.service.DomainitemService import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* @Api(tags = ["DomainitemController"], description = "鍊煎煙淇℃伅API鎺ュ彛") @@ -25,8 +27,21 @@ @DeleteMapping("/{id}") fun delete (@PathVariable id: String) = domainitemService.delete(id) + @ApiOperation("鑾峰彇鏌愮被鍦烘櫙鐨勯棶棰樹綅缃�夐」") @GetMapping("/location") fun getLocation( - @RequestParam("sceneType") sceneType:Int + @ApiParam("鍦烘櫙绫诲瀷id") @RequestParam("sceneType") sceneType:Int ) = domainitemService.getLocation(sceneType) + + @ApiOperation("鑾峰彇宸℃煡浠诲姟鐨勭被鍨嬮�夐」") + @GetMapping("/taskType") + fun getTaskType() = domainitemService.getTaskType() + + @ApiOperation("鑾峰彇宸℃煡浠诲姟鐨勬湡闄愮被鍨嬮�夐」") + @GetMapping("/deadlineType") + fun getDeadlineType() = domainitemService.getDeadlineType() + + @ApiOperation("鑾峰彇宸℃煡浠诲姟灞傛绫诲瀷閫夐」") + @GetMapping("/level") + fun getLevelType() = domainitemService.getLevelType() } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MediafileController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MediafileController.kt index 19ba7c5..47c5249 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MediafileController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MediafileController.kt @@ -27,9 +27,9 @@ @ApiOperation("鏍规嵁涓氬姟绫诲瀷鑾峰彇鏂囦欢") @GetMapping("/{id}/{btid}") fun getBySubtaskId( - @ApiParam("宸℃煡id") @PathVariable iGuid: String, + @ApiParam("宸℃煡id") @PathVariable id: String, @ApiParam("鏂囦欢涓氬姟绫诲瀷id", allowableValues = "") @PathVariable btid: String, - ) = mediafileService.findBysubtaskbtid(iGuid, btid) + ) = mediafileService.findBysubtaskbtid(id, btid) @ApiOperation("鑾峰彇鎵�鏈変换鎰忔媿甯歌璁板綍鍥剧墖", notes = "閫氳繃宸℃煡璁板綍id鎴栧贰鏌ヤ换鍔d鑾峰彇瀵瑰簲鐨勬墍鏈変换鎰忔媿鍥剧墖锛屼袱涓弬鏁颁换閫夊叾涓�鍗冲彲") @GetMapping("/routine") diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MenuController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MenuController.kt index a6dadff..7b2b1d7 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MenuController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MenuController.kt @@ -272,7 +272,7 @@ BeanUtils.copyProperties(subtaskVo, subtask) //濡傛灉guid涓嶄负绌�,閭e氨鏇存柊 if (!StringUtils.isEmpty(subtask.stguid)) { - subtaskService.update(subtask) + subtaskService.changeStatus(subtask) } else { //鑾峰彇鏃ヤ换鍔� val daytask = taskService.findByID(subtaskVo.tsguid!!) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SubtaskController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SubtaskController.kt index 103e7a1..46d2217 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SubtaskController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SubtaskController.kt @@ -28,7 +28,7 @@ @PostMapping fun update(@RequestBody subtask: Subtask): Int { - val res = subtaskService.update(subtask) + val res = subtaskService.changeStatus(subtask) if (subtask.status == Constant.TaskProgress.RUNINGSTATUS3.text) { val event = "鍦�${subtask.scensename}缁撴潫宸℃煡" bizLog.info(WorkStreamLogInfo(subtask.executorguids, subtask.executorrealtimes, event)) @@ -39,6 +39,10 @@ return res } + @ApiOperation("璋冩暣宸℃煡浠诲姟淇℃伅") + @PostMapping("/adjust") + fun adjust(@RequestBody subtask: Subtask) = resPack { subtaskService.update(subtask) } + @GetMapping("/{id}") fun getById(@PathVariable id: String) = subtaskService.findByID(id) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/TaskController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/TaskController.kt index 41d6006..dafb2b7 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/TaskController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/TaskController.kt @@ -15,6 +15,9 @@ @PutMapping fun save(@RequestBody task: Task) = taskService.save(task) + @PutMapping("/create") + fun create(@RequestBody task: Task) = resPack { taskService.create(task) } + @PostMapping fun update(@RequestBody task: Task) = taskService.update(task) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/UserinfoController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/UserinfoController.kt index c9ad232..19127ca 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/UserinfoController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/UserinfoController.kt @@ -19,8 +19,12 @@ @GetMapping("/{id}") fun getById(@PathVariable id: String) = userinfoService.findOne(id) + @ApiOperation(value = "鎸夌敤鎴风被鍨嬫悳绱㈢敤鎴蜂俊鎭�") @GetMapping("/type/get") - fun getUserByTypeId(@RequestParam typeId: Byte) = userinfoService.findByType(typeId) + fun getUserByTypeId( + @ApiParam("鐢ㄦ埛绫诲瀷id") @RequestParam typeId: Byte, + @ApiParam("鐢ㄦ埛鏄惁鍙敤", required = false, defaultValue = "true") @RequestParam(required = false) enable: Boolean? + ) = userinfoService.findByType(typeId, enable) @PutMapping("") fun add(@RequestBody userinfo: Userinfo) = userinfoService.save(userinfo) diff --git a/src/test/kotlin/cn/flightfeather/supervision/SupervisionApplicationTests.kt b/src/test/kotlin/cn/flightfeather/supervision/SupervisionApplicationTests.kt index 9595779..f374e7f 100644 --- a/src/test/kotlin/cn/flightfeather/supervision/SupervisionApplicationTests.kt +++ b/src/test/kotlin/cn/flightfeather/supervision/SupervisionApplicationTests.kt @@ -1,6 +1,7 @@ package cn.flightfeather.supervision +import cn.flightfeather.supervision.business.datafetch.FetchController import cn.flightfeather.supervision.infrastructure.service.ServerManager import cn.flightfeather.supervision.common.utils.UUIDGenerator //import org.junit.Test @@ -17,6 +18,10 @@ @Autowired private lateinit var manager: ServerManager + @Autowired + // 闈欏畨鍖哄闂存柦宸ヨ鍙瘉淇℃伅鑾峰彇浠诲姟 + lateinit var fetchController: FetchController + @Test fun contextLoads() { @@ -25,9 +30,8 @@ @Test @Throws(Exception::class) fun test1() { - //manager.startServer(args[0]); - val uuid= UUIDGenerator.generateUUID(4) - print(uuid) + fetchController.run() + } } diff --git a/src/test/kotlin/cn/flightfeather/supervision/business/location/LocationRoadNearbyTest.kt b/src/test/kotlin/cn/flightfeather/supervision/business/location/LocationRoadNearbyTest.kt index 2fed9ec..fd5ce33 100644 --- a/src/test/kotlin/cn/flightfeather/supervision/business/location/LocationRoadNearbyTest.kt +++ b/src/test/kotlin/cn/flightfeather/supervision/business/location/LocationRoadNearbyTest.kt @@ -204,4 +204,13 @@ // val d = CoordinateUtil.calculateDistance(121.436109, 31.178198, 121.426483, 31.177637) // println(d) } + + @Test + fun foo3(){ + val locationDistance = LocationDistance(scenseMapper) + val bList = listOf( + BasePlace("閲戝北澶ч亾2000鍙�", Pair(121.3404, 30.744262), Pair(121.3404, 30.744262)), + ) + locationDistance.searchList(bList, "閲戝北鍖�") + } } \ No newline at end of file -- Gitblit v1.9.3