| | |
| | | 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.exception.BizException |
| | | 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() |
| | |
| | | //获取全部 |
| | | override fun findAll(): MutableList<DomaincatalogVo> { |
| | | val domaincatalogVoList = mutableListOf<DomaincatalogVo>() |
| | | val domaincatalogList = domaincatalogMapper.selectAll() |
| | | val domaincatalogList = domaincatalogMapper.selectByExample(Example(Domaincatalog::class.java).apply { |
| | | orderBy("name") |
| | | }) |
| | | domaincatalogList.forEach { |
| | | val domaincatalogVo = DomaincatalogVo() |
| | | BeanUtils.copyProperties(it,domaincatalogVo) |
| | |
| | | return domaincatalogVoList |
| | | } |
| | | |
| | | override fun save(domaincatalog: Domaincatalog): Int = domaincatalogMapper.insert(domaincatalog) |
| | | override fun save(domaincatalog: Domaincatalog): Domaincatalog{ |
| | | if (domaincatalog.guid == null) { |
| | | domaincatalog.guid = UUIDGenerator.generate16ShortUUID() |
| | | } |
| | | if (domaincatalogMapper.insert(domaincatalog) == 1) { |
| | | return domaincatalog |
| | | } else { |
| | | throw BizException("值域项新增失败") |
| | | } |
| | | } |
| | | |
| | | override fun update(domaincatalog: Domaincatalog): Int = domaincatalogMapper.updateByPrimaryKey(domaincatalog) |
| | | override fun update(domaincatalog: Domaincatalog): Domaincatalog{ |
| | | // 2025.11.11 新增版本号对比逻辑,若更新的配置信息版本号等于数据历史版本号,才能更新 |
| | | val oldOne = domaincatalogMapper.selectByPrimaryKey(domaincatalog.guid) |
| | | if ((domaincatalog.version == oldOne.version)) { |
| | | // 更新时,版本号递增 |
| | | domaincatalog.version = (domaincatalog.version ?: 0) + 1 |
| | | domaincatalogMapper.updateByPrimaryKey(domaincatalog) |
| | | |
| | | return domaincatalog |
| | | } else { |
| | | throw BizException("版本号不一致,更新失败") |
| | | } |
| | | } |
| | | |
| | | 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) |
| | | // }) |
| | | // } |
| | | // } |
| | | } |
| | | } |