提交 f0458619 authored 作者: ozoz's avatar ozoz

feat(screen): add new feat

上级 e8673b7a
......@@ -26,7 +26,6 @@ public class CheckUnitInfoList {
@ApiModelProperty(value = "单位名称")
private String unitName;
@ApiModelProperty(value = "检查情况集合")
private List<CheckUnitInfo> checkUnitInfos;
......
......@@ -6,6 +6,7 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -26,8 +27,17 @@ public class MapCheckVO {
@ApiModelProperty(value = "区域名称")
private String areaName;
@ApiModelProperty(value = "预警信息")
private List<CheckUnitInfoList> data;
@ApiModelProperty(value = "单位名称")
private String unitName;
@ApiModelProperty(value = "单位id")
private Integer unitId;
@ApiModelProperty(value = "本级信息")
private List<CheckUnitInfo> data= new ArrayList<>();
@ApiModelProperty(value = "下级预警信息")
private List<MapCheckVO> children = new ArrayList<>();
}
......@@ -42,13 +42,13 @@ public class CheckScreenServiceImpl implements CheckScreenService {
PredicateBuilder<DeviceCheckStat> and = Specifications.and();
LocalDateTime now = LocalDateTime.now();
and.ge("endTime", now);
and.le("endTIme", now.plusDays(2));
and.le("endTime", now.plusDays(2));
// 查询到所有快过期到统计任务
List<DeviceCheckStat> statList = statDao.findAll(and.build());
// 查询task,所有的顶级任务
List<Task> tasks = taskDao.findAllById(statList.parallelStream().map(DeviceCheckStat::getId).collect(Collectors.toList()))
.parallelStream().filter(o -> o.getParentTaskId() != 0).collect(Collectors.toList());
List<Task> tasks = taskDao.findAllByBillIdInAndBusinessType(statList.parallelStream().map(DeviceCheckStat::getId).collect(Collectors.toList()), 7)
.parallelStream().filter(o -> o.getParentTaskId() == 0).collect(Collectors.toList());
List<CheckUnitInfo> rs = new ArrayList<>();
......
package com.tykj.dev.device.screen;
import com.tykj.dev.device.screen.subject.service.CheckMapTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* @author ozoz
......@@ -9,8 +13,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackages = {
"com.tykj.dev.device.*"
})
@EnableScheduling
public class ScreenApp {
public static void main(String[] args) {
}
}
package com.tykj.dev.device.screen.subject.controller;
import com.tykj.dev.config.domin.MapCheckVO;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.config.vo.ConfigVo;
import com.tykj.dev.device.screen.subject.entity.CheckArg;
import com.tykj.dev.device.screen.subject.service.CheckMapTask;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
/**
* @author ozoz
* @date 2022/11/24
**/
@RestController
@RequestMapping(value = "/screen")
@AutoDocument
@Api(tags = "装备大屏接口")
@Slf4j
public class ScreenController {
@Autowired
private CheckMapTask checkMapTask;
@ApiOperation(value = "自核查接口", notes = "添加系统配置变量值")
@PostMapping(value = "/check")
public ResponseEntity<HashMap<String, List<MapCheckVO>>> add() {
return ResponseEntity.ok(checkMapTask.getData());
}
}
package com.tykj.dev.device.screen.subject.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author ozoz
* @date 2022/11/24
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CheckArg {
private String areaName;
}
package com.tykj.dev.device.screen.subject.service;
import com.tykj.dev.config.domin.CheckUnitInfo;
import com.tykj.dev.config.domin.MapCheckVO;
import com.tykj.dev.device.confirmcheck.service.CheckScreenService;
import com.tykj.dev.device.selfcheck.service.SelfCheckBillService;
import com.tykj.dev.device.user.subject.dao.RegionDataDao;
import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.entity.RegionData;
import com.tykj.dev.device.user.subject.entity.Units;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -21,45 +22,140 @@ import java.util.stream.Collectors;
**/
@Component
@Slf4j
public class CheckMapTask {
public class CheckMapTask implements CommandLineRunner {
private final static String ZJ_ID = "8017d86d-cf3c-1fe3-90ea-f8a8333a2254";
Map<Integer, List<CheckUnitInfo>> collect = new HashMap<>();
List<RegionData> shis = new ArrayList<>();
HashMap<String, List<MapCheckVO>> rs = new HashMap<>();
@Autowired
private UnitsDao unitsDao;
@Autowired
private RegionDataDao regionDataDao;
@Autowired
private CheckScreenService checkScreenService;
@Autowired
private SelfCheckBillService selfCheckBillService;
public HashMap<String, List<MapCheckVO>> getData() {
return rs;
}
/**
* 根据地区查询单位
* @return 单位集合
*/
public List<Units> findUnitByArea(String areaName) {
switch (areaName) {
case "浙江省":
return unitsDao.findAllByTypeAndLevel(1,1);
case "省直属":
return unitsDao.findAllByEscrow(1).orElse(new ArrayList<>());
case "省局":
return unitsDao.findAllByTypeAndLevel(2, 1);
default:
}
return unitsDao.findAllByNameLike("%" + areaName + "%");
}
public void initArea() {
// 查到了所有市的信息
List<RegionData> shis = regionDataDao.findAllByParentId(ZJ_ID);
shis.forEach(o -> o.setRegionDatas(regionDataDao.findAllByParentId(o.getRegionId())));
List<String> strUnit = Arrays.asList("浙江省","省直属", "省局");
for (String s : strUnit) {
List<Units> units = findUnitByArea(s);
List<MapCheckVO> objects = new ArrayList<>();
units.forEach( o -> {
MapCheckVO build = MapCheckVO.builder()
.unitName(o.getName())
.unitId(o.getUnitId())
.data(collect.get(o.getUnitId()))
.build();
objects.add(build);
});
rs.put(s,objects);
}
// 查到了所有市的信息
for (RegionData shi : shis) {
List<MapCheckVO> shiUnitsInfo = new ArrayList<>();
List<Units> unitByArea = findUnitByArea(shi.getName());
if (unitByArea .size() == 0) {
continue;
}
Units units = (Units) unitByArea.get(0);
List<MapCheckVO> childrenData = new ArrayList<>();
for (RegionData regionData : shi.getRegionDatas()) {
List<Units> unitByArea1 = findUnitByArea(regionData.getName());
if (unitByArea1.size() == 0) {
continue;
}
Units qu = (Units) unitByArea1.get(0);
MapCheckVO build = MapCheckVO.builder()
.areaName(regionData.getName())
.code(regionData.getCode())
.unitId(qu.getUnitId())
.unitName(qu.getName())
.data(collect.get(units.getUnitId()))
.build();
childrenData.add(build);
}
MapCheckVO build = MapCheckVO.builder()
.areaName(shi.getName())
.code(shi.getCode())
.unitId(units.getUnitId())
.unitName(units.getName())
.data(collect.get(units.getUnitId()))
.children(childrenData)
.build();
shiUnitsInfo.add(build);
rs.put(shi.getName(),shiUnitsInfo);
}
}
/**
* 根据单位id获取,获取告警信息。将次信息存储至内存中
* @return Map
*/
public Map<Integer, List<CheckUnitInfo>> init() {
List<CheckUnitInfo> checkUnitInfos = checkScreenService.statMapData();
List<CheckUnitInfo> selfExamination = selfCheckBillService.selectNoFinSh2Weeks();
checkUnitInfos.addAll(selfExamination);
Map<Integer, List<CheckUnitInfo>> collect = checkUnitInfos.stream().collect(Collectors.groupingBy(CheckUnitInfo::getUnitId));
collect = checkUnitInfos.stream().collect(Collectors.groupingBy(CheckUnitInfo::getUnitId));
return collect;
}
public void initShi() {
log.info("初始化大屏所需的地区信息");
long startTime = System.currentTimeMillis();
List<RegionData> shi = regionDataDao.findAllByParentId("330000");
for (RegionData regionData : shi) {
regionData.setRegionDatas(regionDataDao.findAllByParentId(regionData.getCode()));
}
shis = shi;
log.info("初始化大屏所需的地区信息完成,用时:{}ms", System.currentTimeMillis() - startTime);
log.info("市的信息:{}", shis);
}
@Override
public void run(String... args) throws Exception {
initShi();
init();
long startTime = System.currentTimeMillis();
log.info("开始计算数据", System.currentTimeMillis() - startTime);
initArea();
log.info("计算数据,用时:{}ms", System.currentTimeMillis() - startTime);
log.info("打印{}",rs.toString());
}
}
......@@ -272,6 +272,7 @@ public class SelfCheckBillServiceImpl implements SelfCheckBillService {
List<Integer> statusList = new ArrayList<>(Arrays.asList(0,3));
List<SelfCheckBill> checkBillList = selfExaminationBillDao.findAll().stream()
.filter(selfCheckBill -> statusList.contains(selfCheckBill.getCheckStatus()))
.filter(o -> o.getCheckTime() != null)
.filter(selfCheckBill -> LocalDateTime.now().isEqual(DateUtil.getLocalDateTime(selfCheckBill.getCheckTime()).plusWeeks(2)))
.collect(Collectors.toList());
List<CheckUnitInfo> checkUnitInfoList = new ArrayList<>();
......
......@@ -75,6 +75,13 @@
</profiles>
<dependencies>
<dependency>
<groupId>com.tykj</groupId>
<artifactId>dev-screen</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
......
server.port=8088
spring.application.name=device-dev
spring.datasource.url=jdbc:mysql://192.168.0.232:3307/device_master?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
......@@ -11,7 +13,7 @@ spring.jpa.hibernate.ddl-auto=update
#spring.jpa.hibernate.ddl-auto=update
#file.path=C:/Users/dengdiyi/Documents/file/
# spring boot admin
file.path=/Users/zhoushaopan/file/
file.path=/Users/ozoz/data/
preview.path=http://192.168.102.169:8087/file/
spring.boot.admin.client.url=http://localhost:8769
spring.boot.admin.client.instance.serviceBaseUrl=http://localhost:8087
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论