Browse Source

#定时任务抽离

zhongwei
yang_shj 1 year ago
parent
commit
f2d89e306c
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java
  2. 15
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java
  3. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskServiceImpl.java
  4. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ShowService.java
  5. 104
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java
  6. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/CompanyServiceImpl.java
  7. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/InstanceServiceImpl.java
  8. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/MonthServiceImpl.java
  9. 4
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/TrialServiceImpl.java
  10. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkDelayServiceImpl.java
  11. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkPrincipalServiceImpl.java
  12. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java

@ -53,7 +53,7 @@ public interface MainConstants {
String REGIONAL_DUTY_INFO = "regionalDutyInfo";
// 区域设备分类统计
String DEVICE_CLASSIFY = "deviceClassify";
String LOAD_DEVICE_CLASSIFY = "deviceClassify";
// 区域月报
String AREA_MONTH_REPORT = "areaMonthReport";

15
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java

@ -11,8 +11,7 @@ import org.springframework.stereotype.Component;
import java.util.Date;
import static com.hnac.hzims.operational.main.constant.MainConstants.LOAD_HOME_TARGET;
import static com.hnac.hzims.operational.main.constant.MainConstants.REGIONAL_DUTY_INFO;
import static com.hnac.hzims.operational.main.constant.MainConstants.*;
/**
@ -48,4 +47,16 @@ public class ShowScheduledTask {
service.loadRegionalDuty(param);
return new ReturnT<>("SUCCESS");
}
/**
* 首页-区域设备分类统计
*/
@XxlJob(LOAD_DEVICE_CLASSIFY)
public ReturnT<String> loaddDeviceClassify(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
}
service.loaddDeviceClassify(param);
return new ReturnT<>("SUCCESS");
}
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskServiceImpl.java

@ -1,5 +1,6 @@
package com.hnac.hzims.scheduled.service.inspect.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hnac.hzims.scheduled.mapper.inspect.TaskMapper;
import com.hnac.hzims.scheduled.service.inspect.TaskService;
@ -21,6 +22,7 @@ import java.util.stream.Collectors;
@Service
@Slf4j
@AllArgsConstructor
@DS("inspect")
public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> implements TaskService {
/**

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ShowService.java

@ -8,4 +8,6 @@ public interface ShowService {
void loadHomeTarget(String param);
void loadRegionalDuty(String param);
void loaddDeviceClassify(String param);
}

104
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java

@ -1,14 +1,18 @@
package com.hnac.hzims.scheduled.service.operation.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.operational.access.constants.AccessConstants;
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity;
import com.hnac.hzims.operational.defect.constants.DefectConstant;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.duty.vo.DutyInfoVo;
import com.hnac.hzims.operational.duty.vo.DutyTaskVo;
import com.hnac.hzims.operational.duty.vo.NextDutyInfoVo;
@ -27,11 +31,9 @@ import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO;
import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseInstanceClient;
import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*;
import org.springblade.system.cache.DictCache;
@ -50,7 +52,6 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@ -100,7 +101,13 @@ public class ShowServiceImpl implements ShowService {
public String device_cache_cofig_final;
@Value("${hzims.operation.region.areaDutyInfoKey}")
private String area_duty_cofig_final;
private String area_duty_cache_final;
@Value("${hzims.operation.region.deviceClassifyKey}")
private String device_classify_cache_final;
@Value("${hzims.operation.realIdKey}")
public String real_cache_final;
/**
* 集团总指标-首页数据
@ -192,7 +199,7 @@ public class ShowServiceImpl implements ShowService {
this.dutyRunCondition(startDate,endDate,singlet,areaDutyVo);
areaDutyVoList.add(areaDutyVo);
});
redisTemplate.opsForValue().set(area_duty_cofig_final, areaDutyVoList);
redisTemplate.opsForValue().set(area_duty_cache_final, areaDutyVoList);
}
/**
@ -243,6 +250,55 @@ public class ShowServiceImpl implements ShowService {
return target;
}
/**
* 设备分类
*
* @param param
*/
@Override
public void loaddDeviceClassify(String param) {
// 获取所有设备
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
// 实时数据
String json = (String) redisTemplate.opsForValue().get(real_cache_final);
Map<String, String> realMap = null;
if (StringUtil.isNotBlank(json)) {
realMap = JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {});
}
Map<String,List<String>> deviceClassifyMap = new HashMap<>();
List<String> deviceCodeList = devices.stream().map(EminfoAndEmParamVo::getEmCode).collect(Collectors.toList());
// 故障
List<OperPhenomenonEntity> operPhenomenonEntityList = phenomenonService.list(new QueryWrapper<OperPhenomenonEntity>() {{
in("EM_CODE", deviceCodeList);
ne("IS_DEFECT", DefectConstant.IsDefectStatusEnum.IS_DEFECT.getStatus());
ne("CONCLUSION_STATUS", DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus());
}});
List<String> faultList = operPhenomenonEntityList.stream().map(OperPhenomenonEntity::getEmCode).distinct().collect(Collectors.toList());
deviceClassifyMap.put(HomePageConstant.FAULT,faultList);
// 检修
List<OperAccessTaskEntity> operAccessTaskEntityList = accessService.list(new QueryWrapper<OperAccessTaskEntity>() {{
in("EM_CODE", deviceCodeList);
ne("STATUS", AccessConstants.ACCESS_TASK_STATUS_4);
}});
List<String> overhaulList = operAccessTaskEntityList.stream().map(OperAccessTaskEntity::getEmCode).distinct().collect(Collectors.toList());
List<String> overhaulOldList = devices.stream().filter(o-> !faultList.contains(o.getEmCode()) && !overhaulList.contains(o.getEmCode()) && (Func.isNotEmpty(o.getRunStatus()) && EquipmentConstants.RunStatus.access.getStatus().equals(o.getRunStatus())))
.map(EminfoAndEmParamVo::getEmCode).collect(Collectors.toList());
overhaulList.addAll(overhaulOldList);
deviceClassifyMap.put(HomePageConstant.OVERHAUL,overhaulList);
// 运行
List<EminfoAndEmParamVo> runDeviceList = devices.stream().filter(o-> !faultList.contains(o.getEmCode()) && !overhaulList.contains(o.getEmCode())).distinct().collect(Collectors.toList());
List<String> runList = this.runDevice(runDeviceList,realMap);
deviceClassifyMap.put(HomePageConstant.RUN,runList);
// 备用
List<String> spareList = devices.stream().filter(o-> !faultList.contains(o.getEmCode()) && !overhaulList.contains(o.getEmCode()) && !runList.contains(o.getEmCode()) && Func.isNotEmpty(o.getRunStatus())
&& EquipmentConstants.RunStatus.spare.getStatus().equals(o.getRunStatus()))
.map(EminfoAndEmParamVo::getEmCode).distinct().collect(Collectors.toList());
deviceClassifyMap.put(HomePageConstant.SPARE,spareList);
redisTemplate.opsForValue().set(device_classify_cache_final, deviceClassifyMap);
}
/**
* 风电指标
* @return
@ -1127,9 +1183,9 @@ public class ShowServiceImpl implements ShowService {
/**
* 当班运行数据
* @param start
* @param end
* @param childList
* @param startTime
* @param endTime
* @param areas
* @param areaDutyVo
*/
private void dutyRunCondition(Date startTime, Date endTime, List<Long> areas,AreaDutyVo areaDutyVo) {
@ -1182,4 +1238,34 @@ public class ShowServiceImpl implements ShowService {
}
}
}
/**
* 获取运行设备列表
* @param runDeviceList
* @param realMap
* @return
*/
private List<String> runDevice(List<EminfoAndEmParamVo> runDeviceList, Map<String, String> realMap) {
return runDeviceList.stream().map(o ->{
Map<String,String> points = o.getPoint();
if(CollectionUtil.isEmpty(points)){
return "0";
}
String realId = points.get(HomePageConstant.JOINT_RELAY);
if(StringUtil.isEmpty(realId)){
return "0";
}
if(MapUtils.isEmpty(realMap)){
return "0";
}
String value = realMap.get(realId);
if(StringUtil.isEmpty(value)){
return "0";
}
if (value.contains("1") || "1.0".equals(value)) {
return o.getEmCode();
}
return "0";
}).distinct().collect(Collectors.toList());
}
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/CompanyServiceImpl.java

@ -1,5 +1,6 @@
package com.hnac.hzims.scheduled.service.safeproduct.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity;
import com.hnac.hzims.scheduled.mapper.safeproduct.CompanyMapper;
import com.hnac.hzims.scheduled.service.safeproduct.CompanyService;
@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
@Service
@AllArgsConstructor
@Slf4j
@DS("safeproduct")
public class CompanyServiceImpl extends BaseServiceImpl<CompanyMapper, CheckCompanyEntity> implements CompanyService {
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/InstanceServiceImpl.java

@ -1,5 +1,6 @@
package com.hnac.hzims.scheduled.service.safeproduct.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hnac.hzims.safeproduct.entity.CheckItemInstanceEntity;
import com.hnac.hzims.scheduled.mapper.safeproduct.InstanceMapper;
import com.hnac.hzims.scheduled.service.safeproduct.InstanceService;
@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
@Service
@AllArgsConstructor
@Slf4j
@DS("safeproduct")
public class InstanceServiceImpl extends BaseServiceImpl<InstanceMapper, CheckItemInstanceEntity> implements InstanceService {
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/MonthServiceImpl.java

@ -1,5 +1,6 @@
package com.hnac.hzims.scheduled.service.safeproduct.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity;
@ -29,6 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Service
@AllArgsConstructor
@Slf4j
@DS("safeproduct")
public class MonthServiceImpl extends BaseServiceImpl<MonthMapper, CheckMonthEntity> implements MonthService {
private final CompanyService companyService;

4
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/TrialServiceImpl.java

@ -1,11 +1,13 @@
package com.hnac.hzims.scheduled.service.safeproduct.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO;
import com.hnac.hzims.safeproduct.entity.SafeEquipmentTrialEntity;
import com.hnac.hzims.scheduled.mapper.safeproduct.TrialMapper;
import com.hnac.hzims.scheduled.service.safeproduct.TrialService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
@ -17,7 +19,9 @@ import java.util.Optional;
* @author ysj
*/
@Service
@Slf4j
@RequiredArgsConstructor
@DS("safeproduct")
public class TrialServiceImpl extends BaseServiceImpl<TrialMapper, SafeEquipmentTrialEntity> implements TrialService {
/**

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkDelayServiceImpl.java

@ -1,5 +1,6 @@
package com.hnac.hzims.scheduled.service.ticket.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hnac.hzims.scheduled.mapper.ticket.WorkDelayMapper;
import com.hnac.hzims.scheduled.service.ticket.WorkDelayService;
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketDelayEntity;
@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
@Service
@AllArgsConstructor
@Slf4j
@DS("ticket")
public class WorkDelayServiceImpl extends BaseServiceImpl<WorkDelayMapper, WorkTicketDelayEntity> implements WorkDelayService {
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkPrincipalServiceImpl.java

@ -1,5 +1,6 @@
package com.hnac.hzims.scheduled.service.ticket.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hnac.hzims.scheduled.mapper.ticket.WorkPrincipalMapper;
import com.hnac.hzims.scheduled.service.ticket.WorkPrincipalService;
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketPrincipalChangeEntity;
@ -15,6 +16,7 @@ import org.springframework.stereotype.Service;
@Service
@AllArgsConstructor
@Slf4j
@DS("ticket")
public class WorkPrincipalServiceImpl extends BaseServiceImpl<WorkPrincipalMapper, WorkTicketPrincipalChangeEntity> implements WorkPrincipalService {
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java

@ -195,7 +195,7 @@ public class ScheduledCreateTask {
* 首页-区域设备分类统计
* @return ReturnT<String>
*/
@XxlJob(DEVICE_CLASSIFY)
@XxlJob(LOAD_DEVICE_CLASSIFY)
//@Scheduled(cron = "0/10 * * * * ? ")
public ReturnT<String> deviceClassify(String param) throws Exception {
if (Func.isBlank(param)) {

Loading…
Cancel
Save