| | |
| | | import org.springframework.beans.factory.annotation.Autowired |
| | | import org.springframework.stereotype.Component |
| | | import tk.mybatis.mapper.entity.Example |
| | | import java.time.Duration |
| | | import java.time.LocalDateTime |
| | | import java.time.ZoneId |
| | | import javax.annotation.PostConstruct |
| | |
| | | val rowData = RowData() |
| | | |
| | | init { |
| | | if (config.districtCode == null) { |
| | | throw IllegalStateException("参数缺少区县编码:[districtCode]") |
| | | } |
| | | if (config.sceneType == null) { |
| | | throw IllegalStateException("参数缺少场景类型:[sceneType]") |
| | | } |
| | | // if (config.districtCode == null) { |
| | | // throw IllegalStateException("参数缺少区县编码:[districtCode]") |
| | | // } |
| | | // if (config.sceneType == null) { |
| | | // throw IllegalStateException("参数缺少场景类型:[sceneType]") |
| | | // } |
| | | getSource(config) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取报告数据源 |
| | | * 获取报告数据源(巡查任务) |
| | | */ |
| | | private fun getSource(config: ExcelConfigVo) { |
| | | if (config.sceneType == null) return |
| | | // if (config.sceneType == null) return |
| | | |
| | | val result = mutableListOf<Subtask>() |
| | | |
| | |
| | | } |
| | | config.startTime?.let { andGreaterThanOrEqualTo("planstarttime", it) } |
| | | config.endTime?.let { andLessThanOrEqualTo("planendtime", it) } |
| | | config.districtCode?.let { andEqualTo("districtcode", it) } |
| | | // andEqualTo("tguid", config.topTaskGuid) |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | var index = 0 |
| | | |
| | | var subTask: Subtask? = null |
| | | |
| | | private var lastScene: Scense? = null |
| | | |
| | | //场景基本信息 |
| | | val scene: Scense? |
| | |
| | | } |
| | | private var _problems = mutableListOf<Problemlist>() |
| | | |
| | | //评估总分 |
| | | val evaluation: Evaluation? |
| | | get() { |
| | | if (_evaluation == null) { |
| | |
| | | } |
| | | private var _evaluation: Evaluation? = null |
| | | |
| | | //评估细则得分 |
| | | val itemevaluationList: MutableList<Itemevaluation> |
| | | get() { |
| | | if (_itemevaluationList.isEmpty()) { |
| | |
| | | get() { |
| | | if (_problemTypes.isEmpty()) { |
| | | val r = dbMapper.problemtypeMapper.selectByExample(Example(Problemtype::class.java).apply { |
| | | createCriteria().andEqualTo("scensetypeid", config.sceneType) |
| | | .andEqualTo("districtcode", config.districtCode) |
| | | createCriteria().andEqualTo("scensetypeid", scene?.typeid) |
| | | .andEqualTo("districtcode", scene?.districtcode) |
| | | orderBy("extension1") |
| | | }) |
| | | _problemTypes.addAll(r) |
| | |
| | | val rule = dbMapper.evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply { |
| | | createCriteria() |
| | | .andEqualTo("tasktypeid", 99) |
| | | .andEqualTo("scensetypeid", config.sceneType) |
| | | .andEqualTo("scensetypeid", scene?.typeid) |
| | | }) |
| | | if (rule.isNotEmpty()) { |
| | | val ruleId = rule[0].guid |
| | |
| | | val ledgerCount: Int |
| | | get() { |
| | | if (_ledgerCount == -1) { |
| | | val tzSceneType = Constant.ScenseType.typeMap(config.sceneType?.toByte()) |
| | | val tzSceneType = Constant.ScenseType.typeMap(scene?.typeid) |
| | | _ledgerCount = dbMapper.ledgerSubTypeMapper.selectCountByExample(Example(LedgerSubType::class.java).apply { |
| | | createCriteria().andEqualTo("lScenetype", tzSceneType).andEqualTo("lNeedupdate", true) |
| | | }) |
| | |
| | | private var _ledgerRecordNum: List<LedgerRecord>? = null |
| | | |
| | | /** |
| | | * 获取当前巡查任务的上期巡查记录 |
| | | */ |
| | | fun lastOne(): RowData { |
| | | val last = RowData() |
| | | val r = dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { |
| | | createCriteria().andEqualTo("scenseid", subTask?.scenseid) |
| | | .andLessThan("planstarttime", subTask?.planstarttime) |
| | | orderBy("planstarttime").desc() |
| | | }) |
| | | if (r.isNotEmpty()) { |
| | | val thisMonth = LocalDateTime.ofInstant(subTask?.planstarttime?.toInstant(), ZoneId.systemDefault()).withDayOfMonth(1).toLocalDate() |
| | | val lastMonth = LocalDateTime.ofInstant(r[0]?.planstarttime?.toInstant(), ZoneId.systemDefault()).withDayOfMonth(1).toLocalDate() |
| | | if (lastMonth.plusMonths(1).isEqual(thisMonth)) { |
| | | last.subTask = r[0] |
| | | } |
| | | } |
| | | return last |
| | | } |
| | | |
| | | /** |
| | | * 清空当前处理的对象的相关数据源 |
| | | */ |
| | | fun clear() { |
| | | if (lastScene != null && lastScene?.typeid != _scene?.typeid) { |
| | | _problemTypes.clear() |
| | | _topItems.clear() |
| | | _rules.clear() |
| | | _ledgerCount = -1 |
| | | } else { |
| | | lastScene = _scene |
| | | } |
| | | _scene = null |
| | | _baseScene = null |
| | | _problems.clear() |