src/main/kotlin/cn/flightfeather/supervision/business/autooutput/AopOutput.kt
@@ -8,6 +8,7 @@ import cn.flightfeather.supervision.domain.ds1.mapper.EvaluationMapper import cn.flightfeather.supervision.domain.ds1.mapper.ItemevaluationMapper import org.springframework.stereotype.Component import org.springframework.transaction.annotation.Transactional import tk.mybatis.mapper.entity.Example /** @@ -23,6 +24,7 @@ /** * å°è¯åè®°å½è¾åºè³æ°æ®åº */ @Transactional fun toDbEvaluation(evaluationScene: AopDataSource.EvaluationScene, p: Pair<Evaluation, List<Itemevaluation>>) { //å»é¤å·²æè®°å½ evaluationMapper.deleteByExample(Example(Evaluation::class.java).apply { @@ -40,6 +42,7 @@ /** * å°è¯åè®°å½æ´æ°è³æ°æ®åº */ @Transactional fun updateDbEvaluation(evaluationScene: AopDataSource.EvaluationScene, p: Pair<Evaluation, List<Itemevaluation>>) { evaluationMapper.updateByPrimaryKey(p.first) p.second.forEach { il -> itemevaluationMapper.updateByPrimaryKey(il) } src/main/kotlin/cn/flightfeather/supervision/common/utils/Constant.kt
@@ -39,6 +39,7 @@ TYPE9("9","éè·¯æ¬å°çæµç¹"), TYPE10("10","éè·¯"), TYPE11("11","æ²³æµæé¢"), TYPE12("12","å·¥ä¸ååº"), TYPE13("13","æ åºå®åºæ¯"),TYPE14("14","å åº"), TYPE15("15","ç²¾åå°åº"), TYPE99("99","å ¶ä»"); companion object { src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/DustDataResultMapper.kt
@@ -2,7 +2,11 @@ import cn.flightfeather.supervision.domain.ds1.entity.DustDataResult import cn.flightfeather.supervision.domain.util.MyMapper import cn.flightfeather.supervision.lightshare.vo.AreaVo import org.apache.ibatis.annotations.Mapper @Mapper interface DustDataResultMapper : MyMapper<DustDataResult?> interface DustDataResultMapper : MyMapper<DustDataResult?> { fun selectByArea(areaVo: AreaVo): List<DustDataResult?> } src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/MonitorDataRep.kt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,24 @@ package cn.flightfeather.supervision.domain.ds1.repository import cn.flightfeather.supervision.domain.ds1.entity.DustDataResult import cn.flightfeather.supervision.domain.ds1.mapper.DustDataResultMapper import cn.flightfeather.supervision.lightshare.vo.AreaVo import org.springframework.stereotype.Repository /** * çæµæ°æ®æ°æ®åºæ¥è¯¢ * @date 2025/3/19 * @author feiyu02 */ @Repository class MonitorDataRep( private val dataResultMapper: DustDataResultMapper, ) { /** * æ ¹æ®è¡æ¿åºåãæ¶é´ã以ååºæ¯ç±»åæ¥è¯¢ç»æ */ fun fetchDustDataResult(areaVo: AreaVo): List<DustDataResult?> { return dataResultMapper.selectByArea(areaVo) } } src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DomaincatalogService.kt
@@ -1,6 +1,8 @@ package cn.flightfeather.supervision.lightshare.service import cn.flightfeather.supervision.common.utils.Constant import cn.flightfeather.supervision.domain.ds1.entity.Domaincatalog import cn.flightfeather.supervision.lightshare.vo.AreaVo import cn.flightfeather.supervision.lightshare.vo.DomaincatalogVo @@ -16,4 +18,14 @@ fun update(domaincatalog: Domaincatalog): Int fun delete(id: String): Int /** * å¿«æ·é ç½® * é对ä¸ç§æ°çåºæ¯ç±»åï¼è¿è¡å¿«éé ç½® */ fun quickConfiguration( target: Constant.SceneType, targetArea: AreaVo, source: Constant.SceneType, sourceArea: AreaVo, ): Boolean } src/main/kotlin/cn/flightfeather/supervision/lightshare/service/MonitorDataService.kt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,16 @@ package cn.flightfeather.supervision.lightshare.service import cn.flightfeather.supervision.domain.ds1.entity.DustDataResult import cn.flightfeather.supervision.lightshare.vo.AreaVo /** * çæµæ°æ®ï¼å 嫿¬å°çæµãæ²¹ççæµççææçæµæ°æ®ï¼æå¡ * @date 2025/3/19 * @author feiyu02 */ interface MonitorDataService { fun uploadDustDataResult(dataList: List<DustDataResult>): Boolean fun fetchDustDataResult(areaVo: AreaVo): List<DustDataResult?> } src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ProblemtypeService.kt
@@ -1,5 +1,6 @@ package cn.flightfeather.supervision.lightshare.service import cn.flightfeather.supervision.common.utils.Constant import cn.flightfeather.supervision.domain.ds1.entity.Problemtype import cn.flightfeather.supervision.lightshare.vo.ProblemDetailVo import cn.flightfeather.supervision.lightshare.vo.ProblemtypeVo src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DomaincatalogServiceImpl.kt
@@ -1,14 +1,26 @@ package cn.flightfeather.supervision.lightshare.service.impl import cn.flightfeather.supervision.domain.ds1.entity.Domaincatalog import cn.flightfeather.supervision.domain.ds1.mapper.DomaincatalogMapper import cn.flightfeather.supervision.common.utils.Constant import cn.flightfeather.supervision.common.utils.UUIDGenerator import cn.flightfeather.supervision.domain.ds1.entity.* import cn.flightfeather.supervision.domain.ds1.mapper.* import cn.flightfeather.supervision.lightshare.service.DomaincatalogService import cn.flightfeather.supervision.lightshare.vo.AreaVo import cn.flightfeather.supervision.lightshare.vo.DomaincatalogVo import org.springframework.beans.BeanUtils import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import tk.mybatis.mapper.entity.Example import java.util.* @Service class DomaincatalogServiceImpl(val domaincatalogMapper: DomaincatalogMapper) : DomaincatalogService { class DomaincatalogServiceImpl( private val domaincatalogMapper: DomaincatalogMapper, private val problemtypeMapper: ProblemtypeMapper, private val changeAdviceMapper: ChangeAdviceMapper, private val evaluationruleMapper: EvaluationruleMapper, private val evaluationsubruleMapper: EvaluationsubruleMapper, ) : DomaincatalogService { //æ ¹æ®nameæ¥è¯¢ override fun findOneByName(name: String): Domaincatalog? { val domaincatalog = Domaincatalog() @@ -35,4 +47,66 @@ override fun update(domaincatalog: Domaincatalog): Int = domaincatalogMapper.updateByPrimaryKey(domaincatalog) override fun delete(id: String): Int = domaincatalogMapper.deleteByPrimaryKey(id) @Transactional override fun quickConfiguration( target: Constant.SceneType, targetArea: AreaVo, source: Constant.SceneType, sourceArea: AreaVo, ): Boolean { //1. é®é¢ç±»ååæ´æ¹å»ºè®® val adviceList = changeAdviceMapper.selectByExample(Example(ChangeAdvice::class.java).apply { createCriteria().andEqualTo("adExtension1", sourceArea.districtname) .andEqualTo("adExtension2", source.text) }) problemtypeMapper.selectByExample(Example(Problemtype::class.java).apply { createCriteria().andEqualTo("scensetypeid", source.value.toByte()) .andEqualTo("districtname", sourceArea.districtname) }).forEach { val newProblemGuid = UUIDGenerator.generate16ShortUUID() adviceList.find { ad -> ad.adProblemtypeguid == it.guid }?.let { ad -> ad.adGuid = UUIDGenerator.generate16ShortUUID() ad.adProblemtypeguid = newProblemGuid ad.adCreatedate = Date() ad.adUpdatedate = Date() ad.adExtension1 = targetArea.districtname ad.adExtension2 = target.text changeAdviceMapper.insert(ad) } it.guid = newProblemGuid it.scensetypeid = target.value.toByte() it.scensetype = target.text it.createdate = Date() it.updatedate = Date() it.provincecode = targetArea.provincecode it.provincename = targetArea.provincename it.citycode = targetArea.citycode it.cityname = targetArea.cityname it.districtcode = targetArea.districtcode it.districtname = targetArea.districtname problemtypeMapper.insert(it) } return true //2. é®é¢ä½ç½®ï¼é»è®¤å·¥å°ï¼å¯ä¸ä¿®æ¹ï¼ //3. èªè¯è§å表 // evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply { // createCriteria().andEqualTo("tasktypeid", 99) // .andEqualTo("scensetypeid", source.value) // and(createCriteria().orEqualTo("provincecode", sourceArea.provincecode).orIsNull("provincecode")) // and(createCriteria().orEqualTo("citycode", sourceArea.citycode).orIsNull("citycode")) // and(createCriteria().orEqualTo("districtcode", sourceArea.districtcode).orIsNull("districtcode")) // and(createCriteria().orEqualTo("towncode", sourceArea.towncode).orIsNull("towncode")) // }).takeIf { it.isNotEmpty() }?.get(0).let {sourceRule -> // if (sourceRule != null) { // evaluationsubruleMapper.selectByExample(Example(Evaluationsubrule::class.java).apply { // createCriteria().andEqualTo("", sourceRule) // }) // } // } } } src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/MonitorDataServiceImpl.kt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,31 @@ package cn.flightfeather.supervision.lightshare.service.impl import cn.flightfeather.supervision.business.autooutput.AopOutput import cn.flightfeather.supervision.domain.ds1.entity.DustDataResult import cn.flightfeather.supervision.domain.ds1.repository.MonitorDataRep import cn.flightfeather.supervision.lightshare.service.MonitorDataService import cn.flightfeather.supervision.lightshare.vo.AreaVo import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional /** * * @date 2025/3/19 * @author feiyu02 */ @Service class MonitorDataServiceImpl( private val aopOutput: AopOutput, private val monitorDataRep: MonitorDataRep, ) : MonitorDataService { @Transactional override fun uploadDustDataResult(dataList: List<DustDataResult>): Boolean { dataList.forEach { aopOutput.toDbDataResult(it) } return true } override fun fetchDustDataResult(areaVo: AreaVo): List<DustDataResult?> { return monitorDataRep.fetchDustDataResult(areaVo) } } src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemtypeServiceImpl.kt
@@ -1,5 +1,7 @@ package cn.flightfeather.supervision.lightshare.service.impl import cn.flightfeather.supervision.common.utils.Constant import cn.flightfeather.supervision.common.utils.UUIDGenerator import cn.flightfeather.supervision.domain.ds1.entity.Problemtype import cn.flightfeather.supervision.domain.ds1.mapper.ProblemtypeMapper import cn.flightfeather.supervision.lightshare.service.ProblemtypeService @@ -7,8 +9,10 @@ import cn.flightfeather.supervision.lightshare.vo.ProblemtypeVo import org.springframework.beans.BeanUtils import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import tk.mybatis.mapper.entity.Example import tk.mybatis.mapper.util.StringUtil import java.util.* @Service class ProblemtypeServiceImpl(val problemtypeMapper: ProblemtypeMapper) : ProblemtypeService { src/main/kotlin/cn/flightfeather/supervision/lightshare/web/BaseResPack.kt
@@ -22,5 +22,9 @@ } } catch (e: BizException) { BaseResponse(false, message = e.message ?: "") } catch (e: Exception) { // fixme: to log system BaseResponse(false, message = "æå¡å¨åºç°å é¨é误") } } src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MonitorDataController.kt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,33 @@ package cn.flightfeather.supervision.lightshare.web import cn.flightfeather.supervision.domain.ds1.entity.DustDataResult import cn.flightfeather.supervision.lightshare.service.MonitorDataService import cn.flightfeather.supervision.lightshare.vo.AreaVo import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* import org.springframework.web.multipart.MultipartFile /** * çæµæ°æ®ï¼å 嫿¬å°çæµãæ²¹ççæµççææçæµæ°æ®ï¼ç¸å ³APIæ¥å£ * @date 2025/3/19 * @author feiyu02 */ @Api(tags = ["MonitorDataController"], description = "çæµæ°æ®ï¼å 嫿¬å°çæµãæ²¹ççæµççææçæµæ°æ®ï¼ç¸å ³APIæ¥å£") @RestController @RequestMapping("/monitor/data") class MonitorDataController(private val monitorDataService: MonitorDataService) { @ApiOperation(value = "ä¸ä¼ æ¬å°çæµæ°æ®çæåº¦ç»è®¡ç»æ") @PutMapping("/result/construction/upload") fun uploadDustDataResult( @ApiParam("ç»è®¡ç»æ") @RequestBody dataList: List<DustDataResult>, ) = resPack { monitorDataService.uploadDustDataResult(dataList) } @ApiOperation(value = "æ¥è¯¢æ¬å°çæµæ°æ®çæåº¦ç»è®¡ç»æ") @PostMapping("/result/construction/get") fun fetchDustDataResult( @ApiParam("åºåæ¡ä»¶ä¿¡æ¯") @RequestBody areaVo: AreaVo ) = resPack { monitorDataService.fetchDustDataResult(areaVo) } } src/main/resources/mapper/ds1/DustDataResultMapper.xml
@@ -25,4 +25,33 @@ DR_Id, DR_Scene_Id, DR_Scene_Name, DR_Device_Code, DR_Time, DR_Exceed_Times, DR_Avg, DR_Max, DR_Min, DR_Over_Avg_Per, DR_Data_Num, DR_Effective_Rate </sql> <!-- æ°æ®ç»è®¡ç»ææ¶é´æ¡ä»¶ --> <sql id="Where_Plan_Time"> <if test="starttime != null"> AND ${tableAlias}.DR_Time >= #{starttime} </if> <if test="endtime != null"> AND ${tableAlias}.DR_Time <= #{endtime} </if> </sql> <select id="selectByArea" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from ea_t_dust_data_result as a left join sm_t_scense as b on a.DR_Scene_Id = b.S_GUID <where> <include refid="cn.flightfeather.supervision.domain.ds1.mapper.ScenseMapper.Where_Area"> <property name="tableAlias" value="b"/> </include> <include refid="cn.flightfeather.supervision.domain.ds1.mapper.ScenseMapper.Where_Type"> <property name="tableAlias" value="b"/> </include> <include refid="Where_Plan_Time"> <property name="tableAlias" value="a"/> </include> </where> </select> </mapper> src/main/resources/mapper/ds1/ScenseMapper.xml
@@ -70,6 +70,13 @@ </if> </sql> <!-- åºæ¯ç±»åæ¡ä»¶ --> <sql id="Where_Type"> <if test="scensetypeid != null"> AND ${tableAlias}.S_TypeID = #{scensetypeid} </if> </sql> <select id="selectNoAccountScene" resultMap="BaseResultMap"> select a.* FROM sm_t_scense as a LEFT JOIN sm_t_userinfo as b on a.S_GUID = b.D_GUID WHERE b.UI_GUID is null </select> src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DomaincatalogServiceImplTest.kt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,41 @@ package cn.flightfeather.supervision.lightshare.service.impl import cn.flightfeather.supervision.SupervisionApplication import cn.flightfeather.supervision.common.utils.Constant import cn.flightfeather.supervision.lightshare.service.DomaincatalogService import cn.flightfeather.supervision.lightshare.vo.AreaVo import org.junit.Test import org.junit.runner.RunWith import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.context.junit4.SpringJUnit4ClassRunner @RunWith(SpringJUnit4ClassRunner::class) @SpringBootTest(classes = [SupervisionApplication::class]) class DomaincatalogServiceImplTest { @Autowired lateinit var domaincatalogService: DomaincatalogService @Test fun quickConfiguration() { domaincatalogService.quickConfiguration( Constant.SceneType.TYPE15, AreaVo().apply { provincecode = "31" provincename = "䏿µ·å¸" citycode = "3100" cityname = "䏿µ·å¸" districtcode = "310105" districtname = "é¿å®åº" }, Constant.SceneType.TYPE1, AreaVo().apply { provincecode = "31" provincename = "䏿µ·å¸" citycode = "3100" cityname = "䏿µ·å¸" districtcode = "310105" districtname = "é¿å®åº" } ) } }