feiyu02
2022-09-15 3e2159e45e12b2b8af058b68eafeaf082cf3fe85
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
package cn.flightfeather.supervision.lightshare.service.Impl
 
import cn.flightfeather.supervision.domain.entity.*
import cn.flightfeather.supervision.domain.enumeration.*
import cn.flightfeather.supervision.domain.mapper.*
import cn.flightfeather.supervision.infrastructure.utils.DateUtil
import cn.flightfeather.supervision.lightshare.service.OnLineQuestionService
import cn.flightfeather.supervision.lightshare.vo.*
import com.github.pagehelper.PageHelper
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Component
import org.springframework.stereotype.Service
import tk.mybatis.mapper.entity.Example
import java.util.*
import javax.annotation.Resource
import javax.servlet.http.HttpServletResponse
 
/**
 * @Description: 月问题实现类
 */
@Service
@Component
class OnLineQuestionServiceImpl(
    private val mgtFileMapper: MgtFileMapper,
    private val mgtItemMapper: MgtItemMapper,
    private val userinfoMapper: UserinfoMapper,
    private val cstQuestionMapper: CstQuestionMapper,
    private val settingAnswerMapper: SettingAnswerMapper,
    private val enforceCaseMapper: EnforceCaseMapper
) : OnLineQuestionService {
    @Resource
    private val onLineQuestionMapper: OnLineQuestionMapper? = null
    override fun addQuestions(userId: String, questions: List<OnLineQuestion>): Int {
        var r = 0
        for (q in questions) {
            r += onLineQuestionMapper!!.insert(q)
        }
        return r
    }
 
    override fun getQuestions(userId: String, inUse: Boolean, page: Int, perPage: Int, httpServletResponse: HttpServletResponse): List<OnLineQuestion> {
 
        // 1.计算出起始位置
        val startPosition = (page - 1) * perPage
        //2.分页的方法查询数据
        PageHelper.startPage<Any>(startPosition, perPage)
        val allMeetings: List<OnLineQuestion>
        //3.分页显示数据
        allMeetings = if (inUse) {
            onLineQuestionMapper!!.findAll()
        } else {
            onLineQuestionMapper!!.findAllfalse()
        }
        val counts = onLineQuestionMapper.count()
        val totalPage = Math.ceil(counts / perPage * 1.0).toInt()
        httpServletResponse.setIntHeader("totalPage", totalPage)
        httpServletResponse.setIntHeader("currentPage", page)
        return allMeetings
    }
 
    override fun getQDescription(userId: String, questionId: String): String {
        return onLineQuestionMapper!!.getQDescription(questionId)
    }
 
    override fun getQResource(userId: String, questionId: String, page: Int, perPage: Int, httpServletResponse: HttpServletResponse): List<String> {
        // 1.计算出起始位置
        val startPosition = (page - 1) * perPage
        val getQDescription = onLineQuestionMapper!!.getQResource(questionId)
        val lis = Arrays.asList(*getQDescription.split("、").toTypedArray())
        val result: List<String>
        result = if (startPosition + perPage < lis.size) {
            lis.subList(startPosition, startPosition + perPage)
        } else {
            lis.subList(startPosition, lis.size)
        }
        val counts = lis.size
        val totalPage = Math.ceil(counts / perPage * 1.0).toInt()
        httpServletResponse.setIntHeader("totalPage", totalPage)
        httpServletResponse.setIntHeader("currentPage", page)
        return result
    }
 
    override fun getQByConditions(userId: String, inUse: Boolean, qCondition: QCondition, page: Int, perPage: Int, httpServletResponse: HttpServletResponse): List<OnLineQuestion> {
        val keywords = qCondition.keywords
        val factorType = qCondition.factorType
        val resourceKind = qCondition.resourceKind
        val showLevel = qCondition.showLevel
        val worKind = qCondition.worKind
        // 1.计算出起始位置
        val startPosition = (page - 1) * perPage
        //2.分页的方法查询数据
        PageHelper.startPage<Any>(startPosition, perPage)
        //3.分页显示数据  //模糊查询
        val result = onLineQuestionMapper!!.getQByConditions(keywords, factorType, resourceKind, showLevel, worKind)
        val counts = onLineQuestionMapper.getQByConditionsCounts(keywords, factorType, resourceKind, showLevel, worKind)
        val totalPage = Math.ceil(counts / perPage * 1.0).toInt()
        httpServletResponse.setIntHeader("totalPage", totalPage)
        httpServletResponse.setIntHeader("currentPage", page)
        return result
    }
 
    override fun searchLaw(userId: String, keyword: String, type: Byte?, page: Int, perPage: Int): BaseResponse<List<ConsultResultVo>> {
        val userInfo = userinfoMapper.selectByPrimaryKey(userId) ?: return BaseResponse(false)
        val response = BaseResponse<List<ConsultResultVo>>(false, head = DataHead(page, perPage))
        val result = mutableListOf<ConsultResultVo>()
 
        //当搜索不限制类型时,默认每种类型只获取前5项;当限制类型时,则根据前端请求分页数返回
        val _perPage = if (type == null) 5 else perPage
        val _page = page
 
        //法律法规文件
        if (type == null || type == ConsultResultType.TYPE1.value) {
            val p = PageHelper.startPage<MgtFile>(_page, _perPage)
            val example = Example(MgtFile::class.java).apply {
                if (keyword.isNotBlank()) {
                    createCriteria().orLike("mfName", "%${keyword}%")
                        .orLike("mfShortName", "%${keyword}%")
                        .orLike("mfSummary", "%${keyword}%")
                        .orLike("mfKeywordLv1", "%${keyword}%")
                        .orLike("mfKeywordLv2", "%${keyword}%")
                        .orLike("mfKeywordLv3", "%${keyword}%")
                        .orLike("mfKeywordLv4", "%${keyword}%")
                } else {
                    // TODO: 2022/9/8 没有关键字时,按照热门获取机制获取
                    createCriteria().orLike("mfExtension1", "%${userInfo.extension2}%")
                        .orEqualTo("mfExtension1", "")
                        .orIsNull("mfExtension1")
                }
            }
            mgtFileMapper.selectByExample(example).forEach {
                result.add(ConsultResultFileVo().apply {
                    id = it.mfGuid
                    name = it.mfName
                    des = it.mfSummary
                    typeId = ConsultResultType.TYPE1.value
                    typeName = ConsultResultType.TYPE1.des
 
                    fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry)
                    itemType = EnElementType.getNameByValue(it.mfEpItemType)
                    itemSubType = EnElementSubType.getNameByValue(it.mfEpItemSubtype)
                    fileUrl = it.mfFileUrl
                    val keyList = it.mfKeywordLv1.split("、")
                    for (i in keyList.indices) {
                        if (i < 5) {
                            keywords.add(keyList[i])
                        } else {
                            break
                        }
                    }
                    time = it.mfUpdateTime
                    fileType = ConsultFileType.getNameByValue(it.mfFileType)
                    referenceNumber = it.mfReferenceNumber
                    effectiveDate = DateUtil.DateToString(it.mfEffectiveDate, DateUtil.DateStyle.YYYY_MM_DD)
                    closingDate = DateUtil.DateToString(it.mfClosingDate, DateUtil.DateStyle.YYYY_MM_DD)
                    effective = Date().time > (it.mfClosingDate?.time ?: 0)
                })
            }
            response.success = true
            response.head?.run {
                this.page = p.pageNum
                this.totalPage = p.pages
            }
        }
        //法律法规条目
        if (type == null || type == ConsultResultType.TYPE2.value) {
            val map = mutableMapOf<String, MgtFile>()
            val p = PageHelper.startPage<MgtItem>(_page, _perPage)
            val example = Example(MgtItem::class.java).apply {
                if (keyword.isNotBlank()) {
                    createCriteria().orLike("miChapterKeyword", "%${keyword}%")
                        .orLike("miKeyword", "%${keyword}%")
                } else {
                    // TODO: 2022/9/8 没有关键字时,按照热门获取机制获取条目
                }
            }
            mgtItemMapper.selectByExample(example).forEach {
                if (!map.containsKey(it.mfGuid)) {
                    map[it.mfGuid] = mgtFileMapper.selectByPrimaryKey(it.mfGuid)
                }
                result.add(ConsultResultItemVo().apply {
                    id = it.miGuid
                    name = it.miItemName
                    des = it.miItemContent
                    typeId = ConsultResultType.TYPE2.value
                    typeName = ConsultResultType.TYPE2.des
 
//                    fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry)
//                    itemType = EnElementType.getNameByValue(it.mfEpItemType)
//                    fileUrl = it.mfFileUrl
                    val keyList = it.miKeyword.split("、")
                    for (i in keyList.indices) {
                        if (i < 5) {
                            keywords.add(keyList[i])
                        } else {
                            break
                        }
                    }
                    time = it.miUpdateTime
 
                    chapterName = it.miChapterName
                    fileId = it.mfGuid
                    fileName = it.mfName
                    referenceNumber = it.mfReferenceNumber
                    effectiveDate = DateUtil.DateToString(map[it.mfGuid]?.mfEffectiveDate, DateUtil.DateStyle.YYYY_MM_DD)
                    closingDate = DateUtil.DateToString(map[it.mfGuid]?.mfClosingDate, DateUtil.DateStyle.YYYY_MM_DD)
                    effective = Date().time > (map[it.mfGuid]?.mfClosingDate?.time ?: 0)
                    relatedItems = it.miRelatedItems?.split(";")?.size ?: 0
                })
            }
            response.success = true
            response.head?.run {
                this.page = p.pageNum
                this.totalPage = p.pages
            }
        }
        //环保问题
        if (type == null || type == ConsultResultType.TYPE4.value) {
            val p = PageHelper.startPage<CstQuestion>(_page, _perPage)
            val example = Example(CstQuestion::class.java).apply {
                if (keyword.isNotBlank()) {
                    createCriteria().orLike("cqScenes", "%${userInfo.extension2}%")
                        .orEqualTo("cqScenes", "")
                        .orIsNull("cqScenes")
                    and(
                        createCriteria().orLike("cqContent", "%${keyword}%")
                            .orLike("cqKeywords", "%${keyword}%")
                    )
                } else {
                    // TODO: 2022/9/8 没有关键字时,按照热门获取机制获取
                    createCriteria().orLike("cqScenes", "%${userInfo.extension2}%")
                    orderBy("cqTotalnum")
                }
            }
            cstQuestionMapper.selectByExample(example).forEach {
                val answers = settingAnswerMapper.selectByExample(Example(SettingAnswer::class.java).apply {
                    createCriteria().andEqualTo("cqGuid", it.cqGuid)
                })
 
                result.add(ConsultResultQAVo().apply {
                    id = it.cqGuid
                    name = it.cqContent
                    if (answers.isNotEmpty()) {
                        des = answers[0].saContent
                    }
                    typeId = ConsultResultType.TYPE4.value
                    typeName = ConsultResultType.TYPE4.des
 
//                    fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry)
                    itemType = EnElementType.getNameByValue(it.cqKind)
                    itemSubType = EnElementSubType.getNameByValue(it.cqSubkind)
//                    fileUrl = it.mfFileUrl
//                    val keyList = it.mfKeywordLv1.split("、")
//                    for (i in keyList.indices) {
//                        if (i < 5) {
//                            keywords.add(keyList[i])
//                        } else {
//                            break
//                        }
//                    }
                    time = it.cqCreateTime
                })
            }
            response.success = true
            response.head?.run {
                this.page = p.pageNum
                this.totalPage = p.pages
            }
        }
        //执法案例
        if (type == null || type == ConsultResultType.TYPE3.value) {
            val p = PageHelper.startPage<EnforceCase>(_page, _perPage)
            val example = Example(EnforceCase::class.java).apply {
                if (keyword.isNotBlank()) {
                    createCriteria().orLike("ecScenes", "%${userInfo.extension2}%")
                        .orEqualTo("ecScenes", "")
                        .orIsNull("ecScenes")
                    and(
                        createCriteria().orLike("ecTitle", "%${keyword}%")
                            .orLike("ecKeywords", "%${keyword}%")
                    )
                } else {
                    // TODO: 2022/9/8 没有关键字时,按照热门获取机制获取
                    createCriteria().orLike("ecScenes", "%${userInfo.extension2}%")
                        .orEqualTo("ecScenes", "")
                        .orIsNull("ecScenes")
                    orderBy("ecOccurDate").desc()
                }
            }
            enforceCaseMapper.selectByExample(example).forEach {
                result.add(ConsultResultCaseVo().apply {
                    id = it.ecGuid
                    name = it.ecTitle
                    des = it.ecSummary
                    typeId = ConsultResultType.TYPE3.value
                    typeName = ConsultResultType.TYPE3.des
 
//                    fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry)
                    itemType = EnElementType.getNameByValue(it.ecEpItemType)
                    itemSubType = EnElementSubType.getNameByValue(it.ecEpItemSubtype)
                    imgUrl = it.ecAppendixUrl?.split(";")?.get(0)
                    time = it.ecCreateTime
 
                    provinceName = it.ecProvinceName
                    cityName = it.ecCityName
                    occurDate = DateUtil.DateToString(it.ecOccurDate, DateUtil.DateStyle.YYYY_MM_DD)
                    punish = it.ecIsPunish
                    detained = it.ecIsDetained
                    illegal = it.ecIsIllegal
                    shotSpot = it.ecIsShotspot
                    supervise = it.ecIsSupervise
                    minor = it.ecIsMinor
                })
            }
            response.success = true
            response.head?.run {
                this.page = p.pageNum
                this.totalPage = p.pages
            }
        }
 
 
        return response.apply { data = result }
    }
 
    override fun getTopicLaw(userId: String): List<MgtFileVo> {
        val userInfo = userinfoMapper.selectByPrimaryKey(userId) ?: return emptyList()
        val perPage = 5
        val p = PageHelper.startPage<MgtFile>(1, perPage)
        val result = mutableListOf<MgtFileVo>()
        mgtFileMapper.selectByExample(Example(MgtFile::class.java).apply {
            createCriteria().orLike("mfExtension1", "%${userInfo.extension2}%")
                .orEqualTo("mfExtension1", "")
                .orIsNull("mfExtension1")
        }).forEach {
            val vo = MgtFileVo()
            BeanUtils.copyProperties(it, vo)
            vo.apply {
                mfFileIndustry = IndustryType.getNameByValue(it.mfFileIndustry)
                mfMgtLevel = ManageLevelType.getNameByValue(it.mfMgtLevel)
                mfFileType = ConsultFileType.getNameByValue(it.mfFileType)
                mfEpItemType = EnElementType.getNameByValue(it.mfEpItemType)
                mfEpItemSubtype = EnElementSubType.getNameByValue(it.mfEpItemSubtype)
                mfSaveType = FileSaveType.getNameByValue(it.mfSaveType)
            }
            result.add(vo)
        }
        return result
    }
 
    override fun getMgtFile(userId: String, fileId: String): MgtFileVo {
        val result = MgtFileVo()
        mgtFileMapper.selectByPrimaryKey(fileId)?.let {
            BeanUtils.copyProperties(it, result)
            result.apply {
                mfFileIndustry = IndustryType.getNameByValue(it.mfFileIndustry)
                mfMgtLevel = ManageLevelType.getNameByValue(it.mfMgtLevel)
                mfFileType = ConsultFileType.getNameByValue(it.mfFileType)
                mfEpItemType = EnElementType.getNameByValue(it.mfEpItemType)
                mfEpItemSubtype = EnElementSubType.getNameByValue(it.mfEpItemSubtype)
                mfSaveType = FileSaveType.getNameByValue(it.mfSaveType)
            }
        }
 
        return result
    }
 
    override fun getTopicMgtItems(userId: String): List<MgtItem> {
        val perPage = 5
        val p = PageHelper.startPage<MgtFile>(1, perPage)
        return mgtItemMapper.selectAll()
    }
 
    override fun getMgtItem(userId: String, itemId: String): MgtItem {
        return mgtItemMapper.selectByPrimaryKey(itemId) ?: MgtItem()
    }
 
    override fun getTopicQA(userId: String): List<CstQuestionVo> {
        val userInfo = userinfoMapper.selectByPrimaryKey(userId) ?: return emptyList()
        val perPage = 5
        val p = PageHelper.startPage<CstQuestion>(1, perPage)
        val result = mutableListOf<CstQuestionVo>()
        cstQuestionMapper.selectByExample(Example(CstQuestion::class.java).apply {
            createCriteria().orLike("cqScenes", "%${userInfo.extension2}%")
            orderBy("cqTotalnum")
        }).forEach {
            val answers = settingAnswerMapper.selectByExample(Example(SettingAnswer::class.java).apply {
                createCriteria().andEqualTo("cqGuid", it.cqGuid)
            })
            val vo = CstQuestionVo()
            BeanUtils.copyProperties(it, vo)
            vo.apply {
                cqKind = EnElementType.getNameByValue(it.cqKind)
                cqSubkind = EnElementSubType.getNameByValue(it.cqSubkind)
            }
 
            if (answers.isNotEmpty()) {
                vo.answer = answers[0].saContent
            }
            result.add(vo)
        }
        return result
    }
 
    override fun getQuestionsByType(userId: String, kind: Byte?, subKind: Byte?, page: Int, perPage: Int): BaseResponse<List<ConsultResultVo>> {
        val userInfo = userinfoMapper.selectByPrimaryKey(userId) ?: return BaseResponse(false, "用户不存在")
        val result = mutableListOf<ConsultResultVo>()
        val p = PageHelper.startPage<CstQuestion>(page, perPage)
        val example = Example(CstQuestion::class.java).apply {
            createCriteria().apply {
                kind?.let { andEqualTo("cqKind", kind) }
                subKind?.let { andEqualTo("cqSubkind", subKind) }
            }
                .andLike("cqScenes", "%${userInfo.extension2}%")
            orderBy("cqTotalnum")
        }
        cstQuestionMapper.selectByExample(example).forEach {
            val answers = settingAnswerMapper.selectByExample(Example(SettingAnswer::class.java).apply {
                createCriteria().andEqualTo("cqGuid", it.cqGuid)
            })
 
            result.add(ConsultResultQAVo().apply {
                id = it.cqGuid
                name = it.cqContent
                if (answers.isNotEmpty()) {
                    des = answers[0].saContent
                }
                typeId = ConsultResultType.TYPE4.value
                typeName = ConsultResultType.TYPE4.des
                itemType = EnElementType.getNameByValue(it.cqKind)
                itemSubType = EnElementSubType.getNameByValue(it.cqSubkind)
                time = it.cqCreateTime
            })
 
//            val vo = CstQuestionVo()
//            BeanUtils.copyProperties(it, vo)
//            vo.apply {
//                cqKind = EnElementType.getNameByValue(it.cqKind)
//                cqSubkind = EnElementSubType.getNameByValue(it.cqSubkind)
//            }
//
//            if (answers.isNotEmpty()) {
//                vo.answer = answers[0].saContent
//            }
//            result.add(vo)
        }
        val totalCount = cstQuestionMapper.selectCountByExample(example)
        return BaseResponse(true, head = DataHead(p.pageNum, p.pages, totalCount), data = result)
    }
 
    override fun getQuestion(userId: String, qId: String): CstQuestionVo {
        val result = CstQuestionVo()
        cstQuestionMapper.selectByPrimaryKey(qId)?.let {
            BeanUtils.copyProperties(it, result)
            result.apply {
                cqKind = EnElementType.getNameByValue(it.cqKind)
                cqSubkind = EnElementSubType.getNameByValue(it.cqSubkind)
            }
        }
 
        return result
    }
 
    override fun getAnswers(userId: String, qId: String): List<SettingAnswer> {
        return settingAnswerMapper.selectByExample(Example(SettingAnswer::class.java).apply {
            createCriteria().andEqualTo("cqGuid", qId)
        })
    }
 
    override fun getTopicCase(userId: String): List<EnforceCaseVo> {
        val userInfo = userinfoMapper.selectByPrimaryKey(userId) ?: return emptyList()
        val perPage = 5
        val p = PageHelper.startPage<MgtFile>(1, perPage)
        val result = mutableListOf<EnforceCaseVo>()
        enforceCaseMapper.selectByExample(Example(EnforceCase::class.java).apply {
            createCriteria().orLike("ecScenes", "%${userInfo.extension2}%")
                .orEqualTo("ecScenes", "")
                .orIsNull("ecScenes")
            orderBy("ecOccurDate").desc()
        }).forEach {
            val vo = EnforceCaseVo()
            BeanUtils.copyProperties(it, vo)
            vo.apply {
                ecEpItemType = EnElementType.getNameByValue(it.ecEpItemType)
                ecEpItemSubtype = EnElementSubType.getNameByValue(it.ecEpItemSubtype)
                ecType = EnforceCaseType.getNameByValue(it.ecType)
            }
            result.add(vo)
        }
        return result
    }
 
    override fun getCase(userId: String, caseId: String): EnforceCaseVo {
        val result = EnforceCaseVo()
        enforceCaseMapper.selectByPrimaryKey(caseId)?.let {
            BeanUtils.copyProperties(it, result)
            result.apply {
                ecEpItemType = EnElementType.getNameByValue(it.ecEpItemType)
                ecEpItemSubtype = EnElementSubType.getNameByValue(it.ecEpItemSubtype)
                ecType = EnforceCaseType.getNameByValue(it.ecType)
            }
        }
 
        return result
    }
 
    override fun getEnElementTypes(userId: String): List<Pair<String, Byte>> {
        return listOf(
            Pair(EnElementType.TYPE1.des, EnElementType.TYPE1.value),
            Pair(EnElementType.TYPE2.des, EnElementType.TYPE2.value),
            Pair(EnElementType.TYPE3.des, EnElementType.TYPE3.value),
            Pair(EnElementType.TYPE4.des, EnElementType.TYPE4.value),
            Pair(EnElementType.TYPE5.des, EnElementType.TYPE5.value),
            Pair(EnElementType.TYPE6.des, EnElementType.TYPE6.value),
            Pair(EnElementType.TYPE7.des, EnElementType.TYPE7.value),
            Pair(EnElementType.TYPE8.des, EnElementType.TYPE8.value),
            Pair(EnElementType.TYPE9.des, EnElementType.TYPE9.value),
            Pair(EnElementType.TYPE10.des, EnElementType.TYPE10.value),
            Pair(EnElementType.TYPE21.des, EnElementType.TYPE21.value),
            Pair(EnElementType.TYPE31.des, EnElementType.TYPE31.value),
            Pair(EnElementType.TYPE41.des, EnElementType.TYPE41.value),
            Pair(EnElementType.TYPE51.des, EnElementType.TYPE51.value),
            Pair(EnElementType.TYPE61.des, EnElementType.TYPE61.value),
            Pair(EnElementType.TYPE99.des, EnElementType.TYPE99.value),
        )
    }
 
    override fun getEnElementSubTypes(userId: String): List<List<Pair<String, Byte>>> {
        val result = mutableListOf<List<Pair<String, Byte>>>()
        EnElementSubType.subTypes.forEach { sList ->
            val list = mutableListOf<Pair<String, Byte>>()
            for (i in sList.indices) {
                if (i == sList.lastIndex) {
                    list.add(Pair(sList[i], 99.toByte()))
                } else {
                    list.add(Pair(sList[i], (i + 1).toByte()))
                }
            }
            result.add(list)
        }
        return result
    }
}