From d8c3a829ecfdeccc7f11e812634195a2f81067c0 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 1 Apr 2024 08:44:38 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=A3=80=E4=BF=AE=E5=BA=93bug=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduled/scheduled/AlarmScheduledTask.java | 12 +- .../scheduled/service/alarm/AlarmQueryService.java | 5 +- .../scheduled/service/alarm/AlarmService.java | 13 ++ .../service/alarm/InterruptionAlarmService.java | 2 +- .../service/alarm/impl/AlarmQueryServiceImpl.java | 117 +--------- .../service/alarm/impl/AlarmServiceImpl.java | 244 +++++++++++++++++++++ .../alarm/impl/InterruptionAlarmServiceImpl.java | 80 ------- .../inspect/task/service/impl/TaskServiceImpl.java | 51 ++++- .../service/impl/OperAccessLibraryServiceImpl.java | 5 + .../operational/main/dto/BusinessFileDto.java | 3 +- .../hnac/hzims/operational/main/dto/ScanDto.java | 3 +- .../main/service/impl/ScanServiceImpl.java | 162 ++------------ .../impl/OperMaintenanceTaskServiceImpl.java | 112 ++++++---- .../template/excel/access_import_template.xlsx | Bin 22528 -> 22528 bytes 14 files changed, 405 insertions(+), 404 deletions(-) create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmService.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java index b3e21d2..9310fda 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java @@ -1,6 +1,7 @@ package com.hnac.hzims.scheduled.scheduled; import com.hnac.hzims.scheduled.service.alarm.AlarmQueryService; +import com.hnac.hzims.scheduled.service.alarm.AlarmService; import com.hnac.hzims.scheduled.service.alarm.InterruptionAlarmService; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; @@ -25,10 +26,7 @@ import static com.hnac.hzims.operational.main.constant.MainConstants.*; public class AlarmScheduledTask { @Autowired - private AlarmQueryService alarmQueryService; - - @Autowired - private InterruptionAlarmService interruptionService; + private AlarmService alarmService; /** @@ -41,7 +39,7 @@ public class AlarmScheduledTask { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"); } - alarmQueryService.clearHistoryAlarm(param); + alarmService.clearHistoryAlarm(param); return new ReturnT<>("SUCCESS"); } @@ -55,7 +53,7 @@ public class AlarmScheduledTask { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } - alarmQueryService.startStopAlarm(param); + alarmService.startStopAlarm(param); return new ReturnT<>("SUCCESS"); } @@ -70,7 +68,7 @@ public class AlarmScheduledTask { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } - interruptionService.interruption(param); + alarmService.interruption(param); return new ReturnT<>("SUCCESS"); } } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java index cfd3520..40766e9 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java @@ -10,11 +10,10 @@ import java.util.List; */ public interface AlarmQueryService extends BaseService { - void startStopAlarm(String param); - - void clearHistoryAlarm(String param); + void clear(String param); List bells(List codes); List aborts(List codes); + } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmService.java new file mode 100644 index 0000000..bb58700 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmService.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.scheduled.service.alarm; + +/** + * @author ysj + */ +public interface AlarmService { + + void startStopAlarm(String param); + + void clearHistoryAlarm(String param); + + void interruption(String param); +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/InterruptionAlarmService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/InterruptionAlarmService.java index f239e5e..2222d1f 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/InterruptionAlarmService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/InterruptionAlarmService.java @@ -8,5 +8,5 @@ import org.springblade.core.mp.base.BaseService; */ public interface InterruptionAlarmService extends BaseService { - void interruption(String param); + } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java index f38975f..4f5dc86 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java @@ -34,127 +34,12 @@ import java.util.stream.Collectors; public class AlarmQueryServiceImpl extends BaseServiceImpl implements AlarmQueryService { - private final StationService stationService; - - private final RedisTemplate redisTemplate; - - private final static String start_stop_cache_final = "hzims:operation:start:stop:key"; - private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; - - /** - * 开停机告警 - * @param param - */ @Override - public void startStopAlarm(String param) { - // 获取站点开关机状态 - Map startStopMap = (HashMap) redisTemplate.opsForValue().get(start_stop_cache_final); - - // 查询接入水电站点 - List stations = stationService.list(new LambdaQueryWrapper() - .eq(StationEntity::getDataOrigin,0) - .eq(StationEntity::getType, HomePageConstant.HYDROPOWER) - ); - if(CollectionUtil.isEmpty(stations)){ - return; - } - - // 获取站点设备实时数据 - List reals = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); - if(CollectionUtil.isEmpty(reals)){ - return; - } - - Map refresh = new HashMap<>(); - // 实时设备遍历 - reals.forEach(real->{ - // 过滤站点 - List list = stations.stream().filter(item -> item.getRefDept().equals(real.getDeptId())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(list)){ - return; - } - // 确定站点 - StationEntity station = list.get(0); - - // 数据初始化记录 - if(CollectionUtil.isEmpty(startStopMap)){ - if(Math.abs(real.getActivePower()) > 0){ - refresh.put(real.getDeviceCode(),1); - }else{ - refresh.put(real.getDeviceCode(),0); - } - return; - } - // 比对开机状态 - if(Math.abs(real.getActivePower()) > 0){ - if(startStopMap.get(real.getDeviceCode()) == 0){ - refresh.put(real.getDeviceCode(),1); - // 记录开机告警 - this.saveStartStopAlarm(station,real,1); - }else{ - refresh.put(real.getDeviceCode(),0); - } - }else{ - if(startStopMap.get(real.getDeviceCode()) == 1){ - refresh.put(real.getDeviceCode(),0); - // 记录关机告警 - this.saveStartStopAlarm(station,real,0); - }else{ - refresh.put(real.getDeviceCode(),1); - } - } - }); - redisTemplate.opsForValue().set(start_stop_cache_final,refresh); - } - - /** - * 清理历史告警数据 - * @param param - */ - @Override - public void clearHistoryAlarm(String param) { + public void clear(String param) { this.baseMapper.clear(param); } /** - * 保存站点设备开关机告警 - * @param station - * @param real - * @param state - */ - private void saveStartStopAlarm(StationEntity station, HydropowerUnitRealVo real, int state) { - AlarmEntity alarm = new AlarmEntity(); - alarm.setStationId(station.getCode()); - alarm.setStationName(station.getName()); - alarm.setDeviceCode(real.getDeviceCode()); - alarm.setDeviceName(real.getDeviceName()); - alarm.setAlarmId(station.getCode() + "_" + Func.randomUUID()); - alarm.setAlarmContext(station.getName() + "_" + real.getDeviceName() + "_关机"); - alarm.setAlarmSource(AlarmConstants.START_STOP_WARNING); - alarm.setAlarmType(AlarmConstants.STOP); - if(state == 1){ - alarm.setAlarmType(AlarmConstants.START); - alarm.setAlarmContext(station.getName() + "_" + real.getDeviceName() + "_开机"); - } - alarm.setStatus(0); - alarm.setAlarmTime(new Date()); - alarm.setIsRightTabulation(0); - alarm.setIsShowAlert(1); - alarm.setIsSmallBell(1); - alarm.setIsMask(1); - alarm.setIsBroadcast(0); - alarm.setIsPlatformMessage(1); - alarm.setIsShortMessage(1); - alarm.setIsWxMessage(1); - alarm.setTenantId(station.getTenantId()); - alarm.setCreateDept(station.getRefDept()); - alarm.setCreateUser(station.getCreateUser()); - alarm.setUpdateUser(station.getUpdateUser()); - alarm.setUpdateTime(station.getUpdateTime()); - this.save(alarm); - } - - /** * 查询站点铃铛 * @param codes * @return diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java new file mode 100644 index 0000000..b74ee77 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java @@ -0,0 +1,244 @@ +package com.hnac.hzims.scheduled.service.alarm.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.alarm.config.constants.AlarmConstants; +import com.hnac.hzims.alarm.config.entity.AlarmEntity; +import com.hnac.hzims.business.interruption.constants.InterruptionConstants; +import com.hnac.hzims.business.interruption.entity.InterruptionEntity; +import com.hnac.hzims.operational.main.constant.HomePageConstant; +import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.scheduled.service.alarm.AlarmQueryService; +import com.hnac.hzims.scheduled.service.alarm.AlarmService; +import com.hnac.hzims.scheduled.service.operation.station.StationService; +import com.hnac.hzinfo.datasearch.soe.ISoeClient; +import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation; +import com.hnac.hzinfo.sdk.core.response.HzPage; +import com.hnac.hzinfo.sdk.core.response.Result; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@AllArgsConstructor +@Service +@Slf4j +public class AlarmServiceImpl implements AlarmService { + + private final StationService stationService; + + private final AlarmQueryService alarmQueryService; + + private final InterruptionAlarmServiceImpl interruptionAlarmService; + + private final ISoeClient soeClient; + + private final RedisTemplate redisTemplate; + + private final static String start_stop_cache_final = "hzims:operation:start:stop:key"; + private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; + + /** + * 开停机告警 + * @param param + */ + @Override + public void startStopAlarm(String param) { + // 获取站点开关机状态 + Map startStopMap = (HashMap) redisTemplate.opsForValue().get(start_stop_cache_final); + + // 查询接入水电站点 + List stations = stationService.list(new LambdaQueryWrapper() + .eq(StationEntity::getDataOrigin,0) + .eq(StationEntity::getType, HomePageConstant.HYDROPOWER) + ); + if(CollectionUtil.isEmpty(stations)){ + return; + } + + // 获取站点设备实时数据 + List reals = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); + if(CollectionUtil.isEmpty(reals)){ + return; + } + + Map refresh = new HashMap<>(); + // 实时设备遍历 + reals.forEach(real->{ + // 过滤站点 + List list = stations.stream().filter(item -> item.getRefDept().equals(real.getDeptId())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(list)){ + return; + } + // 确定站点 + StationEntity station = list.get(0); + + // 数据初始化记录 + if(CollectionUtil.isEmpty(startStopMap)){ + if(Math.abs(real.getActivePower()) > 0){ + refresh.put(real.getDeviceCode(),1); + }else{ + refresh.put(real.getDeviceCode(),0); + } + return; + } + // 比对开机状态 + if(Math.abs(real.getActivePower()) > 0){ + if(startStopMap.get(real.getDeviceCode()) == 0){ + refresh.put(real.getDeviceCode(),1); + // 记录开机告警 + this.saveStartStopAlarm(station,real,1); + }else{ + refresh.put(real.getDeviceCode(),0); + } + }else{ + if(startStopMap.get(real.getDeviceCode()) == 1){ + refresh.put(real.getDeviceCode(),0); + // 记录关机告警 + this.saveStartStopAlarm(station,real,0); + }else{ + refresh.put(real.getDeviceCode(),1); + } + } + }); + redisTemplate.opsForValue().set(start_stop_cache_final,refresh); + } + + /** + * 清理历史告警数据 + * @param param + */ + @Override + public void clearHistoryAlarm(String param) { + this.alarmQueryService.clear(param); + } + + /** + * 保存站点设备开关机告警 + * @param station + * @param real + * @param state + */ + private void saveStartStopAlarm(StationEntity station, HydropowerUnitRealVo real, int state) { + AlarmEntity alarm = new AlarmEntity(); + alarm.setStationId(station.getCode()); + alarm.setStationName(station.getName()); + alarm.setDeviceCode(real.getDeviceCode()); + alarm.setDeviceName(real.getDeviceName()); + alarm.setAlarmId(station.getCode() + "_" + Func.randomUUID()); + alarm.setAlarmContext(station.getName() + "_" + real.getDeviceName() + "_关机"); + alarm.setAlarmSource(AlarmConstants.START_STOP_WARNING); + alarm.setAlarmType(AlarmConstants.STOP); + if(state == 1){ + alarm.setAlarmType(AlarmConstants.START); + alarm.setAlarmContext(station.getName() + "_" + real.getDeviceName() + "_开机"); + } + alarm.setStatus(0); + alarm.setAlarmTime(new Date()); + alarm.setIsRightTabulation(0); + alarm.setIsShowAlert(1); + alarm.setIsSmallBell(1); + alarm.setIsMask(1); + alarm.setIsBroadcast(0); + alarm.setIsPlatformMessage(1); + alarm.setIsShortMessage(1); + alarm.setIsWxMessage(1); + alarm.setTenantId(station.getTenantId()); + alarm.setCreateDept(station.getRefDept()); + alarm.setCreateUser(station.getCreateUser()); + alarm.setUpdateUser(station.getUpdateUser()); + alarm.setUpdateTime(station.getUpdateTime()); + this.alarmQueryService.save(alarm); + } + + + /** + * 数据中断告警 + * @param param + */ + @Override + public void interruption(String param) { + // 查询接入站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getDataOrigin,"0") + ); + if(CollectionUtil.isEmpty(stations)){ + return; + } + // 查询告警数据: 间隔10分钟 + SoeQueryConditionByStation query = new SoeQueryConditionByStation(); + query.setTypes(InterruptionConstants.INTERRUPTION_TYPE); + query.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + Calendar calendar = Calendar.getInstance(); + query.setEndTime(LocalDateTime.parse(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER)); + calendar.add(Calendar.MINUTE,-360); + query.setBeginTime(LocalDateTime.parse(DateUtil.format(calendar.getTime() , DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER)); + query.setNeedPage(false); + query.setPage(1); + query.setLimit(1000); + Result> result = soeClient.getByStationsAndTime(query); + // 未查询到告警信息 + if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())) { + return; + } + // 中断告警数据 + List soes = result.getData().getRecords(); + // 查询当天数据中断告警记录 + List saves = this.saveInterruptions(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + // 批量保存中断告警数据 + this.interruptionAlarmService.saveBatch(soes.stream().filter(o-> CollectionUtil.isEmpty(saves) || !saves.stream().map(InterruptionEntity::getAlarmId).collect(Collectors.toList()).contains(o.getId())).map(soe->{ + InterruptionEntity entity = new InterruptionEntity(); + List soeStations = stations.stream().filter(o->o.getCode().equals(soe.getStation())).collect(Collectors.toList()); + if(!CollectionUtil.isEmpty(soeStations)){ + entity.setStationId(soeStations.get(0).getCode()); + entity.setStationName(soeStations.get(0).getName()); + entity.setCreateDept(soeStations.get(0).getRefDept()); + entity.setTenantId(soeStations.get(0).getTenantId()); + } + entity.setAlarmId(soe.getId()); + entity.setRealId(soe.getRealId()); + entity.setSoeExplain(soe.getSoeExplain()); + entity.setType(soe.getSoeType()); + entity.setAlarmTime(soe.getTs()); + entity.setStatus(0); + // 通讯中断恢复 + if(InterruptionConstants.ABNORMAL_STATUS.equals(soe.getSoeAlarmType())){ + entity.setStatus(1); + } + return entity; + }).collect(Collectors.toList())); + } + + + /** + * 查询当天数据中断告警记录 + * @param stations + * @return + */ + private List saveInterruptions(List stations) { + Calendar calendar = Calendar.getInstance(); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + return this.interruptionAlarmService.list(Wrappers.lambdaQuery() + .in(InterruptionEntity::getStationId,stations) + .ge(InterruptionEntity::getCreateTime,start) + .le(InterruptionEntity::getCreateTime,end) + ); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/InterruptionAlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/InterruptionAlarmServiceImpl.java index d49f4bf..ab32080 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/InterruptionAlarmServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/InterruptionAlarmServiceImpl.java @@ -36,85 +36,5 @@ import java.util.stream.Collectors; @DS("alarm") public class InterruptionAlarmServiceImpl extends BaseServiceImpl implements InterruptionAlarmService { - private final StationService stationService; - private final ISoeClient soeClient; - - /** - * 数据中断告警 - * @param param - */ - @Override - @Transactional(rollbackFor = Exception.class) - public void interruption(String param) { - // 查询接入站点 - List stations = stationService.list(Wrappers.lambdaQuery() - .eq(StationEntity::getDataOrigin,"0") - ); - if(CollectionUtil.isEmpty(stations)){ - return; - } - // 查询告警数据: 间隔10分钟 - SoeQueryConditionByStation query = new SoeQueryConditionByStation(); - query.setTypes(InterruptionConstants.INTERRUPTION_TYPE); - query.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); - Calendar calendar = Calendar.getInstance(); - query.setEndTime(LocalDateTime.parse(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER)); - calendar.add(Calendar.MINUTE,-10); - query.setBeginTime(LocalDateTime.parse(DateUtil.format(calendar.getTime() , DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER)); - query.setNeedPage(false); - query.setPage(1); - query.setLimit(1000); - Result> result = soeClient.getByStationsAndTime(query); - // 未查询到告警信息 - if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())) { - return; - } - // 中断告警数据 - List soes = result.getData().getRecords(); - // 查询当天数据中断告警记录 - List saves = this.saveInterruptions(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); - // 批量保存中断告警数据 - this.saveBatch(soes.stream().filter(o-> CollectionUtil.isEmpty(saves) || !saves.stream().map(InterruptionEntity::getAlarmId).collect(Collectors.toList()).contains(o.getId())).map(soe->{ - InterruptionEntity entity = new InterruptionEntity(); - List soeStations = stations.stream().filter(o->o.getCode().equals(soe.getStation())).collect(Collectors.toList()); - if(!CollectionUtil.isEmpty(soeStations)){ - entity.setStationId(soeStations.get(0).getCode()); - entity.setStationName(soeStations.get(0).getName()); - entity.setCreateDept(soeStations.get(0).getRefDept()); - entity.setTenantId(soeStations.get(0).getTenantId()); - } - entity.setAlarmId(soe.getId()); - entity.setRealId(soe.getRealId()); - entity.setSoeExplain(soe.getSoeExplain()); - entity.setType(soe.getSoeType()); - entity.setAlarmTime(soe.getTs()); - entity.setStatus(0); - // 通讯中断恢复 - if(InterruptionConstants.ABNORMAL_STATUS.equals(soe.getSoeAlarmType())){ - entity.setStatus(1); - } - return entity; - }).collect(Collectors.toList())); - } - - - /** - * 查询当天数据中断告警记录 - * @param stations - * @return - */ - private List saveInterruptions(List stations) { - Calendar calendar = Calendar.getInstance(); - String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); - calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); - calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); - calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); - String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); - return this.list(Wrappers.lambdaQuery() - .in(InterruptionEntity::getStationId,stations) - .ge(InterruptionEntity::getCreateTime,start) - .le(InterruptionEntity::getCreateTime,end) - ); - } } \ No newline at end of file diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java index e367429..cbd54f0 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java @@ -1,6 +1,7 @@ package com.hnac.hzinfo.inspect.task.service.impl; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.hnac.hzims.common.utils.Condition; +import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.safeproduct.Constants; import com.hnac.hzims.safeproduct.entity.ImsMonCameraInfoEntity; import com.hnac.hzims.safeproduct.feign.IImsMonCameraInfoClient; @@ -51,6 +53,7 @@ import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -60,6 +63,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -100,6 +104,9 @@ public class TaskServiceImpl extends BaseServiceImpl imp @Autowired private TaskNoUserDataScopeMapper taskNoUserDataScopeMapper; + @Autowired + private RedisTemplate redisTemplate; + /** * 正在调用开始任务的id集合 */ @@ -526,7 +533,37 @@ public class TaskServiceImpl extends BaseServiceImpl imp @Override public BladePage page(TaskDTO taskDTO) { - Query query = new Query(); + List inspects = (List) redisTemplate.opsForValue().get("inspect_list" + taskDTO.getCurrent() + taskDTO.getSize()); + Long total = (Long) redisTemplate.opsForValue().get("inspect_list_total"); + if(ObjectUtil.isEmpty(inspects) || ObjectUtil.isEmpty(total)){ + Query query=new Query(); + query.setSize(taskDTO.getSize()); + query.setCurrent(taskDTO.getCurrent()); + IPage pages = Condition.getPage(query); + List list = this.baseMapper.getAllPageList(pages,taskDTO); + List limit = list.stream().peek(taskVo -> { + // 获取机器人信息 + if (taskVo.getAutoVideo().equals(PlanContants.InspectTypeEnum.ROBOT.getVal()) ) { + if (Func.isNotEmpty( ObjectUtil.isNotEmpty(taskVo.getUserId()))) { + taskVo.setRobot(robotService.getDetailByUserId(taskVo.getUserId())); + } + } + }).collect(Collectors.toList()); + pages.setRecords(limit); + redisTemplate.opsForValue().set("inspect_list" + taskDTO.getCurrent() + taskDTO.getSize(),limit); + redisTemplate.expire("inspect_list" + taskDTO.getCurrent() + taskDTO.getSize(),30, TimeUnit.SECONDS); + redisTemplate.opsForValue().set("inspect_list_total",pages.getTotal()); + redisTemplate.expire("inspect_list_total",30, TimeUnit.SECONDS); + return BladePage.of(pages); + } + BladePage page = new BladePage(); + page.setRecords(inspects); + page.setCurrent(taskDTO.getCurrent()); + page.setSize(taskDTO.getSize()); + page.setTotal(total); + return page; + + /* Query query = new Query(); query.setSize(taskDTO.getSize()); query.setCurrent(taskDTO.getCurrent()); IPage pages = Condition.getPage(query); @@ -547,7 +584,7 @@ public class TaskServiceImpl extends BaseServiceImpl imp }).collect(Collectors.toList()); pages.setRecords(list); BladePage bladePage = BladePage.of(pages); - return bladePage; + return bladePage;*/ } private void getQueryWrapper(TaskDTO taskDTO, LambdaQueryWrapper queryWrapper) { @@ -604,7 +641,7 @@ public class TaskServiceImpl extends BaseServiceImpl imp @Override public List getListPageAuth(IPage page, TaskListQuery task) { List re = this.baseMapper.getListPageAuth(page, task); - setVoInfo(re); + setVoInfo(re); return re; } @@ -1007,9 +1044,9 @@ public class TaskServiceImpl extends BaseServiceImpl imp } else { queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptIds); } - queryWrapper.ge(ObjectUtils.isNotNull(startTime), "CREATE_TIME",startTime); - queryWrapper.le(ObjectUtils.isNotNull(endTime), "CREATE_TIME",endTime); - taskEntities= baseMapper.selectList(queryWrapper); + queryWrapper.ge(ObjectUtils.isNotNull(startTime), "CREATE_TIME",startTime); + queryWrapper.le(ObjectUtils.isNotNull(endTime), "CREATE_TIME",endTime); + taskEntities= baseMapper.selectList(queryWrapper); List res=new ArrayList<>(); if (CollectionUtil.isNotEmpty(taskEntities)) { VoteChartVo all = getVoteChartVo(taskEntities); @@ -1035,7 +1072,7 @@ public class TaskServiceImpl extends BaseServiceImpl imp List taskEntities = super.baseMapper.getAllExportList(task); List list=new ArrayList<>(); if (CollectionUtils.isNotEmpty(taskEntities)){ - list=taskEntities.parallelStream().map(taskVo -> { + list=taskEntities.parallelStream().map(taskVo -> { InspectTaskExportVO resEntity=new InspectTaskExportVO(); try { if (ObjectUtil.isNotEmpty(taskVo.getCreateDept())) { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java index 5c38cab..9033366 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java @@ -22,6 +22,7 @@ import com.hnac.hzims.operational.util.PdfUtils; import com.hnac.hzims.safeproduct.feign.IDangerSourceClient; import org.apache.commons.lang.StringUtils; import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; @@ -187,6 +188,7 @@ public class OperAccessLibraryServiceImpl extends BaseServiceImpl operPhenomenonEntityList; + private List operPhenomenonEntityList; @ApiModelProperty(value = "日常维护") private List operMaintenanceTaskEntityList; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/dto/ScanDto.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/dto/ScanDto.java index e4ecadb..a3a937c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/dto/ScanDto.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/dto/ScanDto.java @@ -3,6 +3,7 @@ package com.hnac.hzims.operational.main.dto; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; import com.hnac.hzims.operational.defect.entity.OperDefectEntity; +import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import io.swagger.annotations.ApiModelProperty; @@ -30,7 +31,7 @@ public class ScanDto { private int emInfoEntityCount; @ApiModelProperty(value = "消缺单") - private List operDefectEntityList; + private List operDefectEntityList; @ApiModelProperty(value = "日常维护") private List operMaintenanceTaskEntityList; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/ScanServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/ScanServiceImpl.java index 2a438a7..3d03224 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/ScanServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/ScanServiceImpl.java @@ -4,37 +4,27 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.monitor.feign.IMonitorClient; -import com.hnac.hzims.operational.access.constants.AccessConstants; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; import com.hnac.hzims.operational.access.service.IOperAccessTaskService; -import com.hnac.hzims.operational.defect.constants.DefectConstant; -import com.hnac.hzims.operational.defect.entity.OperDefectEntity; import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.defect.service.IOperDefectService; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; -import com.hnac.hzims.operational.duty.vo.MainOperPhenomenonVo; import com.hnac.hzims.operational.main.dto.BusinessFileDto; import com.hnac.hzims.operational.main.dto.ScanDto; import com.hnac.hzims.operational.main.service.IScanService; -import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.support.BladePage; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.flow.core.feign.IFlowClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.Date; import java.util.List; -import java.util.Map; @Service @Slf4j @@ -59,16 +49,12 @@ public class ScanServiceImpl implements IScanService { @Override public ScanDto getData(String emCode) { - ScanDto scanDto = new ScanDto(); //日常维护任务 List maintenanceTaskEntityList = maintenanceTaskService.list(new LambdaQueryWrapper() {{ - and(o -> o.eq(OperMaintenanceTaskEntity::getStatus, MaintenanceConstant.TASK_STATUS_1). - or().eq(OperMaintenanceTaskEntity::getStatus, MaintenanceConstant.TASK_STATUS_2). - or().eq(OperMaintenanceTaskEntity::getStatus, MaintenanceConstant.TASK_STATUS_3). - or().eq(OperMaintenanceTaskEntity::getStatus, MaintenanceConstant.TASK_STATUS_4)); + eq(OperMaintenanceTaskEntity::getEmCode, emCode); + ne(OperMaintenanceTaskEntity::getFlowTaskName,"结束"); orderByDesc(OperMaintenanceTaskEntity::getCreateTime); - eq(OperMaintenanceTaskEntity::getEmCode,emCode); }}); if(CollectionUtil.isNotEmpty(maintenanceTaskEntityList)){ scanDto.setOperMaintenanceTaskEntityCount(maintenanceTaskEntityList.size()); @@ -76,130 +62,25 @@ public class ScanServiceImpl implements IScanService { } //检修任务 List accessTaskEntityList = accessTaskService.list(new LambdaQueryWrapper() {{ - and(o -> o.eq(OperAccessTaskEntity::getStatus, AccessConstants.ACCESS_TASK_STATUS_1). - or().eq(OperAccessTaskEntity::getStatus, AccessConstants.ACCESS_TASK_STATUS_2). - or().eq(OperAccessTaskEntity::getStatus, AccessConstants.ACCESS_TASK_STATUS_3)); + eq(OperAccessTaskEntity::getEmCode, emCode); + ne(OperAccessTaskEntity::getStatus, 4); orderByDesc(OperAccessTaskEntity::getCreateTime); - eq(OperAccessTaskEntity::getEmCode,emCode); }}); if(CollectionUtil.isNotEmpty(maintenanceTaskEntityList)){ scanDto.setOperAccessTaskEntityCount(accessTaskEntityList.size()); scanDto.setOperAccessTaskEntityList(accessTaskEntityList); } //消缺单 - List defectList = defectService.getDefectByEmCodeList(emCode); - if (CollectionUtil.isNotEmpty(defectList)) { - scanDto.setOperDefectEntityCount(defectList.size()); - scanDto.setOperDefectEntityList(defectList); - } - - - /*List defectList = new ArrayList<>(); - List maintenanceList = new ArrayList<>(); - List accesss = new ArrayList<>(); - Date date = new Date(); - log.info("--------------------开始时间--------:"+ DateUtil.format(date,DateUtil.PATTERN_DATETIME)); - R defectAll = flowClient.todoList(CATEGORY_ID, null, 1, 9999); - if (defectAll.isSuccess()) { - BladePage data = defectAll.getData(); - if (ObjectUtil.isNotEmpty(data) && CollectionUtil.isNotEmpty(data.getRecords())) { - List records = defectAll.getData().getRecords(); - for (Map defect : records) { - if (defect.get("processDefinitionName").equals("巡检问题处理流程")) { - defectList.add(defect.get("businessId").toString()); - } else if (defect.get("processDefinitionName").equals("日常维护流程")) { - maintenanceList.add(defect.get("businessId").toString()); - } else if (defect.get("processDefinitionName").equals("检修任务执行流程")) { - accesss.add(defect.get("businessId").toString()); - } - } - } - } - - //消缺单 - if (CollectionUtil.isNotEmpty(defectList)) { - List defectList1 = defectService.getDefectList(emCode, defectList); - if (CollectionUtil.isNotEmpty(defectList1)) { - scanDto.setOperDefectEntityCount(defectList1.size()); - scanDto.setOperDefectEntityList(defectList1); - } - } - - //日常维护任务 - if (CollectionUtil.isNotEmpty(maintenanceList)) { - List operMaintenanceTaskEntities = maintenanceTaskService.getByEmCode(emCode, maintenanceList); - if (CollectionUtil.isNotEmpty(operMaintenanceTaskEntities)) { - scanDto.setOperMaintenanceTaskEntityCount(operMaintenanceTaskEntities.size()); - scanDto.setOperMaintenanceTaskEntityList(operMaintenanceTaskEntities); - } - } - - //检修任务 - if (CollectionUtil.isNotEmpty(accesss)) { - List operAccessTaskEntities = accessTaskService.getByEmCode(emCode, accesss); - if (CollectionUtil.isNotEmpty(operAccessTaskEntities)) { - scanDto.setOperAccessTaskEntityCount(operAccessTaskEntities.size()); - scanDto.setOperAccessTaskEntityList(operAccessTaskEntities); - } - }*/ - - /*//消缺单 - R defectBladePageR = flowClient.todoList(CATEGORY_ID, "巡检问题处理流程", 1, 999); - log.info("defectBladePageR--------------------:" + defectBladePageR); - if (defectBladePageR.isSuccess()) { - List defects = defectBladePageR.getData().getRecords(); - if (CollectionUtil.isNotEmpty(defects)) { - for (Map defect : defects) { - defectList.add(defect.get("businessId").toString()); - } - if (CollectionUtil.isNotEmpty(defectList)) { - List defectList1 = defectService.getDefectList(emCode, defectList); - if (CollectionUtil.isNotEmpty(defectList1)) { - scanDto.setOperDefectEntityCount(defectList1.size()); - scanDto.setOperDefectEntityList(defectList1); - } - } - } - } - - - //日常维护任务 - R maintenanceBladePageR = flowClient.todoList(CATEGORY_ID, "日常维护流程", 1, 999); - List maintenances = maintenanceBladePageR.getData().getRecords(); - - if (CollectionUtil.isNotEmpty(maintenances)) { - for (Map maintenance : maintenances) { - log.info("------------------待办--------------------" + maintenance.get("businessId").toString()); - maintenanceList.add(maintenance.get("businessId").toString()); - } - if (CollectionUtil.isNotEmpty(maintenanceList)) { - List operMaintenanceTaskEntities = maintenanceTaskService.getByEmCode(emCode, maintenanceList); - if (CollectionUtil.isNotEmpty(operMaintenanceTaskEntities)) { - scanDto.setOperMaintenanceTaskEntityCount(operMaintenanceTaskEntities.size()); - scanDto.setOperMaintenanceTaskEntityList(operMaintenanceTaskEntities); - } - } + List phenomenons = phenomenonService.list(new LambdaQueryWrapper(){{ + eq(OperPhenomenonEntity::getEmCode,emCode); + isNull(OperPhenomenonEntity::getHandleTaskId); + orderByDesc(OperPhenomenonEntity::getCreateTime); + }}); + if (CollectionUtil.isNotEmpty(phenomenons)) { + scanDto.setOperDefectEntityCount(phenomenons.size()); + scanDto.setOperDefectEntityList(phenomenons); } - - - //检修任务 - R accessBladePageR = flowClient.todoList(CATEGORY_ID, "检修任务执行流程", 1, 999); - List records = accessBladePageR.getData().getRecords(); - if (CollectionUtil.isNotEmpty(records)) { - for (Map record : records) { - log.info("------------------待办--------------------" + record.get("businessId").toString()); - accesss.add(record.get("businessId").toString()); - } - if (CollectionUtil.isNotEmpty(accesss)) { - List operAccessTaskEntities = accessTaskService.getByEmCode(emCode, accesss); - if (CollectionUtil.isNotEmpty(operAccessTaskEntities)) { - scanDto.setOperAccessTaskEntityCount(operAccessTaskEntities.size()); - scanDto.setOperAccessTaskEntityList(operAccessTaskEntities); - } - } - }*/ return scanDto; - } @Override public ScanDto getRealDataTimeAndDeviceFile(String emCode){ @@ -233,7 +114,7 @@ public class ScanServiceImpl implements IScanService { //日常维护任务 List list = maintenanceTaskService.list(new LambdaQueryWrapper() {{ eq(OperMaintenanceTaskEntity::getEmCode, emCode); - eq(OperMaintenanceTaskEntity::getStatus, 5); + eq(OperMaintenanceTaskEntity::getFlowTaskName, "结束"); }}); if (CollectionUtil.isNotEmpty(list)) { dto.setOperMaintenanceTaskEntityCount(list.size()); @@ -249,15 +130,14 @@ public class ScanServiceImpl implements IScanService { dto.setOperAccessTaskEntityList(list1); } //消缺单 - /*List list2 = phenomenonService.list(new LambdaQueryWrapper() {{ - eq(OperPhenomenonEntity::getEmCode, emCode); - eq(OperPhenomenonEntity::getConclusionStatus, 1); - }});*/ - - List listByStatus = phenomenonService.getListByStatus(emCode, DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()); - if (CollectionUtil.isNotEmpty(listByStatus)) { - dto.setOperPhenomenonEntityCount(listByStatus.size()); - dto.setOperPhenomenonEntityList(listByStatus); + List phenomenons = phenomenonService.list(new LambdaQueryWrapper(){{ + eq(OperPhenomenonEntity::getEmCode,emCode); + isNotNull(OperPhenomenonEntity::getHandleTaskId); + orderByDesc(OperPhenomenonEntity::getCreateTime); + }}); + if (CollectionUtil.isNotEmpty(phenomenons)) { + dto.setOperPhenomenonEntityList(phenomenons); + dto.setOperPhenomenonEntityCount(phenomenons.size()); } return dto; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java index ded403b..ec492c9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java @@ -54,6 +54,7 @@ import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.BeanUtils; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -64,6 +65,7 @@ import java.text.DecimalFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -85,6 +87,8 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl> list(OperMaintenanceTaskDTO req) { + List tasks = (List) redisTemplate.opsForValue().get("main_list" + req.getCurrent() + req.getSize()); + Long total = (Long) redisTemplate.opsForValue().get("main_list_total"); + if(ObjectUtil.isEmpty(tasks) || ObjectUtil.isEmpty(total)){ + Query query=new Query(); + query.setSize(req.getSize()); + query.setCurrent(req.getCurrent()); + Wrapper queryWrapper = getQueryWrapper(req); + IPage pages = super.page(Condition.getPage(query), queryWrapper); + List list = OperMaintenanceTaskWrapper.build().listVO(pages.getRecords()); + pages.setRecords(list); + redisTemplate.opsForValue().set("main_list" + req.getCurrent() + req.getSize() , list); + redisTemplate.expire("main_list" + req.getCurrent() + req.getSize(),30, TimeUnit.SECONDS); + redisTemplate.opsForValue().set("main_list_total" , pages.getTotal()); + redisTemplate.expire("main_list_total",30, TimeUnit.SECONDS); + return R.data(pages); + } Query query=new Query(); query.setSize(req.getSize()); query.setCurrent(req.getCurrent()); - Wrapper queryWrapper = getQueryWrapper(req); - IPage pages = super.page(Condition.getPage(query), queryWrapper); - pages.setRecords(OperMaintenanceTaskWrapper.build().listVO(pages.getRecords())); + IPage pages = Condition.getPage(query); + pages.setTotal(total); + pages.setRecords(tasks); return R.data(pages); } @@ -275,7 +295,7 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl immatureTask = v.stream().filter(o -> MaintenanceConstant.TASK_STATUS_5 != o.getStatus()).collect(Collectors.toList()); if (CollectionUtil.isNotEmpty(immatureTask)){ - Map> immatureTaskTaskGroupByType = immatureTask.stream().collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getTypeCode)); + Map> immatureTaskTaskGroupByType = immatureTask.stream().collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getTypeCode)); // AtomicReference immatureTaskSituation = new AtomicReference<>(""); - immatureTaskTaskGroupByType.forEach((TypeCode, TypeList) -> { - finishSituation.set(finishSituation.get().concat(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, TypeCode)).concat(":").concat(TypeList.size() + "").concat("\r\n")); - }); - maintenanceReportVO.setIncompleteNum(immatureTask.size()); - maintenanceReportVO.setIncompleteList(immatureTask.stream().map(s->String.valueOf(s.getId())).collect(Collectors.toList())); - maintenanceReportVO.setRemark(finishSituation.get()); + immatureTaskTaskGroupByType.forEach((TypeCode, TypeList) -> { + finishSituation.set(finishSituation.get().concat(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, TypeCode)).concat(":").concat(TypeList.size() + "").concat("\r\n")); + }); + maintenanceReportVO.setIncompleteNum(immatureTask.size()); + maintenanceReportVO.setIncompleteList(immatureTask.stream().map(s->String.valueOf(s.getId())).collect(Collectors.toList())); + maintenanceReportVO.setRemark(finishSituation.get()); } } @@ -588,44 +608,44 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl { MaintenanceExportVO resEntity=new MaintenanceExportVO(); try { - if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getCreateDept())){ - R dept = sysClient.getDept(maintenanceTaskVO.getCreateDept()); - if (dept.isSuccess()&&ObjectUtil.isNotEmpty(dept.getData())){ - resEntity.setCompany(Optional.ofNullable(dept.getData().getDeptName()).orElse("")); - } - } - resEntity.setTypeCode(Optional.ofNullable(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, maintenanceTaskVO.getTypeCode())).orElse("")); - if (StringUtil.isNotBlank(maintenanceTaskVO.getEmCode())){ - EmInfoEntity emInfoEntity = emInfoClient.getByCode(maintenanceTaskVO.getEmCode()); - if (ObjectUtil.isNotEmpty(emInfoEntity)&&StringUtil.isNotBlank(emInfoEntity.getName())){ - resEntity.setRefLibraryId(emInfoEntity.getName()); - }else { - resEntity.setRefLibraryId(maintenanceTaskVO.getEmCode()); + if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getCreateDept())){ + R dept = sysClient.getDept(maintenanceTaskVO.getCreateDept()); + if (dept.isSuccess()&&ObjectUtil.isNotEmpty(dept.getData())){ + resEntity.setCompany(Optional.ofNullable(dept.getData().getDeptName()).orElse("")); + } } - } - resEntity.setTitle(Optional.ofNullable( maintenanceTaskVO.getContent()).orElse("")); - if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getPlanEndTime())) { - resEntity.setPlanEndTime(Optional.ofNullable(DateUtil.format(maintenanceTaskVO.getPlanEndTime(), TicketConstants.TICKET_DATE_PATTERN)).orElse("")); - } - if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getDisposeTime())) { - resEntity.setExecuteTime(Optional.ofNullable(DateUtil.format(maintenanceTaskVO.getDisposeTime(), TicketConstants.TICKET_DATE_PATTERN)).orElse("")); - } - if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getDisposer())) { - String disposerName = Optional.ofNullable(maintenanceTaskVO.getDisposer()).map(s->{ - List disposerList = Arrays.stream(s.split(",")).collect(Collectors.toList()); - return disposerList.stream().map(d ->{ - User user = UserCache.getUser(Long.parseLong(d)); - return Optional.ofNullable(user).map(User::getName).orElse(""); - }).collect(Collectors.joining(",")); - }).orElse(""); - if (StringUtil.isNotBlank(disposerName)) { - resEntity.setDisposer(disposerName); + resEntity.setTypeCode(Optional.ofNullable(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, maintenanceTaskVO.getTypeCode())).orElse("")); + if (StringUtil.isNotBlank(maintenanceTaskVO.getEmCode())){ + EmInfoEntity emInfoEntity = emInfoClient.getByCode(maintenanceTaskVO.getEmCode()); + if (ObjectUtil.isNotEmpty(emInfoEntity)&&StringUtil.isNotBlank(emInfoEntity.getName())){ + resEntity.setRefLibraryId(emInfoEntity.getName()); + }else { + resEntity.setRefLibraryId(maintenanceTaskVO.getEmCode()); + } + } + resEntity.setTitle(Optional.ofNullable( maintenanceTaskVO.getContent()).orElse("")); + if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getPlanEndTime())) { + resEntity.setPlanEndTime(Optional.ofNullable(DateUtil.format(maintenanceTaskVO.getPlanEndTime(), TicketConstants.TICKET_DATE_PATTERN)).orElse("")); + } + if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getDisposeTime())) { + resEntity.setExecuteTime(Optional.ofNullable(DateUtil.format(maintenanceTaskVO.getDisposeTime(), TicketConstants.TICKET_DATE_PATTERN)).orElse("")); + } + if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getDisposer())) { + String disposerName = Optional.ofNullable(maintenanceTaskVO.getDisposer()).map(s->{ + List disposerList = Arrays.stream(s.split(",")).collect(Collectors.toList()); + return disposerList.stream().map(d ->{ + User user = UserCache.getUser(Long.parseLong(d)); + return Optional.ofNullable(user).map(User::getName).orElse(""); + }).collect(Collectors.joining(",")); + }).orElse(""); + if (StringUtil.isNotBlank(disposerName)) { + resEntity.setDisposer(disposerName); + } } - } // resEntity.setDisposer(Optional.ofNullable(maintenanceTaskVO.getDisposerName()).orElse("")); - resEntity.setPrincipal(Optional.ofNullable(maintenanceTaskVO.getWorkStandards()).orElse("")); - return resEntity; - }catch (Exception e){ + resEntity.setPrincipal(Optional.ofNullable(maintenanceTaskVO.getWorkStandards()).orElse("")); + return resEntity; + }catch (Exception e){ log.error("日常维护导出失败---》param"+maintenanceTaskVO+"报错信息:"+e.getStackTrace()); return resEntity; } diff --git a/hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx b/hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx index 737bd1e311181161cdba4d12435aff02aeaedc40..b6292cb02cec4e1dcb1bf023c662f0ea8acbc36c 100644 GIT binary patch delta 548 zcmZqJz}T>XaYHT(%jWc}^ClOvv@?F0{F9}gan|NaRz?9v_Q}bj`jc0QN&vCT!q97#DsL1bZsX~IbCO*G5M2|F{9~bHRqSiwr&iJOl%BHKF10~b&g8-oWBvIBWy49t@!ct}nzbk||@o;=Up+uVo22P(tPzyQ>NfZhz= zP#F$PnaK(s;>kRM>fn%OYGTh^E2| z=&~YDZ)TtwlMi@`yCYPJps7U2h+>tw&S1b0#md02gi(#5V6vW<_+(oz4j?w?<7eOm z>R@Ex2SQHH%}riW%$xkgnAr1}f~F--_1!ERV8S%nGf0{Dz<-~4?2HTy4h?_)%TF#0 VvY&h)XeP^l?yK`Q#|AHE0RZIQZq5Jz delta 437 zcmZqJz}T>XaYHT(OSX!o_~b&CcE$^nf3nmwc5SX?WfYh^NmOF;Eg)V6rgbLEi3zcJ zGjtne