¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.lightshare.service |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.AlarmDataVo |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/5 |
| | | */ |
| | | interface ObdAlarmService { |
| | | |
| | | /** |
| | | * æ ¹æ®vinç è·åè¦æ¥æ°æ® |
| | | */ |
| | | fun getAlarmByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<AlarmDataVo> |
| | | |
| | | } |
| | |
| | | */ |
| | | interface ObdDataService { |
| | | |
| | | /** |
| | | * æ ¹æ®vinç è·åå¯¹åºæ°æ® |
| | | */ |
| | | fun getDataByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<ObdDataVo> |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.lightshare.service |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.ThresholdValueVo |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/5 |
| | | */ |
| | | interface ObdThresholdValueService { |
| | | |
| | | /** |
| | | * ä¿å |
| | | */ |
| | | fun save(thresholdValueVo: ThresholdValueVo): Boolean |
| | | |
| | | /** |
| | | * æ´æ° |
| | | */ |
| | | fun update(thresholdValueVo: ThresholdValueVo): Boolean |
| | | |
| | | /** |
| | | * æ ¹æ®vinç è·å对åºéå¼ |
| | | */ |
| | | fun getDataByVinCode(vinCode: String): ThresholdValueVo? |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.lightshare.service.impl |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.AlarmDataVo |
| | | import com.flightfeather.obd.lightshare.service.ObdAlarmService |
| | | import com.flightfeather.obd.repository.ObdAlarmRepository |
| | | import org.springframework.stereotype.Service |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/5 |
| | | */ |
| | | @Service |
| | | class ObdAlarmServiceImpl(val obdAlarmRepository: ObdAlarmRepository) : ObdAlarmService { |
| | | |
| | | override fun getAlarmByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<AlarmDataVo> { |
| | | return obdAlarmRepository.getAlarmByVinCode(vinCode, pageNum, pageSize) |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.lightshare.service.impl |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.ThresholdValueVo |
| | | import com.flightfeather.obd.lightshare.service.ObdThresholdValueService |
| | | import com.flightfeather.obd.repository.ObdThresholdValueRepository |
| | | import org.springframework.stereotype.Service |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/5 |
| | | */ |
| | | @Service |
| | | class ObdThresholdValueServiceImpl(val obdThresholdValueRepository: ObdThresholdValueRepository) : ObdThresholdValueService { |
| | | |
| | | override fun save(thresholdValueVo: ThresholdValueVo): Boolean { |
| | | return obdThresholdValueRepository.save(thresholdValueVo) |
| | | } |
| | | |
| | | override fun update(thresholdValueVo: ThresholdValueVo): Boolean { |
| | | return obdThresholdValueRepository.update(thresholdValueVo) |
| | | } |
| | | |
| | | override fun getDataByVinCode(vinCode: String): ThresholdValueVo? { |
| | | return obdThresholdValueRepository.getByVinCode(vinCode) |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.lightshare.web |
| | | |
| | | import com.flightfeather.obd.lightshare.service.ObdAlarmService |
| | | import org.springframework.web.bind.annotation.* |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/5 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("obd/alarm") |
| | | class ObdAlarmController(val obdAlarmService: ObdAlarmService) { |
| | | |
| | | @GetMapping("/{id}") |
| | | fun getAlarmByVinCode( |
| | | @PathVariable("id") id: String, |
| | | @RequestParam("page", required = false) pageNum: Int?, |
| | | @RequestParam("per_page", required = false) pageSize: Int? |
| | | ) = obdAlarmService.getAlarmByVinCode(id, pageNum, pageSize) |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.lightshare.web |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.ThresholdValueVo |
| | | import com.flightfeather.obd.lightshare.service.ObdThresholdValueService |
| | | import org.springframework.web.bind.annotation.* |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/5 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("obd/threshold") |
| | | class ObdThresholdController(val obdThresholdValueService: ObdThresholdValueService) { |
| | | |
| | | @GetMapping("/{id}") |
| | | fun getDataByVinCode( |
| | | @PathVariable("id") id: String |
| | | ) = obdThresholdValueService.getDataByVinCode(id) |
| | | |
| | | @PostMapping("/update") |
| | | fun update( |
| | | @RequestBody thresholdValueVo: ThresholdValueVo |
| | | ) = obdThresholdValueService.update(thresholdValueVo) |
| | | |
| | | @PutMapping("/save") |
| | | fun save( |
| | | @RequestBody thresholdValueVo: ThresholdValueVo |
| | | ) = obdThresholdValueService.save(thresholdValueVo) |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.repository |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.AlarmDataVo |
| | | |
| | | /** |
| | | * obdè¦æ¥ç¸å
³æ°æ®åºæä½æ¥å£ |
| | | * @author riku |
| | | * Date: 2019/9/5 |
| | | */ |
| | | interface ObdAlarmRepository { |
| | | |
| | | /** |
| | | * åå¨è¦æ¥æ°æ® |
| | | */ |
| | | fun saveObdAlarm(alarmDataVo: AlarmDataVo): Boolean |
| | | |
| | | /** |
| | | * éè¿æ±½è½¦vinç è·åè¦æ¥æ°æ® |
| | | */ |
| | | fun getAlarmByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<AlarmDataVo> |
| | | |
| | | } |
| | |
| | | /** |
| | | * åå¨obdæ°æ® |
| | | */ |
| | | fun saveObdData(data:ObdDataVo) |
| | | fun saveObdData(data: ObdDataVo): Boolean |
| | | |
| | | /** |
| | | * éè¿æ±½è½¦vinç è·åææ°æ°æ® |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.repository |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.ThresholdValueVo |
| | | |
| | | /** |
| | | * obdè¦æ¥éå¼ç¸å
³æ°æ®åºæä½æ¥å£ |
| | | * @author riku |
| | | * Date: 2019/9/5 |
| | | */ |
| | | interface ObdThresholdValueRepository { |
| | | |
| | | /** |
| | | * åå¨éå¼ |
| | | */ |
| | | fun save(thresholdValueVo: ThresholdValueVo): Boolean |
| | | |
| | | /** |
| | | * æ´æ°éå¼ |
| | | */ |
| | | fun update(thresholdValueVo: ThresholdValueVo): Boolean |
| | | |
| | | /** |
| | | * éè¿æ±½è½¦vinç è·åé弿°æ® |
| | | */ |
| | | fun getByVinCode(vinCode: String): ThresholdValueVo? |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.repository.impl |
| | | |
| | | import com.flightfeather.obd.domain.entity.AlarmData |
| | | import com.flightfeather.obd.domain.mapper.AlarmDataMapper |
| | | import com.flightfeather.obd.lightshare.bean.AlarmDataVo |
| | | import com.flightfeather.obd.repository.ObdAlarmRepository |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.beans.BeanUtils |
| | | import org.springframework.stereotype.Repository |
| | | import tk.mybatis.mapper.entity.Example |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/5 |
| | | */ |
| | | @Repository |
| | | class ObdAlarmDaoImpl(val alarmDataMapper: AlarmDataMapper) : ObdAlarmRepository { |
| | | |
| | | override fun saveObdAlarm(alarmDataVo: AlarmDataVo): Boolean { |
| | | val alarmData = AlarmData() |
| | | BeanUtils.copyProperties(alarmDataVo, alarmData) |
| | | return alarmDataMapper.insert(alarmData) == 1 |
| | | } |
| | | |
| | | override fun getAlarmByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<AlarmDataVo> { |
| | | val example = Example(AlarmData::class.java).apply { |
| | | createCriteria().andEqualTo("obdVin", vinCode) |
| | | orderBy("obdTime").desc() |
| | | } |
| | | |
| | | //å页 |
| | | val offset = (pageSize?.times(pageNum?.minus(1) ?: 0)) ?: 0 |
| | | PageHelper.offsetPage<AlarmData>(offset, pageSize ?: 10) |
| | | val result = alarmDataMapper.selectByExample(example) |
| | | |
| | | val resultList = mutableListOf<AlarmDataVo>() |
| | | result.forEach { |
| | | val vo = AlarmDataVo() |
| | | BeanUtils.copyProperties(it, vo) |
| | | resultList.add(vo) |
| | | } |
| | | |
| | | return resultList |
| | | } |
| | | |
| | | } |
| | |
| | | @Repository |
| | | class ObdDataDaoImpl(val obdDataMapper: ObdDataMapper) : ObdDataRepository { |
| | | |
| | | override fun saveObdData(data: ObdDataVo) { |
| | | override fun saveObdData(data: ObdDataVo): Boolean { |
| | | val obdData = ObdData() |
| | | BeanUtils.copyProperties(data, obdData) |
| | | obdDataMapper.insert(obdData) |
| | | return obdDataMapper.insert(obdData) == 1 |
| | | } |
| | | |
| | | override fun getDataByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<ObdDataVo> { |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.repository.impl |
| | | |
| | | import com.flightfeather.obd.domain.entity.ThresholdValue |
| | | import com.flightfeather.obd.domain.mapper.ThresholdValueMapper |
| | | import com.flightfeather.obd.lightshare.bean.ThresholdValueVo |
| | | import com.flightfeather.obd.repository.ObdThresholdValueRepository |
| | | import org.springframework.beans.BeanUtils |
| | | import org.springframework.stereotype.Repository |
| | | import tk.mybatis.mapper.entity.Example |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/5 |
| | | */ |
| | | @Repository |
| | | class ObdThresholdValueDaoImpl(val obdThresholdValueMapper: ThresholdValueMapper) : ObdThresholdValueRepository { |
| | | |
| | | override fun save(thresholdValueVo: ThresholdValueVo): Boolean { |
| | | val thresholdValue = ThresholdValue() |
| | | BeanUtils.copyProperties(thresholdValueVo, thresholdValue) |
| | | return obdThresholdValueMapper.insert(thresholdValue) == 1 |
| | | } |
| | | |
| | | override fun update(thresholdValueVo: ThresholdValueVo): Boolean { |
| | | val thresholdValue = ThresholdValue() |
| | | BeanUtils.copyProperties(thresholdValueVo, thresholdValue) |
| | | return obdThresholdValueMapper.updateByPrimaryKey(thresholdValue) == 1 |
| | | } |
| | | |
| | | override fun getByVinCode(vinCode: String): ThresholdValueVo? { |
| | | val example = Example(ThresholdValue::class.java).apply { |
| | | createCriteria().andEqualTo("obdVin", vinCode) |
| | | } |
| | | |
| | | val result = obdThresholdValueMapper.selectByExample(example) |
| | | |
| | | if (result.isNotEmpty()) { |
| | | val vo = ThresholdValueVo() |
| | | BeanUtils.copyProperties(vo, result[0]) |
| | | return vo |
| | | } |
| | | |
| | | return null |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | } |
| | | } catch (e: Throwable) { |
| | | e.printStackTrace() |
| | | println("------æ¶å°æ ¼å¼éè¯¯çæ°æ®ï¼$msg") |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | override fun channelRead(ctx: ChannelHandlerContext?, msg: Any?) { |
| | | super.channelRead(ctx, msg) |
| | | println("------æ¶å°çåå§æ°æ®ï¼$msg") |
| | | if (msg is String) { |
| | | MessageManager().dealMsg(msg, ctx) |
| | | } |
| | |
| | | spring: |
| | | datasource: |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://47.100.191.150:3306/obd?serverTimezone=GMT&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false |
| | | url: jdbc:mysql://47.100.191.150:3306/obd?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false |
| | | username: obd |
| | | password: obd2019 |
| | | |