提交 f4fd4767 authored 作者: 邓砥奕's avatar 邓砥奕

添加大屏接口

上级 c732cbca
package com.tykj.dev.device.file.Controller; package com.tykj.dev.device.file.Controller;
import com.itextpdf.text.*; import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.text.pdf.PdfWriter;
import com.tykj.dev.config.swagger.AutoDocument; import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.file.entity.FileRet; import com.tykj.dev.device.file.entity.FileRet;
...@@ -10,14 +13,14 @@ import io.swagger.annotations.ApiOperation; ...@@ -10,14 +13,14 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.jpa.repository.query.JpaEntityGraph;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartRequest; import org.springframework.web.multipart.MultipartRequest;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
...@@ -126,7 +129,13 @@ public class FileController { ...@@ -126,7 +129,13 @@ public class FileController {
document.newPage(); document.newPage();
float height = img.getHeight(); float height = img.getHeight();
float width = img.getWidth(); float width = img.getWidth();
int percent = getPercent(height, width); int percent;
if (width>=height) {
percent = getPercent(height, width);
}
else {
percent = getPercent2(height,width);
}
img.setAlignment(Image.MIDDLE); img.setAlignment(Image.MIDDLE);
img.scalePercent(percent); img.scalePercent(percent);
document.add(img); document.add(img);
...@@ -254,7 +263,7 @@ public class FileController { ...@@ -254,7 +263,7 @@ public class FileController {
/** /**
* 等比压缩,获取压缩百分比 * 等比压缩,获取压缩百分比(A4横向)
* *
* @param height 图片的高度 * @param height 图片的高度
* @param weight 图片的宽度 * @param weight 图片的宽度
...@@ -270,4 +279,20 @@ public class FileController { ...@@ -270,4 +279,20 @@ public class FileController {
return Math.round(percent); return Math.round(percent);
} }
/**
* 等比压缩,获取压缩百分比(A4纵向)
*
* @param height 图片的高度
* @param weight 图片的宽度
* @return 压缩百分比
*/
private static int getPercent2(float height, float weight) {
float percent = 0.0F;
if (height > weight) {
percent = PageSize.A4.getHeight() / height * 100;
} else {
percent = PageSize.A4.getWidth() / weight * 100;
}
return Math.round(percent);
}
} }
...@@ -212,10 +212,10 @@ public class RfidServiceImpl implements RfidService { ...@@ -212,10 +212,10 @@ public class RfidServiceImpl implements RfidService {
} }
StringBuilder stringBuffer = new StringBuilder(); StringBuilder stringBuffer = new StringBuilder();
if (deviceType.length() <= 10) { if (deviceType.length() <= 10) {
stringBuffer.append(deviceType);
for (int i = 0; i < 10 - deviceType.length(); i++) { for (int i = 0; i < 10 - deviceType.length(); i++) {
stringBuffer.append(" "); stringBuffer.append("0");
} }
stringBuffer.append(deviceType);
} else { } else {
stringBuffer.append(deviceType.substring(deviceType.length() - 10)); stringBuffer.append(deviceType.substring(deviceType.length() - 10));
} }
...@@ -223,19 +223,19 @@ public class RfidServiceImpl implements RfidService { ...@@ -223,19 +223,19 @@ public class RfidServiceImpl implements RfidService {
stringBuffer.append(partType); stringBuffer.append(partType);
if (deviceNumber.length() < 4) { if (deviceNumber.length() < 4) {
stringBuffer.append(deviceNumber);
for (int i = 0; i < 4 - deviceNumber.length(); i++) { for (int i = 0; i < 4 - deviceNumber.length(); i++) {
stringBuffer.append(" "); stringBuffer.append("0");
} }
stringBuffer.append(deviceNumber);
} else { } else {
stringBuffer.append(deviceNumber.substring(deviceNumber.length() - 4)); stringBuffer.append(deviceNumber.substring(deviceNumber.length() - 4));
} }
if (produceNumber.length() < 4) { if (produceNumber.length() < 4) {
stringBuffer.append(produceNumber);
for (int i = 0; i < 4 - produceNumber.length(); i++) { for (int i = 0; i < 4 - produceNumber.length(); i++) {
stringBuffer.append(" "); stringBuffer.append("0");
} }
stringBuffer.append(produceNumber);
} else { } else {
stringBuffer.append(produceNumber.substring(produceNumber.length() - 4)); stringBuffer.append(produceNumber.substring(produceNumber.length() - 4));
} }
......
package com.tykj.dev.statistical.cache;
import com.tykj.dev.statistical.vo.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author dengdiyi
* 大屏缓存
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class BigScreenCache {
/**
* 省及各市装备统计信息
*/
private List<DevNum> devNums;
/**
* 全省入库业务每月数量统计
*/
private List<BusinessNum> businessNums;
/**
* 大屏中心信息统计
*/
private CenterNum centerNum;
/**
* 装备维修情况数量统计
*/
private RepairNum repairNum;
/**
* 装备维修情况装备统计
*/
private List<RepairDevice> repairDevices;
/**
* 最近一次自查统计
*/
private List<SelfCheckNum> selfCheckNums;
/**
* 专管员统计
*/
private List<UserDateScreen> userDateScreens;
}
package com.tykj.dev.statistical.cache; package com.tykj.dev.statistical.cache;
import com.tykj.dev.statistical.service.BigScreenService;
import com.tykj.dev.statistical.service.StatisticalService; import com.tykj.dev.statistical.service.StatisticalService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -17,8 +18,16 @@ public class CacheConfig { ...@@ -17,8 +18,16 @@ public class CacheConfig {
@Autowired @Autowired
private StatisticalService statisticalService; private StatisticalService statisticalService;
@Autowired
private BigScreenService bigScreenService;
@Bean @Bean
public StatisticalCache initStatisticalCache() throws ParseException { public StatisticalCache initStatisticalCache() throws ParseException {
return new StatisticalCache(statisticalService.getDeviceNum(),statisticalService.getLifeStatus(1),statisticalService.getLifeStatus(2),statisticalService.getSelfCheck(),statisticalService.getYearSelfCheck(),statisticalService.getRfidWarning(),statisticalService.getRfidWarningDetail(1),statisticalService.getRfidWarningDetail(2),statisticalService.getCheckNum(),statisticalService.getConfirmCheck(1),statisticalService.getConfirmCheck(2),statisticalService.getUserGeneralSituation()); return new StatisticalCache(statisticalService.getDeviceNum(),statisticalService.getLifeStatus(1),statisticalService.getLifeStatus(2),statisticalService.getSelfCheck(),statisticalService.getYearSelfCheck(),statisticalService.getRfidWarning(),statisticalService.getRfidWarningDetail(1),statisticalService.getRfidWarningDetail(2),statisticalService.getCheckNum(),statisticalService.getConfirmCheck(1),statisticalService.getConfirmCheck(2),statisticalService.getUserGeneralSituation());
} }
@Bean
public BigScreenCache initBigScreenCache(){
return new BigScreenCache(bigScreenService.getAllDeviceNum(),bigScreenService.getBusinessNum(2),bigScreenService.getCenterNum(),bigScreenService.getRepairNum(),bigScreenService.getRepairDevices(),bigScreenService.getSelfCheckNum(),bigScreenService.selectUserDataScreen());
}
} }
...@@ -10,9 +10,7 @@ import com.tykj.dev.device.user.subject.dao.UserDao; ...@@ -10,9 +10,7 @@ import com.tykj.dev.device.user.subject.dao.UserDao;
import com.tykj.dev.device.user.subject.entity.Area; import com.tykj.dev.device.user.subject.entity.Area;
import com.tykj.dev.device.user.subject.entity.Units; import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.entity.User; import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.rfid.entity.domin.InputOutputDevice; import com.tykj.dev.statistical.service.BigScreenService;
import com.tykj.dev.rfid.repository.InputOutputDeviceDao;
import com.tykj.dev.rfid.timeTask.AccessSchedulerTask;
import com.tykj.dev.statistical.service.StatisticalService; import com.tykj.dev.statistical.service.StatisticalService;
import lombok.Data; import lombok.Data;
import lombok.SneakyThrows; import lombok.SneakyThrows;
...@@ -22,7 +20,6 @@ import org.springframework.scheduling.support.CronTrigger; ...@@ -22,7 +20,6 @@ import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -60,7 +57,11 @@ public class CacheRefreshTask { ...@@ -60,7 +57,11 @@ public class CacheRefreshTask {
final UnitsCache unitsCache; final UnitsCache unitsCache;
public CacheRefreshTask(StatisticalService statisticalService,AreaDao areaDao,UserDao userDao,UnitsDao unitsDao,StatisticalCache statisticalCache,AreaCache areaCache,UserCache userCache,UnitsCache unitsCache){ final BigScreenCache bigScreenCache;
final BigScreenService bigScreenService;
public CacheRefreshTask(StatisticalService statisticalService,AreaDao areaDao,UserDao userDao,UnitsDao unitsDao,StatisticalCache statisticalCache,AreaCache areaCache,UserCache userCache,UnitsCache unitsCache,BigScreenCache bigScreenCache,BigScreenService bigScreenService){
this.statisticalService = statisticalService; this.statisticalService = statisticalService;
this.areaDao = areaDao; this.areaDao = areaDao;
this.userDao = userDao; this.userDao = userDao;
...@@ -69,6 +70,8 @@ public class CacheRefreshTask { ...@@ -69,6 +70,8 @@ public class CacheRefreshTask {
this.userCache = userCache; this.userCache = userCache;
this.unitsCache = unitsCache; this.unitsCache = unitsCache;
this.statisticalCache = statisticalCache; this.statisticalCache = statisticalCache;
this.bigScreenCache = bigScreenCache;
this.bigScreenService = bigScreenService;
scheduledFuture = TaskBeanConfig.getThreadPoolTaskScheduler().schedule(new RefreshTask(), triggerContext -> new CronTrigger(cron).nextExecutionTime(triggerContext)); scheduledFuture = TaskBeanConfig.getThreadPoolTaskScheduler().schedule(new RefreshTask(), triggerContext -> new CronTrigger(cron).nextExecutionTime(triggerContext));
log.info("[统计分析模块]:定时更新缓存任务开启"); log.info("[统计分析模块]:定时更新缓存任务开启");
} }
...@@ -106,6 +109,16 @@ public class CacheRefreshTask { ...@@ -106,6 +109,16 @@ public class CacheRefreshTask {
statisticalCache.setYearSelfInspections(statisticalService.getYearSelfCheck()); statisticalCache.setYearSelfInspections(statisticalService.getYearSelfCheck());
log.info("[统计分析模块]:更新统计分析缓存"); log.info("[统计分析模块]:更新统计分析缓存");
} }
if (bigScreenService!=null&&bigScreenCache!=null){
bigScreenCache.setBusinessNums(bigScreenService.getBusinessNum(2));
bigScreenCache.setCenterNum(bigScreenService.getCenterNum());
bigScreenCache.setDevNums(bigScreenService.getAllDeviceNum());
bigScreenCache.setRepairDevices(bigScreenService.getRepairDevices());
bigScreenCache.setRepairNum(bigScreenService.getRepairNum());
bigScreenCache.setSelfCheckNums(bigScreenService.getSelfCheckNum());
bigScreenCache.setUserDateScreens(bigScreenService.selectUserDataScreen());
log.info("[统计分析模块]:更新大屏缓存");
}
} }
} }
} }
package com.tykj.dev.statistical.controller;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.statistical.cache.BigScreenCache;
import com.tykj.dev.statistical.service.BigScreenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author dengdiyi
*/
@RestController
@Api(tags = "大屏模块", description = "统计相关接口")
@AutoDocument
@RequestMapping("/bigScreen")
public class BigScreenController {
@Autowired
private BigScreenService bigScreenService;
@Autowired
private BigScreenCache bigScreenCache;
/**
* 查询省及各市的装备数量
* @return 省及各市装备对象集合
*/
@ApiOperation(value = "查询省及各市的装备数量")
@GetMapping("/devNum")
public ResponseEntity selectDevNum(){
return ResponseEntity.ok(bigScreenCache.getDevNums());
}
@ApiOperation(value = "查询全省某业务每月数量统计")
@GetMapping("/businessNum/{businessType}")
public ResponseEntity selectbusinessNum(@PathVariable int businessType){
if (businessType==2) {
return ResponseEntity.ok(bigScreenCache.getBusinessNums());
}
else {
return ResponseEntity.ok(bigScreenService.getBusinessNum(businessType));
}
}
@ApiOperation(value = "查询大屏中心统计")
@GetMapping("/center")
public ResponseEntity selectCenterNum(){
return ResponseEntity.ok(bigScreenCache.getCenterNum());
}
@ApiOperation(value = "查询装备维修情况数量统计")
@GetMapping("/repairNum")
public ResponseEntity selectRepairNum(){
return ResponseEntity.ok(bigScreenCache.getRepairNum());
}
@ApiOperation(value = "查询装备维修情况装备统计")
@GetMapping("/repairDevice")
public ResponseEntity selectRepairDevice(){
return ResponseEntity.ok(bigScreenCache.getRepairDevices());
}
@ApiOperation(value = "查询最近一次自查统计")
@GetMapping("/selfCheck")
public ResponseEntity selectSelfCheck(){
return ResponseEntity.ok(bigScreenCache.getSelfCheckNums());
}
@ApiOperation(value = "查询专管员统计")
@GetMapping("/user")
public ResponseEntity selectUser(){
return ResponseEntity.ok(bigScreenCache.getUserDateScreens());
}
}
package com.tykj.dev.statistical.service;
import com.tykj.dev.statistical.vo.*;
import java.util.List;
/**
* @author dengdiyi
*/
public interface BigScreenService {
/**
* 获取省及各市装备统计信息
*/
List<DevNum> getAllDeviceNum();
/**
* 获取全省某业务每月数量统计
*/
List<BusinessNum> getBusinessNum(Integer businessType);
/**
* 获取大屏中心信息统计
*/
CenterNum getCenterNum();
/**
* 获取装备维修情况数量统计
*/
RepairNum getRepairNum();
/**
* 获取装备维修情况装备统计
*/
List<RepairDevice> getRepairDevices();
/**
* 获取最近一次自查统计
*/
List<SelfCheckNum> getSelfCheckNum();
/**
* 专管员统计
*/
List<UserDateScreen> selectUserDataScreen();
}
package com.tykj.dev.statistical.service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.repair.repository.RepairDetailDao;
import com.tykj.dev.device.repair.repository.RepairSendBillDao;
import com.tykj.dev.device.repair.service.RepairBillService;
import com.tykj.dev.device.repair.subject.domin.RepairDetail;
import com.tykj.dev.device.repair.subject.domin.RepairSendBill;
import com.tykj.dev.device.selfcheck.repository.SelfCheckBillDao;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.task.repository.TaskDao;
import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.subject.dao.AreaDao;
import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.dao.UserDao;
import com.tykj.dev.device.user.subject.entity.Area;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.misc.base.BusinessEnum;
import com.tykj.dev.statistical.cache.StatisticalCache;
import com.tykj.dev.statistical.service.BigScreenService;
import com.tykj.dev.statistical.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author dengdiyi
*/
@Service
@Slf4j
public class BigScreenServiceImpl implements BigScreenService {
@Autowired
private StatisticalCache statisticalCache;
@Autowired
private DeviceLibraryDao deviceLibraryDao;
@Autowired
private AreaDao areaDao;
@Autowired
private UnitsCache unitsCache;
@Autowired
private TaskDao taskDao;
@Autowired
private UnitsDao unitsDao;
@Autowired
private UserDao userDao;
@Autowired
private RepairSendBillDao repairSendBillDao;
@Autowired
private RepairBillService repairBillService;
@Autowired
private RepairDetailDao repairDetailDao;
@Autowired
private SelfCheckBillDao selfCheckBillDao;
/**
* 获取省及各市装备统计信息
*/
@Override
public List<DevNum> getAllDeviceNum() {
List<DevNum> devNumList = new ArrayList<>();
List<DevNum> devNums = new ArrayList<>(statisticalCache.getDevNums());
//获取所有装备
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAll();
//获取省本级
List<Area> areas = areaDao.findAreasByType(1);
//获取所有单位
List<Units> units = unitsCache.findAll();
//统计各市装备数量
for (Area area:areas) {
DevNum devNum = new DevNum();
devNum.setAreaName(area.getName());
//根据区域id找单位id集合
List<String> names = units.stream()
.filter(units1 -> area.getId().equals(units1.getAreaId()))
.map(Units::getName)
.collect(Collectors.toList());
//筛选出所属单位在id集合中的装备
List<DeviceLibrary> deviceLibraryList = deviceLibraries.stream()
.filter(deviceLibrary -> names.contains(deviceLibrary.getOwnUnit()))
.collect(Collectors.toList());
//获取装备总数量
devNum.setCount(deviceLibraryList.size());
devNumList.add(devNum);
}
devNumList.addAll(devNums);
return devNumList;
}
/**
* 获取全省某业务每月数量统计
*
* @param businessType
*/
@Override
public List<BusinessNum> getBusinessNum(Integer businessType) {
List<BusinessNum> businessNums = new ArrayList<>();
for (int i =1;i<13;i++){
BusinessNum businessNum = new BusinessNum();
businessNum.setMonth(i);
businessNums.add(businessNum);
}
List<Task> tasks = taskDao.findAllByBusinessType(businessType);
tasks.forEach(task -> {
if (isPresentYear(task.getCreateTime())) {
int month = getMonth(task.getCreateTime());
BusinessNum businessNum = businessNums.get(month - 1);
businessNum.setCount(businessNum.getCount() + 1);
}
});
return businessNums;
}
/**
* 获取大屏中心信息统计
*/
@Override
public CenterNum getCenterNum() {
CenterNum centerNum = new CenterNum();
//装备总数
centerNum.setDeviceCount(deviceLibraryDao.findAll().size());
//本年度业务总数
centerNum.setBusinessCount((int) taskDao.findAll().stream().filter(task -> isPresentYear(task.getCreateTime())).count());
//新增设备数
centerNum.setDeviceAddCount((int) deviceLibraryDao.findAll().stream().filter(deviceLibrary -> isPresentYear(deviceLibrary.getCreateTime())).count());
//故障率
double num = 0;
List<Task> tasks = taskDao.findAllByBusinessType(BusinessEnum.REPAIR.id).stream().filter(task -> task.getParentTaskId()==null).collect(Collectors.toList());
List<RepairSendBill> repairSendBills = tasks.stream()
.map(task -> repairBillService.getOne(task.getBillId()))
.map(repairBill -> repairSendBillDao.findByDeviceRepairBillId(repairBill.getId()))
.collect(Collectors.toList());
for (RepairSendBill r:repairSendBills) {
num+=r.getSendingCount();
}
double faultPercent = num/centerNum.getDeviceCount()*100;
centerNum.setFaultPercent(faultPercent);
return centerNum;
}
/**
* 获取装备维修情况数量统计
*/
@Override
public RepairNum getRepairNum() {
RepairNum repairNum = new RepairNum();
List<Task> tasks = taskDao.findAllByBusinessType(BusinessEnum.REPAIR.id).stream().filter(task -> task.getParentTaskId()==null).collect(Collectors.toList());
List<List<RepairDetail>> repairDetails = tasks.stream()
.map(task -> repairBillService.getOne(task.getBillId()))
.map(repairBill -> repairDetailDao.findByDeviceRepairBillId(repairBill.getId()))
.collect(Collectors.toList());
int repairCount = 0;
int completeCount = 0;
int changeNewCount = 0;
int noCompleteCount = 0;
for (List<RepairDetail> l:repairDetails) {
for (RepairDetail r:l) {
switch (r.getRepairStatus()){
case 0:
repairCount++;
noCompleteCount++;
break;
case 1:
repairCount++;
noCompleteCount++;
break;
case 2:
repairCount++;
completeCount++;
break;
case 4:
repairCount++;
if (r.getNewDeviceDetailId()!=null&&r.getNewDeviceDetailId()>0){
changeNewCount++;
}
else {
noCompleteCount++;
}
break;
case 5:
repairCount++;
completeCount++;
break;
default:break;
}
}
}
repairNum.setChangeNewCount(changeNewCount);
repairNum.setCompleteCount(completeCount);
repairNum.setNoCompleteCount(noCompleteCount);
repairNum.setRepairCount(repairCount);
return repairNum;
}
/**
* 获取装备维修情况装备统计
*/
@Override
public List<RepairDevice> getRepairDevices() {
List<RepairDevice> repairDevices = new ArrayList<>();
List<Task> tasks = taskDao.findAllByBusinessType(BusinessEnum.REPAIR.id).stream().filter(task -> task.getParentTaskId()==null).collect(Collectors.toList());
List<List<RepairDetail>> repairDetails = tasks.stream()
.map(task -> repairBillService.getOne(task.getBillId()))
.map(repairBill -> repairDetailDao.findByDeviceRepairBillId(repairBill.getId()))
.collect(Collectors.toList());
for (List<RepairDetail> l:repairDetails) {
for (RepairDetail r:l) {
RepairDevice repairDevice = new RepairDevice();
repairDevice.setLocationUnit(r.getLocationUnit());
repairDevice.setModel(r.getModel());
repairDevice.setType(r.getType());
switch (r.getRepairStatus()){
case 0:
repairDevice.setRepairStatus("未完成");
repairDevices.add(repairDevice);
break;
case 1:
repairDevice.setRepairStatus("未完成");
repairDevices.add(repairDevice);
break;
case 2:
repairDevice.setRepairStatus("完成");
repairDevices.add(repairDevice);
break;
case 4:
if (r.getNewDeviceDetailId()!=null&&r.getNewDeviceDetailId()>0){
repairDevice.setRepairStatus("已换新");
}
else {
repairDevice.setRepairStatus("未完成");
}
repairDevices.add(repairDevice);
break;
case 5:
repairDevice.setRepairStatus("完成");
repairDevices.add(repairDevice);
break;
default:break;
}
}
}
return repairDevices;
}
/**
* 获取最近一次自查统计
*/
@Override
public List<SelfCheckNum> getSelfCheckNum() {
List<SelfCheckNum> selfCheckNums = new ArrayList<>();
//获取所有自查单
List<SelfCheckBill> selfCheckBills = selfCheckBillDao.findAll();
//获取所有市
List<Area> areas = areaDao.findAreasByType(1);
//获取省
List<Area> areas2 = areaDao.findAreasByType(2);
areas.addAll(areas2);
//遍历市,找到最近完成的自查和核查账单
for (Area a:areas) {
SelfCheckNum selfCheckNum = new SelfCheckNum();
selfCheckNum.setAreaName(a.getName());
List<Units> units = unitsDao.findAllByAreaId(a.getId());
if (units.size()==1) {
//获取市单位名称
String unitName = units.get(0).getName();
//筛选出当前单位已完成的自查和核查账单,按更新时间排序
List<SelfCheckBill> selfCheckBillList = selfCheckBills.stream()
.filter(selfCheckBill -> selfCheckBill.getCheckUnit().equals(unitName))
.sorted(Comparator.comparing(SelfCheckBill::getUpdateTime).reversed())
.collect(Collectors.toList());
if (!selfCheckBillList.isEmpty()) {
SelfCheckBill s = selfCheckBillList.get(0);
if (s.getCheckStatus()!=3&&s.getCheckDetail()!=null) {
String[] strings = s.getCheckDetail().split("x");
for (String s1 : strings) {
if (s1.length() >= 2) {
//缺失
if ("0".equals(s1.substring(s1.length() - 1))) {
selfCheckNum.setLoseCount(selfCheckNum.getLoseCount() + 1);
}
//无误
if ("1".equals(s1.substring(s1.length() - 1))) {
selfCheckNum.setUnmistakableCount(selfCheckNum.getUnmistakableCount() + 1);
}
//新增
if ("2".equals(s1.substring(s1.length() - 1))) {
selfCheckNum.setUnRegisterCount(selfCheckNum.getUnRegisterCount() + 1);
}
}
}
}
else if(s.getCheckStatus()==3){
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("ownUnit", unitName);
predicateBuilder.eq("lifeStatus", 2);
selfCheckNum.setUnCheckCount(deviceLibraryDao.findAll(predicateBuilder.build()).size());
}
}
}
//总数
selfCheckNum.setSelfCheckCount(selfCheckNum.getUnCheckCount()+selfCheckNum.getLoseCount()+selfCheckNum.getUnmistakableCount()+selfCheckNum.getUnRegisterCount());
selfCheckNums.add(selfCheckNum);
}
return selfCheckNums;
}
/**
* 专管员统计
*/
@Override
public List<UserDateScreen> selectUserDataScreen() {
List<UserDateScreen> list=new ArrayList<>();
Map<Integer,UserDateScreen> map=new HashMap<>();
//获取所有市
List<Area> areas = areaDao.findAreasByType(2);
//获取省
List<Area> areas2 = areaDao.findAreasByType(1);
areas.addAll(areas2);
// List<Integer> areaIds = areas.stream().map(Area::getId).collect(Collectors.toList());
// List<Integer> levels=new ArrayList<>();
// levels.add(1);
// levels.add(2);
areas.forEach(area -> {
List<Integer> unitIds= unitsDao.findAllByAreaId(area.getId()).stream().map(Units::getUnitId).collect(Collectors.toList());
List<User> users= userDao.findAllByUnitsIdIn(unitIds);
if (users.size()>0) {
users.forEach(
user -> {
UserDateScreen userDateScreen = new UserDateScreen();
if (map.containsKey(area.getId())) {
userDateScreen = map.get(area.getId());
}
switch (user.getTrainStatus()) {
case 0:
userDateScreen.setHadBeenTraining(userDateScreen.getHadBeenTraining() + 1);
break;
case 1:
userDateScreen.setExpired(userDateScreen.getExpired() + 1);
break;
case 2:
userDateScreen.setNoTraining(userDateScreen.getNoTraining() + 1);
break;
case 3:
userDateScreen.setHadBeenTraining(userDateScreen.getHadBeenTraining() + 1);
break;
default:
log.info("[用户] 未找到对应的培训状态{}", user.getTrainStatus());
}
userDateScreen.setUnitName(area.getName());
map.put(area.getId(), userDateScreen);
}
);
}
else {
UserDateScreen userDateScreen = new UserDateScreen();
userDateScreen.setUnitName(area.getName());
map.put(area.getId(), userDateScreen);
}
});
for (Integer areaId:map.keySet()){
UserDateScreen userDateScreen=map.get(areaId);
list.add(userDateScreen);
}
return list;
}
private Integer getMonth(Date date){
return date.getMonth()+1;
}
private Boolean isPresentYear(Date date){
return new Date().getYear()==date.getYear();
}
}
...@@ -2,12 +2,8 @@ package com.tykj.dev.statistical.service.impl; ...@@ -2,12 +2,8 @@ package com.tykj.dev.statistical.service.impl;
import com.tykj.dev.device.confirmcheck.entity.cache.AreaCache; import com.tykj.dev.device.confirmcheck.entity.cache.AreaCache;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetail; import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetail;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckStat;
import com.tykj.dev.device.confirmcheck.entity.vo.CheckDeviceStatVo;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckDetailDao; import com.tykj.dev.device.confirmcheck.repository.DeviceCheckDetailDao;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckStatDao; import com.tykj.dev.device.confirmcheck.repository.DeviceCheckStatDao;
import com.tykj.dev.device.finalcheck.entity.domain.FinalReport;
import com.tykj.dev.device.finalcheck.repisotry.FinalReportDao;
import com.tykj.dev.device.library.repository.DeviceLibraryDao; import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary; import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.selfcheck.base.SelfCheckSchedulerTask; import com.tykj.dev.device.selfcheck.base.SelfCheckSchedulerTask;
...@@ -16,9 +12,8 @@ import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill; ...@@ -16,9 +12,8 @@ import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.task.service.TaskService; import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.vo.TaskSelectVo; import com.tykj.dev.device.task.subject.vo.TaskSelectVo;
import com.tykj.dev.device.task.subject.vo.TaskUserVo; import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.cache.UserCache;
import com.tykj.dev.device.user.base.ret.UserSituationVo; import com.tykj.dev.device.user.base.ret.UserSituationVo;
import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.subject.dao.AreaDao; import com.tykj.dev.device.user.subject.dao.AreaDao;
import com.tykj.dev.device.user.subject.dao.UnitsDao; import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.dao.UserDao; import com.tykj.dev.device.user.subject.dao.UserDao;
...@@ -26,8 +21,6 @@ import com.tykj.dev.device.user.subject.entity.Area; ...@@ -26,8 +21,6 @@ import com.tykj.dev.device.user.subject.entity.Area;
import com.tykj.dev.device.user.subject.entity.Units; import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.entity.User; import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.misc.exception.ApiException; import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.ResultUtil;
import com.tykj.dev.rfid.entity.domin.LibraryWarningLog; import com.tykj.dev.rfid.entity.domin.LibraryWarningLog;
import com.tykj.dev.rfid.repository.LibraryWarningLogDao; import com.tykj.dev.rfid.repository.LibraryWarningLogDao;
import com.tykj.dev.statistical.service.StatisticalService; import com.tykj.dev.statistical.service.StatisticalService;
...@@ -412,7 +405,7 @@ public class StatisticalServiceImpl implements StatisticalService { ...@@ -412,7 +405,7 @@ public class StatisticalServiceImpl implements StatisticalService {
int count= (int) userDao.count(); int count= (int) userDao.count();
int hasTraining= 0; int hasTraining= 0;
List<UserSituationVo> list=new ArrayList<>(); List<UserSituationVo> list=new ArrayList<>();
List<Integer> ids= userDao.findAll().stream().filter(user -> user.getTrainStatus() == 1 || user.getTrainStatus() == 2).map(User::getUserId).collect(Collectors.toList()); List<Integer> ids= userDao.findAll().stream().filter(user -> user.getTrainStatus()!=null&&(user.getTrainStatus() == 1 || user.getTrainStatus() == 2)).map(User::getUserId).collect(Collectors.toList());
hasTraining=count-ids.size(); hasTraining=count-ids.size();
userDao.findAllByUserIdIn(ids).forEach( userDao.findAllByUserIdIn(ids).forEach(
user -> { user -> {
......
package com.tykj.dev.statistical.vo; package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author zjm * @author zjm
* @version 1.0.0 * @version 1.0.0
...@@ -7,6 +11,9 @@ package com.tykj.dev.statistical.vo; ...@@ -7,6 +11,9 @@ package com.tykj.dev.statistical.vo;
* @Description 告警详情统计 * @Description 告警详情统计
* @createTime 2020年10月16日 10:38:00 * @createTime 2020年10月16日 10:38:00
*/ */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Alarm { public class Alarm {
/** /**
* 市 名称 * 市 名称
......
package com.tykj.dev.statistical.vo; package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author zjm * @author zjm
...@@ -10,6 +12,8 @@ import lombok.Data; ...@@ -10,6 +12,8 @@ import lombok.Data;
* @createTime 2020年10月16日 13:50:00 * @createTime 2020年10月16日 13:50:00
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class AlarmSituation { public class AlarmSituation {
/** /**
* 总数 * 总数
......
...@@ -2,6 +2,7 @@ package com.tykj.dev.statistical.vo; ...@@ -2,6 +2,7 @@ package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author zjm * @author zjm
...@@ -12,6 +13,7 @@ import lombok.Data; ...@@ -12,6 +13,7 @@ import lombok.Data;
*/ */
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor
public class BusinessSituation { public class BusinessSituation {
/** /**
* 配发 * 配发
......
package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author dengdiyi
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CenterNum {
/**
* 省装备数量统计
*/
private Integer deviceCount = 0;
/**
* 本年度业务处理总数
*/
private Integer businessCount = 0;
/**
* 设备故障率
*/
private double faultPercent = 0;
/**
* 本年度新增设备数
*/
private Integer deviceAddCount = 0;
}
package com.tykj.dev.statistical.vo; package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author dengdiyi * @author dengdiyi
* 区域最近一次自查和核查数量统计 * 区域最近一次自查和核查数量统计
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class Check { public class Check {
/** /**
* 市 名称 * 市 名称
......
package com.tykj.dev.statistical.vo; package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author zjm * @author zjm
...@@ -10,6 +12,8 @@ import lombok.Data; ...@@ -10,6 +12,8 @@ import lombok.Data;
* @createTime 2020年10月16日 09:55:00 * @createTime 2020年10月16日 09:55:00
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class DevLifeSector { public class DevLifeSector {
/** /**
* 市名称 * 市名称
......
package com.tykj.dev.statistical.vo; package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author zjm * @author zjm
...@@ -10,6 +12,8 @@ import lombok.Data; ...@@ -10,6 +12,8 @@ import lombok.Data;
* @createTime 2020年10月15日 10:35:00 * @createTime 2020年10月15日 10:35:00
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class DevNum { public class DevNum {
/** /**
* 区域名称 * 区域名称
......
package com.tykj.dev.statistical.vo; package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author zjm * @author zjm
* @version 1.0.0 * @version 1.0.0
...@@ -7,6 +11,9 @@ package com.tykj.dev.statistical.vo; ...@@ -7,6 +11,9 @@ package com.tykj.dev.statistical.vo;
* @Description 省扇形生命状态统计 * @Description 省扇形生命状态统计
* @createTime 2020年10月16日 09:55:00 * @createTime 2020年10月16日 09:55:00
*/ */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DevProvinceSector { public class DevProvinceSector {
/** /**
* 市名称 * 市名称
......
package com.tykj.dev.statistical.vo; package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List; import java.util.List;
...@@ -9,6 +11,8 @@ import java.util.List; ...@@ -9,6 +11,8 @@ import java.util.List;
* 年度中每季度自查统计 * 年度中每季度自查统计
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class PerQuarter { public class PerQuarter {
/** /**
......
package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author dengdiyi
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SelfCheckNum {
/**
* 市 名称
*/
private String areaName;
/**
* 自查数量
*/
private Integer selfCheckCount = 0;
/**
* 检查无误数量
*/
private Integer unmistakableCount = 0;
/**
* 未检查数量
*/
private Integer unCheckCount = 0;
/**
* 未登记数量
*/
private Integer unRegisterCount = 0;
/**
* 缺失数量
*/
private Integer loseCount = 0;
}
package com.tykj.dev.statistical.vo; package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author zjm * @author zjm
...@@ -10,6 +12,8 @@ import lombok.Data; ...@@ -10,6 +12,8 @@ import lombok.Data;
* @createTime 2020年10月16日 10:30:00 * @createTime 2020年10月16日 10:30:00
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class SelfInspection { public class SelfInspection {
/** /**
* 市 名称 * 市 名称
......
package com.tykj.dev.device.user.base.ret; package com.tykj.dev.statistical.vo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -19,9 +19,9 @@ import lombok.NoArgsConstructor; ...@@ -19,9 +19,9 @@ import lombok.NoArgsConstructor;
public class UserDateScreen { public class UserDateScreen {
private String unitName; private String unitName;
private Integer hadBeenTraining; private Integer hadBeenTraining = 0;
private Integer noTraining; private Integer noTraining = 0;
private Integer expired; private Integer expired = 0;
} }
package com.tykj.dev.statistical.vo; package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author zjm * @author zjm
...@@ -10,6 +12,8 @@ import lombok.Data; ...@@ -10,6 +12,8 @@ import lombok.Data;
* @createTime 2020年10月16日 10:30:00 * @createTime 2020年10月16日 10:30:00
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class Verification { public class Verification {
/** /**
* 市 名称 * 市 名称
......
package com.tykj.dev.statistical.vo; package com.tykj.dev.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author dengdiyi * @author dengdiyi
* 年度自查统计详情vo * 年度自查统计详情vo
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class YearSelfInspection { public class YearSelfInspection {
/** /**
......
...@@ -63,4 +63,6 @@ public interface TaskDao extends JpaRepository<Task, Integer>, JpaSpecificationE ...@@ -63,4 +63,6 @@ public interface TaskDao extends JpaRepository<Task, Integer>, JpaSpecificationE
Task findByBusinessTypeAndOwnUnitAndBillStatus(Integer type, Integer ownUnit, Integer billStatus); Task findByBusinessTypeAndOwnUnitAndBillStatus(Integer type, Integer ownUnit, Integer billStatus);
Task findByParentTaskIdAndAndTitle(Integer parentId, String title); Task findByParentTaskIdAndAndTitle(Integer parentId, String title);
List<Task> findAllByBusinessType(Integer businessType);
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论