|
@ -1,10 +1,20 @@ |
|
|
package com.kms.yxgh.common.enums; |
|
|
package com.kms.yxgh.common.enums; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
|
|
import com.kms.system.domain.SysXzqh; |
|
|
|
|
|
import com.kms.system.service.SysXzqhService; |
|
|
|
|
|
import com.kms.yxgh.common.dto.CountDto; |
|
|
|
|
|
import com.kms.yxgh.common.dto.ObjectStatisticQueDto; |
|
|
import com.kms.yxgh.common.service.Statistic; |
|
|
import com.kms.yxgh.common.service.Statistic; |
|
|
|
|
|
import com.kms.yxgh.df.mapper.DfCheckingProblemV2Mapper; |
|
|
|
|
|
import com.kms.yxgh.df.mapper.DfCheckingRecordV2Mapper; |
|
|
|
|
|
import com.kms.yxgh.df.mapper.DfCheckingV2Mapper; |
|
|
|
|
|
import com.kms.yxgh.df.mapper.DfYhV2Mapper; |
|
|
|
|
|
import com.shuili.common.utils.SpringUtils; |
|
|
import lombok.Getter; |
|
|
import lombok.Getter; |
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
import java.util.*; |
|
|
import java.util.Map; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@Getter |
|
|
@Getter |
|
|
public enum StaticIndexEnum { |
|
|
public enum StaticIndexEnum { |
|
@ -25,39 +35,29 @@ public enum StaticIndexEnum { |
|
|
}, "个", "0"), |
|
|
}, "个", "0"), |
|
|
|
|
|
|
|
|
DF_QX_ADCD_SUM("缺陷数量", sp -> { |
|
|
DF_QX_ADCD_SUM("缺陷数量", sp -> { |
|
|
Map<String, String> map = new HashMap<>(); |
|
|
DfCheckingProblemV2Mapper mapper = SpringUtils.getBean(DfCheckingProblemV2Mapper.class); |
|
|
map.put("2024/05/20", "12"); |
|
|
List<CountDto> list = mapper.count(sp); |
|
|
map.put("2024/05/21", "15"); |
|
|
return adcdGroup(list, sp); |
|
|
map.put("2024/05/22", "17"); |
|
|
|
|
|
return map; |
|
|
|
|
|
}, "个", "0"), |
|
|
}, "个", "0"), |
|
|
DF_YH_ADCD_SUM("养护次数", sp -> { |
|
|
DF_YH_ADCD_SUM("养护次数", sp -> { |
|
|
Map<String, String> map = new HashMap<>(); |
|
|
DfYhV2Mapper mapper = SpringUtils.getBean(DfYhV2Mapper.class); |
|
|
map.put("2024/05/20", "12"); |
|
|
List<CountDto> list = mapper.count(sp); |
|
|
map.put("2024/05/21", "15"); |
|
|
return adcdGroup(list, sp); |
|
|
map.put("2024/05/22", "17"); |
|
|
|
|
|
return map; |
|
|
|
|
|
}, "个", "0"), |
|
|
}, "个", "0"), |
|
|
DF_PROJECT_ADCD_SUM("工程数量", sp -> { |
|
|
DF_PROJECT_ADCD_SUM("工程数量", sp -> { |
|
|
Map<String, String> map = new HashMap<>(); |
|
|
DfCheckingV2Mapper mapper = SpringUtils.getBean(DfCheckingV2Mapper.class); |
|
|
map.put("2024/05/20", "12"); |
|
|
List<CountDto> list = mapper.count(sp); |
|
|
map.put("2024/05/21", "15"); |
|
|
return adcdGroup(list, sp); |
|
|
map.put("2024/05/22", "17"); |
|
|
|
|
|
return map; |
|
|
|
|
|
}, "个", "0"), |
|
|
}, "个", "0"), |
|
|
DF_CHECKING_ADCD_SUM("工程巡查", sp -> { |
|
|
DF_CHECKING_ADCD_SUM("工程巡查", sp -> { |
|
|
Map<String, String> map = new HashMap<>(); |
|
|
DfCheckingRecordV2Mapper mapper = SpringUtils.getBean(DfCheckingRecordV2Mapper.class); |
|
|
map.put("2024/05/20", "12"); |
|
|
List<CountDto> list = mapper.count(sp, PatrolMaintenanceCategory.PROJECT_PATROL); |
|
|
map.put("2024/05/21", "15"); |
|
|
return adcdGroup(list, sp); |
|
|
map.put("2024/05/22", "17"); |
|
|
|
|
|
return map; |
|
|
|
|
|
}, "个", "0"), |
|
|
}, "个", "0"), |
|
|
DF_JD_ADCD_SUM("机电巡查", sp -> { |
|
|
DF_JD_ADCD_SUM("机电巡查", sp -> { |
|
|
Map<String, String> map = new HashMap<>(); |
|
|
DfCheckingRecordV2Mapper mapper = SpringUtils.getBean(DfCheckingRecordV2Mapper.class); |
|
|
map.put("2024/05/20", "12"); |
|
|
List<CountDto> list = mapper.count(sp, PatrolMaintenanceCategory.JD_PATROL); |
|
|
map.put("2024/05/21", "15"); |
|
|
return adcdGroup(list, sp); |
|
|
map.put("2024/05/22", "17"); |
|
|
|
|
|
return map; |
|
|
|
|
|
}, "个", "0"), |
|
|
}, "个", "0"), |
|
|
|
|
|
|
|
|
; |
|
|
; |
|
@ -74,4 +74,40 @@ public enum StaticIndexEnum { |
|
|
this.defaultValue = defaultValue; |
|
|
this.defaultValue = defaultValue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Map<String, String> adcdGroup(List<CountDto> list, ObjectStatisticQueDto sp) { |
|
|
|
|
|
if (CollectionUtil.isEmpty(list)) { |
|
|
|
|
|
return Collections.emptyMap(); |
|
|
|
|
|
} |
|
|
|
|
|
String queryAdcd = sp.getAdcdQx(); |
|
|
|
|
|
int index = queryAdcd.length(); |
|
|
|
|
|
List<String> adcds = list.stream() |
|
|
|
|
|
.map(co -> fullAdcd(co.getCode(), index)) |
|
|
|
|
|
.distinct() |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
SysXzqhService service = SpringUtils.getBean(SysXzqhService.class); |
|
|
|
|
|
Map<String, SysXzqh> map = service.get(adcds); |
|
|
|
|
|
return list.stream().map(item -> { |
|
|
|
|
|
String code = fullAdcd(item.getCode(), index); |
|
|
|
|
|
SysXzqh sysXzqh = map.get(code); |
|
|
|
|
|
if (sysXzqh != null) { |
|
|
|
|
|
item.setCode(sysXzqh.getName()); |
|
|
|
|
|
return item; |
|
|
|
|
|
} else { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
}).filter(Objects::nonNull) |
|
|
|
|
|
.collect(Collectors.groupingBy(CountDto::getCode, |
|
|
|
|
|
Collectors.reducing("0", item -> item.getSum() + "", (a, b) -> { |
|
|
|
|
|
int sum = Integer.parseInt(a); |
|
|
|
|
|
int add = Integer.parseInt(b); |
|
|
|
|
|
return String.valueOf(sum + add); |
|
|
|
|
|
} |
|
|
|
|
|
))); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static String fullAdcd(String adcd, int index) { |
|
|
|
|
|
return (adcd.substring(0, index + 2) + "0000000000000000").substring(0, 12); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|