| | |
| | | */ |
| | | class DataSource(val config: ExcelConfigVo, val dbMapper: DbMapper){ |
| | | |
| | | private val dateUtil = DateUtil() |
| | | |
| | | private val sourceList = mutableListOf<Subtask>() |
| | | |
| | | var year = 0 |
| | |
| | | */ |
| | | fun reset() { |
| | | rowData.index = 0 |
| | | rowData.subTask = sourceList.first() |
| | | rowData.subTask = if (sourceList.isEmpty()) null else sourceList.first() |
| | | rowData.clear() |
| | | } |
| | | |
| | |
| | | */ |
| | | fun areaName(): String { |
| | | val t = dbMapper.taskMapper.selectByPrimaryKey(config.topTaskGuid) |
| | | return "${dateUtil.DateToString(t.starttime, DateUtil.DateStyle.YYYY_MM_CN)}${t.districtname}${if (area != t.districtname) area else ""}${Constant.SceneType.getDes(config.sceneType)}" |
| | | return "${DateUtil.DateToString(t.starttime, DateUtil.DateStyle.YYYY_MM_CN)}${t.districtname}${if (area != t.districtname) area else ""}${Constant.SceneType.getDes(config.sceneType)}" |
| | | } |
| | | |
| | | /** |
| | |
| | | })?.takeIf { it.isNotEmpty() }?.get(0)?.let { area = it.townname ?: "" } |
| | | } |
| | | |
| | | dbMapper.taskMapper.selectByPrimaryKey(config.topTaskGuid).let { |
| | | dbMapper.taskMapper.selectByPrimaryKey(config.topTaskGuid)?.let { |
| | | val time = LocalDateTime.ofInstant(it.starttime?.toInstant(), ZoneId.systemDefault()) |
| | | this.year = time.year |
| | | this.month = time.monthValue |
| | |
| | | } |
| | | |
| | | //1. 查找特定的巡查任务或者所有的计划巡查任务 |
| | | var taskSceneIdList = listOf<String>() |
| | | val subTaskList = if (config.subTaskIdList?.isNotEmpty() == true || |
| | | (config.startTime != null || config.endTime != null) |
| | | ) { |
| | | dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { |
| | | createCriteria().apply { |
| | | if (config.subTaskIdList?.isNotEmpty() == true) { |
| | | andIn("stguid", config.subTaskIdList) |
| | | } |
| | | config.startTime?.let { andGreaterThanOrEqualTo("planstarttime", it) } |
| | | config.endTime?.let { andLessThanOrEqualTo("planendtime", it) } |
| | | config.districtCode?.let { andEqualTo("districtcode", it) } |
| | | // andEqualTo("tguid", config.topTaskGuid) |
| | | } |
| | | }) |
| | | } else { |
| | | taskSceneIdList = dbMapper.scenseMapper.getSceneByType(config.topTaskGuid, config |
| | | .sceneType, config.townCode).map { it.guid ?: "" } |
| | | dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { |
| | | createCriteria().andIn("scenseid", taskSceneIdList) |
| | | .andEqualTo("tguid", config.topTaskGuid) |
| | | }) |
| | | } |
| | | val taskSceneIdList = dbMapper.scenseMapper.getSceneByType(config.topTaskGuid, config.sceneType, |
| | | config.townCode).map { it.guid ?: "" } |
| | | |
| | | if (taskSceneIdList.isNotEmpty()) { |
| | | taskSceneIdList.forEach { |
| | | var subtask: Subtask? = null |
| | | for (s in subTaskList) { |
| | | if (s.scenseid == it) { |
| | | subtask = s |
| | | result.add(s) |
| | | // 统计总任务下所有场景 |
| | | if (config.allScene) { |
| | | val subTaskList = dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { |
| | | createCriteria().apply { |
| | | if (taskSceneIdList.isNotEmpty()) andIn("scenseid", taskSceneIdList) |
| | | }.andEqualTo("tguid", config.topTaskGuid) |
| | | }) |
| | | // 给还未巡查的场景生成空的子任务对象 |
| | | if (taskSceneIdList.isNotEmpty()) { |
| | | taskSceneIdList.forEach { |
| | | var subtask: Subtask? = null |
| | | for (s in subTaskList) { |
| | | if (s.scenseid == it) { |
| | | subtask = s |
| | | result.add(s) |
| | | } |
| | | } |
| | | if (subtask == null) { |
| | | result.add(Subtask().apply { scenseid = it }) |
| | | } |
| | | } |
| | | if (subtask == null) { |
| | | result.add(Subtask().apply { scenseid = it }) |
| | | } |
| | | } else { |
| | | result.addAll(subTaskList) |
| | | } |
| | | } else { |
| | | } |
| | | else { |
| | | val subTaskList = dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { |
| | | createCriteria().apply { |
| | | if (config.subTaskIdList?.isNotEmpty() == true) andIn("stguid", config.subTaskIdList) |
| | | config.startTime?.let { andGreaterThanOrEqualTo("planstarttime", it) } |
| | | config.endTime?.let { andLessThanOrEqualTo("planendtime", it) } |
| | | config.districtCode?.let { andEqualTo("districtcode", it) } |
| | | andEqualTo("tguid", config.topTaskGuid) |
| | | } |
| | | }) |
| | | result.addAll(subTaskList) |
| | | } |
| | | |
| | |
| | | private var _baseScene: BaseScene? = null |
| | | |
| | | //具体的问题 |
| | | val problems: MutableList<Problemlist> |
| | | val problems: List<Problemlist> |
| | | get() { |
| | | if (noRecord()) return mutableListOf() |
| | | |
| | | if (_problems.isEmpty()) { |
| | | if (_problems == null) { |
| | | val r = dbMapper.problemlistMapper.selectByExample(Example(Problemlist::class.java).apply { |
| | | createCriteria().andEqualTo("stguid", subTask?.stguid) |
| | | }) |
| | | _problems.addAll(r) |
| | | _problems = r |
| | | } |
| | | return _problems |
| | | return _problems ?: emptyList() |
| | | } |
| | | private var _problems = mutableListOf<Problemlist>() |
| | | private var _problems: List<Problemlist>? = null |
| | | |
| | | //评估总分 |
| | | val evaluation: Evaluation? |
| | |
| | | private var _evaluation: Evaluation? = null |
| | | |
| | | //评估细则得分 |
| | | val itemevaluationList: MutableList<Itemevaluation> |
| | | val itemevaluationList: List<Itemevaluation> |
| | | get() { |
| | | if (_itemevaluationList.isEmpty()) { |
| | | if (_itemevaluationList == null) { |
| | | val r = dbMapper.itemevaluationMapper.selectByExample(Example(Itemevaluation::class.java).apply { |
| | | createCriteria().andEqualTo("stguid", subTask?.stguid) |
| | | }) |
| | | _itemevaluationList.addAll(r) |
| | | _itemevaluationList = r |
| | | println("-------------------itemevaluationList--------------------------------") |
| | | } |
| | | return _itemevaluationList |
| | | return _itemevaluationList ?: emptyList() |
| | | } |
| | | private var _itemevaluationList = mutableListOf<Itemevaluation>() |
| | | private var _itemevaluationList: List<Itemevaluation>? = null |
| | | |
| | | //问题类型 |
| | | val problemTypes: MutableList<Problemtype> |
| | | val problemTypes: List<Problemtype> |
| | | get() { |
| | | if (_problemTypes.isEmpty()) { |
| | | if (_problemTypes == null) { |
| | | val r = dbMapper.problemtypeMapper.selectByExample(Example(Problemtype::class.java).apply { |
| | | createCriteria().andEqualTo("scensetypeid", scene?.typeid) |
| | | .andEqualTo("districtcode", scene?.districtcode) |
| | | orderBy("extension1") |
| | | }) |
| | | _problemTypes.addAll(r) |
| | | _problemTypes = r |
| | | } |
| | | return _problemTypes |
| | | return _problemTypes ?: emptyList() |
| | | } |
| | | private var _problemTypes = mutableListOf<Problemtype>() |
| | | private var _problemTypes: List<Problemtype>? = null |
| | | |
| | | //自动评分规则一级分类 |
| | | val topItems: MutableList<Evaluationsubrule2> |
| | | val topItems: List<Evaluationsubrule2> |
| | | get() { |
| | | if (_topItems.isEmpty()) { |
| | | if (_topItems == null) { |
| | | val tempTopItems = mutableListOf<Evaluationsubrule2>() |
| | | val secRules = mutableListOf<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>>() |
| | | val rule = dbMapper.evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply { |
| | | createCriteria() |
| | | .andEqualTo("tasktypeid", 99) |
| | |
| | | }) |
| | | rules.forEach { |
| | | if (it.ertype == 2) { |
| | | _topItems.add(it) |
| | | tempTopItems.add(it) |
| | | } |
| | | } |
| | | _topItems.sortBy { it.displayid } |
| | | tempTopItems.sortBy { it.displayid } |
| | | |
| | | var t = 0 |
| | | _topItems.forEach { |
| | | tempTopItems.forEach { |
| | | t += it.maxscore ?: 0 |
| | | val tempRules = mutableListOf<Evaluationsubrule2>() |
| | | for (i in rules) { |
| | |
| | | } |
| | | } |
| | | tempSubRules.sortBy { ts -> ts.displayid } |
| | | this._rules.add(Pair(temp, tempSubRules)) |
| | | secRules.add(Pair(temp, tempSubRules)) |
| | | } |
| | | } |
| | | } |
| | | this._rules = secRules |
| | | _topItems = tempTopItems |
| | | } |
| | | return _topItems |
| | | return _topItems ?: emptyList() |
| | | } |
| | | private var _topItems = mutableListOf<Evaluationsubrule2>() |
| | | private var _topItems: List<Evaluationsubrule2>? = null |
| | | |
| | | //自动评分规则二级和三级分类 |
| | | val rules: MutableList<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>> |
| | | val rules: List<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>> |
| | | get() { |
| | | if (_rules.isEmpty()) { |
| | | if (_rules == null) { |
| | | this.topItems |
| | | } |
| | | return _rules |
| | | return _rules ?: emptyList() |
| | | } |
| | | private var _rules = mutableListOf<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>>() |
| | | private var _rules: List<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>>? = null |
| | | |
| | | //必填台账数量 |
| | | val ledgerCount: Int |
| | |
| | | fun clear() { |
| | | _scene = null |
| | | _baseScene = null |
| | | _problems.clear() |
| | | _problems = null |
| | | _evaluation = null |
| | | _itemevaluationList.clear() |
| | | _itemevaluationList = null |
| | | _ledgerRecordNum = null |
| | | if (lastScene != null && lastScene?.typeid != scene?.typeid) { |
| | | _problemTypes.clear() |
| | | _topItems.clear() |
| | | _rules.clear() |
| | | _problemTypes = null |
| | | _topItems = null |
| | | _rules = null |
| | | _ledgerCount = -1 |
| | | } |
| | | recordLastScene() |