| | |
| | | <artifactId>spring-boot-starter-webflux</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-websocket</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- https://mvnrepository.com/artifact/org.springframework.plugin/spring-plugin-core --> |
| | | <dependency> |
| | | <groupId>org.springframework.plugin</groupId> |
| | |
| | | |
| | | import cn.flightfeather.supervision.business.datafetch.FetchController |
| | | import org.springframework.beans.factory.annotation.Autowired |
| | | import org.springframework.beans.factory.annotation.Value |
| | | import org.springframework.boot.ApplicationRunner |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication |
| | | import org.springframework.boot.runApplication |
| | |
| | | |
| | | @SpringBootApplication |
| | | @EnableScheduling |
| | | class SupervisionApplication { |
| | | class SupervisionApplication( |
| | | @Value("\${mode}") |
| | | var mode: String |
| | | ) { |
| | | |
| | | @Autowired |
| | | // éå®åºå¤é´æ½å·¥è®¸å¯è¯ä¿¡æ¯è·åä»»å¡ |
| | |
| | | |
| | | @Bean |
| | | fun runner() = ApplicationRunner { |
| | | if (mode == "pro") { |
| | | fetchController.run() |
| | | } |
| | | println("mode: $mode") |
| | | } |
| | | } |
| | | |
| | | fun main(args: Array<String>) { |
| | |
| | | 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), |
| | |
| | | scense.location ?: "", |
| | | scense.longitude?.toDouble() ?: .0, |
| | | scense.latitude?.toDouble() ?: .0, |
| | | scense.districtname ?: "", |
| | | scense.townname ?: "", |
| | | scense.contacts ?: "", |
| | | scense.contactst ?: "" |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.flightfeather.supervision.common.log |
| | | |
| | | import cn.flightfeather.supervision.common.utils.JsonUtil |
| | | import com.fasterxml.jackson.annotation.JsonFormat |
| | | import com.google.gson.Gson |
| | | import java.time.LocalDateTime |
| | | |
| | | /** |
| | | * æ¥å¿ä¿¡æ¯ç»æ |
| | | * @date 2024/7/19 |
| | | * @author feiyu02 |
| | | */ |
| | | open class AbstractLogInfo() { |
| | | |
| | | constructor(event: String) : this() { |
| | | this.event = event |
| | | } |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | var time: LocalDateTime = LocalDateTime.now() |
| | | var event: String = "" |
| | | |
| | | fun toJsonStr(): String { |
| | | return JsonUtil.gson.toJson(this) |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.flightfeather.supervision.common.log |
| | | |
| | | import cn.flightfeather.supervision.socket.processor.WebSocketSender |
| | | import org.springframework.stereotype.Component |
| | | |
| | | /** |
| | | * ä¸å¡æ¥å¿ç®¡ç |
| | | * ç¸æ¯äºlog4J2çæ¡æ¶æ¥å¿ï¼æ¤å¤æ¥å¿éè¦è®°å½è³æ°æ®åºææ¨éè³çæ§å¹³å°ï¼æ¹ä¾¿æµè§ç®¡ç |
| | | * @date 2024/7/19 |
| | | * @author feiyu02 |
| | | */ |
| | | @Component |
| | | class BizLog( |
| | | private val webSocketSender: WebSocketSender, |
| | | ) { |
| | | // TODO: 2024/7/19 åç»éæ·»å æ¥å¿ç¸å
³çæ°æ®åºåå¨åè½ |
| | | |
| | | /** |
| | | * è®°å½å¸¸ææ¥å¿ |
| | | */ |
| | | fun info(logInfo: AbstractLogInfo) { |
| | | // å¹¿ææ¥å¿ |
| | | webSocketSender.broadcast(logInfo.toJsonStr()) |
| | | // TODO: 2024/7/19 æ¥å¿å
¥åº |
| | | } |
| | | |
| | | /** |
| | | * è®°å½é误æ¥å¿ |
| | | */ |
| | | fun error() { |
| | | // TODO: 2024/7/19 æ¥å¿å
¥åº |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.flightfeather.supervision.common.log |
| | | |
| | | import cn.flightfeather.supervision.domain.ds1.entity.Userinfo |
| | | |
| | | /** |
| | | * 工使¥å¿ |
| | | * @date 2024/7/19 |
| | | * @author feiyu02 |
| | | */ |
| | | class WorkStreamLogInfo : AbstractLogInfo { |
| | | |
| | | constructor() : super() |
| | | constructor(userId: String?, userName: String?, type: String?, event: String) : super(event) { |
| | | this.userId = userId |
| | | this.userName = userName |
| | | this.type = type |
| | | } |
| | | constructor(userId: String?, userName: String?, event: String) : this(userId, userName, null, event) |
| | | constructor(userInfo: Userinfo?, event: String) : this(userInfo?.guid, userInfo?.realname, null, event) |
| | | |
| | | var userId: String? = null |
| | | var userName: String? = null |
| | | var type: String? = null |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.flightfeather.supervision.common.utils |
| | | |
| | | import com.google.gson.Gson |
| | | import com.google.gson.GsonBuilder |
| | | |
| | | object JsonUtil { |
| | | |
| | | val gson: Gson = GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create() |
| | | } |
| | |
| | | package cn.flightfeather.supervision.lightshare.service.impl |
| | | |
| | | import cn.flightfeather.supervision.common.exception.BizException |
| | | import cn.flightfeather.supervision.common.log.BizLog |
| | | import cn.flightfeather.supervision.common.log.WorkStreamLogInfo |
| | | import cn.flightfeather.supervision.domain.ds1.entity.Problemlist |
| | | import cn.flightfeather.supervision.domain.ds1.entity.Scense |
| | | import cn.flightfeather.supervision.common.utils.Constant |
| | |
| | | private val taskRep: TaskRep, |
| | | private val subTaskRep: SubTaskRep, |
| | | private val problemRep: ProblemRep, |
| | | private val bizLog: BizLog, |
| | | ) : ProblemlistService { |
| | | |
| | | @Resource |
| | |
| | | return BaseResponse(false, "éæ³çæä½æä»¤") |
| | | } |
| | | val p = problemlistMapper.selectByPrimaryKey(pId) ?: return BaseResponse(false, "é®é¢ä¸åå¨") |
| | | val subtask = p.stguid?.let { subTaskRep.findOne(it) } |
| | | val response = BaseResponse<String>(true) |
| | | var event = "" |
| | | |
| | | p.apply { |
| | | this.remark = userName |
| | | if (extension3 == Constant.PROBLEM_UNCHECKED) { |
| | | event = "å¨${subtask?.scensename}å®¡æ ¸äºä¸ä¸ªé®é¢" |
| | | when (action) { |
| | | 0.toByte() -> extension3 = Constant.PROBLEM_CHECK_PASS |
| | | 1.toByte() -> extension3 = Constant.PROBLEM_CHECK_FAIL |
| | | 0.toByte() -> { |
| | | extension3 = Constant.PROBLEM_CHECK_PASS |
| | | } |
| | | 1.toByte() -> { |
| | | extension3 = Constant.PROBLEM_CHECK_FAIL |
| | | } |
| | | 2.toByte(), |
| | | 3.toByte(), |
| | | -> { |
| | |
| | | } else { |
| | | Constant.CHANGE_CHECK_FAIL |
| | | } |
| | | event = "å¨${subtask?.scensename}å®¡æ ¸äºä¸ä¸ªæ´æ¹" |
| | | } else { |
| | | response.success = false |
| | | response.message = "é®é¢è¿æªæ´æ¹ï¼æ æ³è¿è¡æ´æ¹å®¡æ ¸ï¼æä½æ æ" |
| | |
| | | } |
| | | } |
| | | } else if (extension3 == Constant.CHANGE_UNCHECKED) { |
| | | event = "å¨${subtask?.scensename}å®¡æ ¸äºä¸ä¸ªæ´æ¹" |
| | | when (action) { |
| | | 0.toByte(), |
| | | 1.toByte(), |
| | |
| | | if (r != 1) { |
| | | response.success = false |
| | | response.message = "é®é¢æ´æ°å¤±è´¥ï¼" |
| | | } else { |
| | | bizLog.info(WorkStreamLogInfo(subtask?.executorguids, subtask?.executorrealtimes, event)) |
| | | } |
| | | } |
| | | return response |
| | |
| | | inspectionMapper.updateByPrimaryKey(inspection) |
| | | } |
| | | |
| | | problemlist.stguid?.let { |
| | | val subtask = subTaskRep.findOne(it) |
| | | val event = "å¨${subtask?.scensename}æ°å¢ä¸ä¸ªé®é¢" |
| | | bizLog.info(WorkStreamLogInfo(subtask?.executorguids, subtask?.executorrealtimes, event)) |
| | | } |
| | | |
| | | return BaseResponse(true) |
| | | } |
| | | |
| | |
| | | if (!bool){ |
| | | daytaskVo.runingstatus = Constant.TaskProgress.RUNINGSTATUS3.text |
| | | } |
| | | |
| | | } |
| | | //两è
ç¶æç¸åæ¶ä¸åä¿®æ¹ï¼å
¶ä½æ
嵿¥ä»»å¡é½ä¸ºæ£å¨æ§è¡ |
| | | else if (subtask.status != daytaskVo.runingstatus){ |
| | |
| | | //**************************************************************************************** |
| | | subtaskMapper.updateByPrimaryKeySelective(subtask) |
| | | } |
| | | |
| | | //夿坹åºé¡¶å±ä»»å¡çæ§è¡ç¶æ |
| | | // val daytaskVolist = taskService.getDayTaskByTaskID(toptaskVo.tguid!!) |
| | | // val iterator: Iterator<TaskVo> = daytaskVolist.iterator() |
| | | // if (daytaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS3.text |
| | | // && toptaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS2.text) { |
| | | // var bool = false |
| | | // while (iterator.hasNext()) { |
| | | // val tmp = iterator.next() |
| | | // if (tmp.runingstatus != Constant.TaskProgress.RUNINGSTATUS3.text) { |
| | | // bool = true |
| | | // break |
| | | // } |
| | | // } |
| | | // if (!bool){ |
| | | // toptaskVo.runingstatus = Constant.TaskProgress.RUNINGSTATUS3.text |
| | | // } |
| | | // } |
| | | // else if (daytaskVo.runingstatus != toptaskVo.runingstatus){ |
| | | // toptaskVo.runingstatus = Constant.TaskProgress.RUNINGSTATUS2.text |
| | | // } |
| | | // val toptask = Task() |
| | | // BeanUtils.copyProperties(toptaskVo, toptask) |
| | | // taskMapper.updateByPrimaryKeySelective(toptask) |
| | | |
| | | //å¯¹å·²ç»æçåä»»å¡è¿è¡èªå¨è¯å |
| | | if (subtask.status == Constant.TaskProgress.RUNINGSTATUS3.text) { |
| | |
| | | package cn.flightfeather.supervision.lightshare.vo |
| | | |
| | | import cn.flightfeather.supervision.domain.ds1.entity.Problemlist |
| | | import com.fasterxml.jackson.annotation.JsonInclude |
| | | import java.util.* |
| | | |
| | |
| | | |
| | | var changeCount: Int = 0 |
| | | |
| | | var problems: List<Problemlist>? = null |
| | | |
| | | } |
| | |
| | | package cn.flightfeather.supervision.lightshare.web |
| | | |
| | | import cn.flightfeather.supervision.common.log.BizLog |
| | | import cn.flightfeather.supervision.common.log.WorkStreamLogInfo |
| | | import cn.flightfeather.supervision.domain.ds1.entity.Problemlist |
| | | import cn.flightfeather.supervision.lightshare.service.ProblemlistService |
| | | import cn.flightfeather.supervision.lightshare.service.SubtaskService |
| | | import cn.flightfeather.supervision.lightshare.vo.* |
| | | import io.swagger.annotations.Api |
| | | import io.swagger.annotations.ApiOperation |
| | |
| | | @Api(tags = ["ProblemlistController"], description = "ç管é®é¢APIæ¥å£") |
| | | @RestController |
| | | @RequestMapping("/problemlist") |
| | | class ProblemlistController(val problemlistService: ProblemlistService) { |
| | | class ProblemlistController( |
| | | val problemlistService: ProblemlistService, |
| | | val subtaskService: SubtaskService, private val bizLog: BizLog, |
| | | ) { |
| | | @GetMapping |
| | | fun getAll() = problemlistService.findAll() |
| | | |
| | |
| | | fun add(@RequestBody problemlist: Problemlist) = problemlistService.save(problemlist) |
| | | |
| | | @PostMapping |
| | | fun update(@RequestBody problemlist: Problemlist) = problemlistService.update(problemlist) |
| | | fun update(@RequestBody problemlist: Problemlist):Int{ |
| | | val res = problemlistService.update(problemlist) |
| | | problemlist.stguid?.let { |
| | | val subtask = subtaskService.findByID(it) |
| | | val event = "å¨${subtask.scensename}æ°å¢ä¸ä¸ªé®é¢" |
| | | bizLog.info(WorkStreamLogInfo(subtask.executorguids, subtask.executorrealtimes, event)) |
| | | } |
| | | return res |
| | | } |
| | | |
| | | @GetMapping("/{id}") |
| | | fun getById(@PathVariable id: String) = problemlistService.findByID(id) |
| | |
| | | package cn.flightfeather.supervision.lightshare.web |
| | | |
| | | import cn.flightfeather.supervision.common.log.BizLog |
| | | import cn.flightfeather.supervision.common.log.WorkStreamLogInfo |
| | | import cn.flightfeather.supervision.common.utils.Constant |
| | | import cn.flightfeather.supervision.domain.ds1.entity.Subtask |
| | | import cn.flightfeather.supervision.lightshare.service.SubtaskService |
| | | import cn.flightfeather.supervision.lightshare.vo.AreaVo |
| | |
| | | @Api(tags = ["SubtaskController"], description = "å·¡æ¥åä»»å¡APIæ¥å£") |
| | | @RestController |
| | | @RequestMapping("/subtask") |
| | | class SubtaskController(val subtaskService: SubtaskService) { |
| | | class SubtaskController(val subtaskService: SubtaskService, private val bizLog: BizLog) { |
| | | @GetMapping |
| | | fun getAll() = subtaskService.findAll() |
| | | |
| | |
| | | fun addList(@RequestBody subtasklist: List<Subtask>) = subtaskService.saveList(subtasklist) |
| | | |
| | | @PostMapping |
| | | fun update(@RequestBody subtask: Subtask) = subtaskService.update(subtask) |
| | | fun update(@RequestBody subtask: Subtask): Int { |
| | | val res = subtaskService.update(subtask) |
| | | if (subtask.status == Constant.TaskProgress.RUNINGSTATUS3.text) { |
| | | val event = "å¨${subtask.scensename}ç»æå·¡æ¥" |
| | | bizLog.info(WorkStreamLogInfo(subtask.executorguids, subtask.executorrealtimes, event)) |
| | | }else if (subtask.status == Constant.TaskProgress.RUNINGSTATUS2.text) { |
| | | val event = "å¨${subtask.scensename}å¼å§å·¡æ¥" |
| | | bizLog.info(WorkStreamLogInfo(subtask.executorguids, subtask.executorrealtimes, event)) |
| | | } |
| | | return res |
| | | } |
| | | |
| | | @GetMapping("/{id}") |
| | | fun getById(@PathVariable id: String) = subtaskService.findByID(id) |
| | |
| | | import cn.flightfeather.supervision.lightshare.vo.AreaVo |
| | | import org.slf4j.Logger |
| | | import org.slf4j.LoggerFactory |
| | | import org.springframework.beans.factory.annotation.Value |
| | | import org.springframework.scheduling.annotation.Async |
| | | import org.springframework.scheduling.annotation.Scheduled |
| | | import org.springframework.stereotype.Component |
| | | import java.time.LocalDate |
| | | import java.time.LocalDateTime |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Component |
| | | class ScheduleService( |
| | | @Value("\${mode}") |
| | | var mode: String, |
| | | private val taskFinishSubtask: TaskFinishSubtask, |
| | | private val taskFinishTopTask: TaskFinishTopTask, |
| | | private val aopTaskCtrl: AopTaskCtrl, |
| | |
| | | @Async |
| | | @Scheduled(cron = "0 0 0 * * *") |
| | | fun eachDay() { |
| | | if (mode != "pro") return |
| | | |
| | | logger.info("=====>>>>>æ¯æ¥ä»»å¡æ§è¡ {}", System.currentTimeMillis()) |
| | | taskFinishSubtask.handle() |
| | | logger.info("=====>>>>>æ¯æ¥ä»»å¡ç»æ {}", System.currentTimeMillis()) |
| | |
| | | @Async |
| | | @Scheduled(cron = "0 0 0 * * MON") |
| | | fun eachWeek() { |
| | | if (mode != "pro") return |
| | | |
| | | logger.info("=====>>>>>æ¯å¨ä»»å¡æ§è¡ {}", System.currentTimeMillis()) |
| | | // æ§è¡ä¸å¨çèªè¯ä»»å¡ |
| | | aopTaskCtrl.startAllEvaluation(LocalDateTime.now()) |
| | | aopTaskCtrl.startAllEvaluation(LocalDate.now().atStartOfDay()) |
| | | logger.info("=====>>>>>æ¯å¨ä»»å¡ç»æ {}", System.currentTimeMillis()) |
| | | } |
| | | |
| | | @Async |
| | | @Scheduled(cron = "0 0 0 2 * *") |
| | | fun eachMonth() { |
| | | if (mode != "pro") return |
| | | |
| | | logger.info("=====>>>>>æ¯æä»»å¡æ§è¡ {}", System.currentTimeMillis()) |
| | | // æ§è¡ä¸ä¸ªæç宿´èªè¯ä»»å¡ |
| | | aopTaskCtrl.startAll(LocalDateTime.now().minusMonths(1)) |
| | | aopTaskCtrl.startAll(LocalDate.now().atStartOfDay().minusMonths(1)) |
| | | // æ§è¡é¡¶å±ä»»å¡èªå¨ç»æä»»å¡ |
| | | taskFinishTopTask.handle() |
| | | logger.info("=====>>>>>æ¯æä»»å¡ç»æ {}", System.currentTimeMillis()) |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.flightfeather.supervision.socket |
| | | |
| | | import org.springframework.web.socket.WebSocketSession |
| | | import java.io.IOException |
| | | import java.util.concurrent.ConcurrentHashMap |
| | | |
| | | /** |
| | | * |
| | | * @date 2024/7/19 |
| | | * @author feiyu02 |
| | | */ |
| | | object WsSessionManager { |
| | | /** |
| | | * ä¿åè¿æ¥ session çå°æ¹ |
| | | */ |
| | | private val SESSION_POOL = ConcurrentHashMap<String, WebSocketSession>() |
| | | |
| | | /** |
| | | * æ·»å session |
| | | * |
| | | * @param key |
| | | */ |
| | | fun add(key: String, session: WebSocketSession) { |
| | | // æ·»å session |
| | | SESSION_POOL[key] = session |
| | | } |
| | | |
| | | /** |
| | | * å é¤ session,ä¼è¿åå é¤ç session |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | fun remove(key: String?): WebSocketSession? { |
| | | // å é¤ session |
| | | return SESSION_POOL.remove(key) |
| | | } |
| | | |
| | | /** |
| | | * å é¤å¹¶åæ¥å
³éè¿æ¥ |
| | | * |
| | | * @param key |
| | | */ |
| | | fun removeAndClose(key: String?) { |
| | | val session: WebSocketSession? = remove(key) |
| | | if (session != null) { |
| | | try { |
| | | // å
³éè¿æ¥ |
| | | session.close() |
| | | } catch (e: IOException) { |
| | | // todo: å
³éåºç°å¼å¸¸å¤ç |
| | | e.printStackTrace() |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·å¾ session |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | operator fun get(key: String?): WebSocketSession? { |
| | | // è·å¾ session |
| | | return SESSION_POOL[key] |
| | | } |
| | | |
| | | fun eachSession(action:(session:WebSocketSession) -> Unit) { |
| | | SESSION_POOL.forEachEntry(10){ |
| | | action(it.value) |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.flightfeather.supervision.socket.config |
| | | |
| | | import cn.flightfeather.supervision.socket.WsSessionManager |
| | | import cn.flightfeather.supervision.socket.processor.WebSocketReceiver |
| | | import org.springframework.stereotype.Component |
| | | import org.springframework.web.socket.CloseStatus |
| | | import org.springframework.web.socket.TextMessage |
| | | import org.springframework.web.socket.WebSocketSession |
| | | import org.springframework.web.socket.handler.TextWebSocketHandler |
| | | |
| | | /** |
| | | * |
| | | * @date 2024/7/19 |
| | | * @author feiyu02 |
| | | */ |
| | | @Component |
| | | class SPTextWebSocketHandler(private val webSocketReceiver: WebSocketReceiver) : TextWebSocketHandler() { |
| | | /** |
| | | * socket å»ºç«æåäºä»¶ |
| | | * |
| | | * @param session |
| | | * @throws Exception |
| | | */ |
| | | @Throws(Exception::class) |
| | | override fun afterConnectionEstablished(session: WebSocketSession) { |
| | | val sessionId = session.attributes["session_id"] |
| | | if (sessionId != null) { |
| | | // ç¨æ·è¿æ¥æåï¼æ¾å
¥å¨çº¿ç¨æ·ç¼å |
| | | WsSessionManager.add(sessionId.toString(), session) |
| | | } else { |
| | | throw RuntimeException("ç¨æ·ç»å½å·²ç»å¤±æ!") |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¥æ¶æ¶æ¯äºä»¶ |
| | | * |
| | | * @param session |
| | | * @param message |
| | | * @throws Exception |
| | | */ |
| | | @Throws(Exception::class) |
| | | override fun handleTextMessage(session: WebSocketSession, message: TextMessage) { |
| | | // è·å¾å®¢æ·ç«¯ä¼ æ¥çæ¶æ¯ |
| | | val payload = message.payload |
| | | val sessionId = session.attributes["session_id"] |
| | | println("server æ¥æ¶å° $sessionId åéç $payload") |
| | | webSocketReceiver.onReceiveMsg(payload) |
| | | // session.sendMessage(TextMessage("server åéç» " + sessionId + " æ¶æ¯ " + payload + " " + LocalDateTime.now() |
| | | // .toString())) |
| | | } |
| | | |
| | | /** |
| | | * socket æå¼è¿æ¥æ¶ |
| | | * |
| | | * @param session |
| | | * @param status |
| | | * @throws Exception |
| | | */ |
| | | @Throws(Exception::class) |
| | | override fun afterConnectionClosed(session: WebSocketSession, status: CloseStatus) { |
| | | val sessionId = session.attributes["session_id"] |
| | | if (sessionId != null) { |
| | | // ç¨æ·éåºï¼ç§»é¤ç¼å |
| | | WsSessionManager.remove(sessionId.toString()) |
| | | } |
| | | } |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.flightfeather.supervision.socket.config |
| | | |
| | | import cn.flightfeather.supervision.scheduler.ScheduleService |
| | | import org.springframework.context.annotation.Bean |
| | | import org.springframework.context.annotation.Configuration |
| | | import org.springframework.scheduling.TaskScheduler |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler |
| | | import org.springframework.web.socket.config.annotation.EnableWebSocket |
| | | import org.springframework.web.socket.config.annotation.WebSocketConfigurer |
| | | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry |
| | | import javax.annotation.Nullable |
| | | |
| | | /** |
| | | * |
| | | * @date 2024/7/19 |
| | | * @author feiyu02 |
| | | */ |
| | | @Configuration |
| | | @EnableWebSocket |
| | | class WebSocketConfig( |
| | | private val handler: SPTextWebSocketHandler, |
| | | private val wsHandshakeInterceptor: WsHandshakeInterceptor |
| | | ) : WebSocketConfigurer { |
| | | |
| | | override fun registerWebSocketHandlers(registry: WebSocketHandlerRegistry) { |
| | | registry |
| | | .addHandler(handler, "workstream") |
| | | .addInterceptors(wsHandshakeInterceptor) |
| | | .setAllowedOrigins("*") |
| | | } |
| | | |
| | | /** |
| | | * webSocket宿¶å¨é
ç½®ï¼è§£å³åæ¥ä½¿ç¨å®æ¶å¨[ScheduleService]æ¶çå²çªé®é¢ |
| | | */ |
| | | @Bean |
| | | @Nullable |
| | | fun taskScheduler():TaskScheduler { |
| | | return ThreadPoolTaskScheduler().apply { |
| | | setThreadNamePrefix("SockJS-") |
| | | poolSize = Runtime.getRuntime().availableProcessors() |
| | | isRemoveOnCancelPolicy = true |
| | | } |
| | | } |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.flightfeather.supervision.socket.config |
| | | |
| | | import org.apache.logging.log4j.util.Strings |
| | | import org.springframework.http.server.ServerHttpRequest |
| | | import org.springframework.http.server.ServerHttpResponse |
| | | import org.springframework.stereotype.Component |
| | | import org.springframework.web.socket.WebSocketHandler |
| | | import org.springframework.web.socket.server.HandshakeInterceptor |
| | | |
| | | /** |
| | | * |
| | | * @date 2024/7/19 |
| | | * @author feiyu02 |
| | | */ |
| | | @Component |
| | | class WsHandshakeInterceptor : HandshakeInterceptor { |
| | | /** |
| | | * æ¡æå |
| | | */ |
| | | @Throws(Exception::class) |
| | | override fun beforeHandshake( |
| | | request: ServerHttpRequest, |
| | | response: ServerHttpResponse, |
| | | wsHandler: WebSocketHandler, |
| | | attributes: MutableMap<String, Any>, |
| | | ): Boolean { |
| | | println("æ¡æå¼å§") |
| | | val hostName = request.remoteAddress.hostName |
| | | // TODO: 2024/7/19 åç»å¯æ·»å ç¨æ·èº«ä»½éªè¯æºå¶,sessionId坿¿æ¢ä¸ºå®é
çç¨æ·id |
| | | val sessionId = hostName + (Math.random() * 1000).toInt().toString() |
| | | if (Strings.isNotBlank(sessionId)) { |
| | | // æ¾å
¥å±æ§å |
| | | attributes["session_id"] = sessionId |
| | | println("ç¨æ· session_id $sessionId æ¡ææåï¼") |
| | | return true |
| | | } |
| | | println("ç¨æ·ç»å½å·²å¤±æ") |
| | | return false |
| | | } |
| | | |
| | | /** |
| | | * æ¡æå |
| | | */ |
| | | override fun afterHandshake( |
| | | request: ServerHttpRequest, |
| | | response: ServerHttpResponse, |
| | | wsHandler: WebSocketHandler, |
| | | exception: Exception?, |
| | | ) { |
| | | println("æ¡æå®æ") |
| | | } |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.flightfeather.supervision.socket.processor |
| | | |
| | | import cn.flightfeather.supervision.common.log.BizLog |
| | | import cn.flightfeather.supervision.common.log.WorkStreamLogInfo |
| | | import org.springframework.stereotype.Component |
| | | |
| | | /** |
| | | * webSocketæ¶æ¯æ¥æ¶ç®¡ç |
| | | * @date 2024/7/19 |
| | | * @author feiyu02 |
| | | */ |
| | | @Component |
| | | class WebSocketReceiver(private val bizLog: BizLog) { |
| | | |
| | | /** |
| | | * æ¥æ¶æ¶æ¯å¤ç |
| | | */ |
| | | fun onReceiveMsg(msg: String) { |
| | | // debug |
| | | if (msg == "test"){ |
| | | bizLog.info(WorkStreamLogInfo("8FAqSPnAA8ry4ExX", "æ±æ£å¼º", "å¨ä¸æµ·å¹¿åç²ç
¤ç°æéå
¬å¸æ°å¢ä¸ä¸ªé®é¢")) |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.flightfeather.supervision.socket.processor |
| | | |
| | | import cn.flightfeather.supervision.socket.WsSessionManager |
| | | import org.springframework.stereotype.Component |
| | | import org.springframework.web.socket.TextMessage |
| | | |
| | | /** |
| | | * webSocketæ¶æ¯åé管ç |
| | | * @date 2024/7/19 |
| | | * @author feiyu02 |
| | | */ |
| | | @Component |
| | | class WebSocketSender { |
| | | |
| | | /** |
| | | * åç¬åéæ¶æ¯ |
| | | */ |
| | | fun sendMsg(msg: String, sessionId: String) { |
| | | WsSessionManager[sessionId]?.sendMessage(TextMessage(msg)) |
| | | } |
| | | |
| | | /** |
| | | * 广æç»ææäºº |
| | | */ |
| | | fun broadcast(msg: String) { |
| | | WsSessionManager.eachSession { |
| | | it.sendMessage(TextMessage(msg)) |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | imgPath: target |
| | | filePath: target |
| | | mode: dev |
| | |
| | | |
| | | imgPath: D:/02product/04supervision/images/ |
| | | filePath: D:/02product/04supervision/files/ |
| | | mode: pro |
| | |
| | | |
| | | imgPath: C:\02product\supervision\images |
| | | filePath: C:\02product\supervision\files |
| | | mode: test |
| | |
| | | |
| | | #loggingè·¯å¾è®¾ç½® |
| | | logging: |
| | | # config: classpath:log4j2.xml |
| | | level: |
| | | cn.flightfeather.supervision.domain: debug |
| | | config: classpath:log4j2.xml |
| | | # level: |
| | | # cn.flightfeather.supervision.domain: debug |
| | | |
| | | springfox: |
| | | documentation: |
| | |
| | | </logger> |
| | | |
| | | <root level="all"> |
| | | <appender-ref ref="Console"/> |
| | | <!-- <appender-ref ref="Console"/>--> |
| | | <appender-ref ref="RollingFileInfo"/> |
| | | <appender-ref ref="RollingFileWarn"/> |
| | | <appender-ref ref="RollingFileError"/> |
| | |
| | | <result property="endTime" column="endTime"/> |
| | | <result property="count" column="count"/> |
| | | <result property="changeCount" column="changeCount"/> |
| | | <!-- <collection property="problems" ofType="cn.flightfeather.supervision.domain.ds1.entity.Problemlist" resultMap="BaseResultMap"/>--> |
| | | </resultMap> |
| | | <resultMap id="SceneProblemSummary" type="cn.flightfeather.supervision.lightshare.vo.SceneProblemSummary"> |
| | | <id property="sceneId" column="sceneId"/> |
| | |
| | | LEFT JOIN sm_t_scense AS f ON a.S_GUID = f.S_GUID |
| | | LEFT JOIN tm_t_subtask AS c ON a.ST_GUID = c.ST_GUID |
| | | <where> |
| | | <!-- a.ST_GUID IN (--> |
| | | <!-- SELECT--> |
| | | <!-- d.ST_GUID--> |
| | | <!-- FROM--> |
| | | <!-- tm_t_subtask AS d LEFT JOIN tm_t_task AS e ON d.T_GUID = e.T_GUID--> |
| | | <!-- WHERE--> |
| | | <!-- e.T_LevelNum = '2'--> |
| | | <!-- <if test="startTime != null">--> |
| | | <!-- AND e.T_StartTime <= #{startTime}--> |
| | | <!-- </if>--> |
| | | <!-- <if test="endTime != null">--> |
| | | <!-- AND e.T_EndTime >= #{endTime}--> |
| | | <!-- </if>--> |
| | | <!-- <if test="districtCode != null">--> |
| | | <!-- AND e.T_DistrictCode = #{districtCode}--> |
| | | <!-- </if>--> |
| | | <!-- )--> |
| | | <if test="startTime != null"> |
| | | AND c.ST_PlanStartTime >= #{startTime} |
| | | </if> |
| | |
| | | import java.io.BufferedReader |
| | | import java.io.InputStreamReader |
| | | import java.time.LocalDate |
| | | import java.time.LocalDateTime |
| | | |
| | | |
| | | @RunWith(SpringRunner::class) |
| | |
| | | |
| | | @Test |
| | | fun startEvaluation() { |
| | | val time = LocalDate.of(2024, 6, 23).atStartOfDay() |
| | | val time = LocalDate.of(2024, 7, 23).atStartOfDay() |
| | | aopTaskCtrl.startEvaluation(aopTaskCtrl.getArea(time, "310106", "éå®åº", Constant.SceneType.TYPE1)) |
| | | } |
| | | |
| | | @Test |
| | | fun startAllEvaluation() { |
| | | // val time = LocalDate.of(2024, 6, 23).atStartOfDay() |
| | | val time = LocalDate.now().atStartOfDay() |
| | | aopTaskCtrl.startAllEvaluation(time) |
| | | } |
| | | |
| | | @Test |
| | | fun startNewTask(){ |
| | | val time = LocalDate.of(2024, 6, 23).atStartOfDay() |
| | | aopTaskCtrl.startNewTask(aopTaskCtrl.getArea(time, "310106", "éå®åº", Constant.SceneType.TYPE1)) |
| | |
| | | // LocationRoadNearby.BasePlace("åéè·¯-æ±åå
¬è·¯-æ±å¹³å
¬è·¯", Pair(121.136318,30.833325), Pair(121.148624,30.836094)), |
| | | // LocationRoadNearby.BasePlace("æ³æ¹¾æ¯è·¯-åéè·¯-æ±å¹³å
¬è·¯", Pair(121.155048,30.835229), Pair(121.148659,30.829861)), |
| | | |
| | | LocationRoadNearby.BasePlace("徿±ä¸å¸å¤§", Pair(121.419384,31.161433), Pair(121.419384,31.161433)), |
| | | LocationRoadNearby.BasePlace("éå®çæµç«å½æ§ç¹", Pair(121.429439, 31.223632), Pair(121.429439, 31.223632)), |
| | | LocationRoadNearby.BasePlace("é山大é2000å·", Pair(121.3404, 30.744262), Pair(121.3404, 30.744262)), |
| | | LocationRoadNearby.BasePlace("ä»éç«", Pair(121.394775, 31.203982), Pair(121.419384,31.161433)), |
| | | // LocationRoadNearby.BasePlace("徿±ä¸å¸å¤§", Pair(121.419384,31.161433), Pair(121.419384,31.161433)), |
| | | // LocationRoadNearby.BasePlace("éå®çæµç«å½æ§ç¹", Pair(121.429439, 31.223632), Pair(121.429439, 31.223632)), |
| | | // LocationRoadNearby.BasePlace("é山大é2000å·", Pair(121.3404, 30.744262), Pair(121.3404, 30.744262)), |
| | | LocationRoadNearby.BasePlace("ä»éç«", Pair(121.394775, 31.203982), Pair(121.394775, 31.203982)), |
| | | |
| | | // LocationRoadNearby.BasePlace("ç¨æ¡¥ç«", Pair(121.362928, 31.192925), Pair(121.362928, 31.192925)), |
| | | // LocationRoadNearby.BasePlace("é¿é³ç«", Pair(121.424603, 31.223644), Pair(121.424603, 31.223644)), |
| | | |
| | | |
| | | // LocationRoadNearby.BasePlace("å¤å²è·¯", Pair(121.411559, 30.791152), Pair(121.423728, 30.788246)), |
| | | // LocationRoadNearby.BasePlace("䏿¹çº¢ä¸å¿è·¯", Pair(121.141623, 30.870369), Pair(121.160251, 30.872135)), |
| | | // LocationRoadNearby.BasePlace("漾平路", Pair(121.222056, 30.852923), Pair(121.237356, 30.853606)), |
| | | // LocationRoadNearby.BasePlace("å
´å¯è·¯", Pair(121.045916, 30.831142), Pair(121.052351, 30.836051)), |
| | | // LocationRoadNearby.BasePlace("äºæ±å
¬è·¯", Pair(121.328213, 30.874901), Pair(121.335347, 30.860441)), |
| | | // LocationRoadNearby.BasePlace("å«å
«è·¯", Pair(121.286369, 30.704997), Pair(121.279021, 30.722918)), |
| | | // LocationRoadNearby.BasePlace("ç§å®è·¯", Pair(121.273549, 30.720349), Pair(121.277212, 30.726353)), |
| | | // LocationRoadNearby.BasePlace("æåº·è·¯", Pair(121.335671, 30.85661), Pair(121.342813, 30.857601)), |
| | | // LocationRoadNearby.BasePlace("æ¾æºªè·¯", Pair(121.236017, 30.894031), Pair(121.24154, 30.892297)), |
| | | // LocationRoadNearby.BasePlace("å
´æ¡è·¯", Pair(121.105814, 30.876818), Pair(121.106139, 30.868925)), |
| | | // LocationRoadNearby.BasePlace("è£ä¸°è·¯", Pair(121.236894, 30.83599), Pair(121.253117, 30.835875)), |
| | | // LocationRoadNearby.BasePlace("å¶æ°å
¬è·¯", Pair(121.164193, 30.936096), Pair(121.023036, 30.933981)), |
| | | // LocationRoadNearby.BasePlace("é³åº·è·¯", Pair(121.355063, 30.780308), Pair(121.35446, 30.774935)), |
| | | // LocationRoadNearby.BasePlace("å¼ æ§æ¯è·¯", Pair(121.321495, 30.783227), Pair(121.325356, 30.785677)), |
| | | // LocationRoadNearby.BasePlace("å建路", Pair(121.134021, 30.855966), Pair(121.141504, 30.856559)), |
| | | // LocationRoadNearby.BasePlace("åå±è·¯", Pair(121.407831, 30.801774), Pair(121.426746, 30.797785)), |
| | | // LocationRoadNearby.BasePlace("天åè·¯", Pair(121.451848, 30.776257), Pair(121.4337, 30.80644)), |
| | | // LocationRoadNearby.BasePlace("ç æ¸¯è¡", Pair(121.337652, 30.847802), Pair(121.345829, 30.846835)), |
| | | // LocationRoadNearby.BasePlace("è£ä¸è·¯", Pair(121.249271, 30.832921), Pair(121.249176, 30.835928)), |
| | | // LocationRoadNearby.BasePlace("ä¹ä¸°è·¯", Pair(121.254114, 30.903438), Pair(121.254715, 30.893363)), |
| | | ) |
| | | listOf(500.0, 1000.0, 2000.0, 3000.0).forEach { |
| | | listOf( |
| | | 500.0, |
| | | // 1000.0, |
| | | 2000.0, |
| | | 3000.0 |
| | | ).forEach { |
| | | locationRoadNearby.searchList(bList, it) |
| | | } |
| | | } |