初次提交
This commit is contained in:
@ -0,0 +1,28 @@
|
||||
package com.ho.flow;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
/**
|
||||
* @author fancl
|
||||
* @desc: 工作流配置启动
|
||||
* @date 2023/1/2
|
||||
*/
|
||||
@SpringBootApplication(scanBasePackages = {"com.ho.common.tools" ,"com.ho.flow","com.ho.business"}
|
||||
,exclude = {SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class}
|
||||
)
|
||||
@MapperScan(basePackages = {"com.ho.flow.mapper","com.ho.business.mapper"})
|
||||
@EnableFeignClients(basePackages = {"com.ho.flow.feignclient"})
|
||||
@EnableAsync //开启异步
|
||||
@EnableCaching
|
||||
public class FlowApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(FlowApplication.class, args);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,191 @@
|
||||
package com.ho.flow.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ho.common.tools.annotation.LargeScreenToken;
|
||||
import com.ho.common.tools.annotation.LogAnnotation;
|
||||
import com.ho.common.tools.annotation.TokenIgnore;
|
||||
import com.ho.common.tools.constant.CommonConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
import com.ho.common.tools.entity.UserDetailRespVO;
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.BusinessException;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.IPUtils;
|
||||
import com.ho.user.api.entity.SysLog;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 业务模块切面
|
||||
* 目前实现日志和token校验
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
@Slf4j
|
||||
public class BusinessAspect {
|
||||
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
SaveLogComponent saveLogComponent;
|
||||
|
||||
/**
|
||||
* 此处的切点是注解的方式
|
||||
* 只要出现 @LogAnnotation注解都会进入
|
||||
* 改为切入点是controller,不然日志记录不清晰,只有LogAnnotation才入库
|
||||
*/
|
||||
//@Pointcut("@annotation(com.ho.common.tools.annotation.LogAnnotation)")
|
||||
@Pointcut("execution(* com.ho.*.controller.*.*(..))")
|
||||
public void pointCut() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 环绕增强,相当于MethodInterceptor
|
||||
*
|
||||
* @param point
|
||||
* @return
|
||||
* @throws Throwable
|
||||
*/
|
||||
@Around("pointCut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
long beginTime = System.currentTimeMillis();
|
||||
ServletRequestAttributes servletAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = servletAttributes.getRequest();
|
||||
UserDetailRespVO userDetail = null;
|
||||
SimpleUser simpleUser = null;
|
||||
MethodSignature signature = (MethodSignature) point.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
//是否是token忽略
|
||||
TokenIgnore tokenIgnoreAnnotation = method.getAnnotation(TokenIgnore.class);
|
||||
//是否大屏token
|
||||
LargeScreenToken largeScreenToken = method.getAnnotation(LargeScreenToken.class);
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
log.info("token:" + token);
|
||||
String url = request.getRequestURL().toString();
|
||||
String className = point.getTarget().getClass().getName();
|
||||
String methodName = signature.getName();
|
||||
log.info("请求url:{} ,method:{}, 开始时间: {}", url, method, beginTime);
|
||||
//没有tokenIgnore注解的方法,验证token
|
||||
if (tokenIgnoreAnnotation == null) {
|
||||
//判断token是否有效
|
||||
String tokenKey = checkToken(token);
|
||||
userDetail = (UserDetailRespVO) redisService.get(tokenKey);
|
||||
String userNameKey = RedisKeyConstant.User.USER_NAME + userDetail.getLoginChannel() + ":" +userDetail.getUsername();
|
||||
simpleUser = (SimpleUser) redisService.get(userNameKey);
|
||||
if(simpleUser ==null){
|
||||
log.info("User token has expired ! token :{}", token);
|
||||
throw new BusinessException(BaseResponseCode.TOKEN_PARSE_ERROR);
|
||||
}
|
||||
log.info("userName: {}, groupId:{}, deptId:{}", userDetail.getUsername(), simpleUser.getGroupId(), simpleUser.getDeptId());
|
||||
//延长token时间
|
||||
redisService.expire(tokenKey, 2, TimeUnit.HOURS);
|
||||
redisService.expire(userNameKey, 2, TimeUnit.HOURS);
|
||||
}
|
||||
//有大屏token(largeScreenToken)的接口 , 因为这个token不过期,并且它的键值对和
|
||||
if(largeScreenToken !=null){
|
||||
String tokenKey = checkLargeToken(token);
|
||||
userDetail = (UserDetailRespVO) redisService.get(tokenKey);
|
||||
String userNameKey = RedisKeyConstant.User.USER_NAME_LARGE_SCREEN + "pc:" +userDetail.getUsername();
|
||||
simpleUser = (SimpleUser) redisService.get(userNameKey);
|
||||
log.info("userName: {}, userId: {}, groupId:{}", userDetail.getUsername(), simpleUser.getUserId(), simpleUser.getGroupId());
|
||||
//大屏token做延长有效期
|
||||
redisService.expire(tokenKey, 2, TimeUnit.HOURS);
|
||||
redisService.expire(userNameKey, 2, TimeUnit.HOURS);
|
||||
|
||||
}
|
||||
|
||||
//请求参数
|
||||
String params = null;
|
||||
try {
|
||||
//请求的参数
|
||||
Object[] args = point.getArgs();
|
||||
//MultipartFile类型的跳过转Json
|
||||
if (args != null && args.length > 0 && args[0] != null) {
|
||||
String simpleClassName = args[0].getClass().getSimpleName();
|
||||
log.info("SimpleClassName:" + simpleClassName);
|
||||
//不包含文件类型才打印日志
|
||||
if (!StringUtils.isBlank(simpleClassName) && !simpleClassName.contains("Multipart")) {
|
||||
params = JSON.toJSONString(args[0]);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
log.info("methodName:{}, className:{}", methodName, className);
|
||||
LogAnnotation logAnnotation = method.getAnnotation(LogAnnotation.class);
|
||||
//执行目标方法
|
||||
//执行方法
|
||||
Object result = point.proceed();
|
||||
//方法执行结果 返回日志屏蔽
|
||||
//log.info("返回:" + JSON.toJSONString(result));
|
||||
//执行时长(毫秒)
|
||||
long time = System.currentTimeMillis() - beginTime;
|
||||
log.info("耗时:{}, url:{}, param:{}" ,time, url, null);
|
||||
if(time> CommonConstant.timeoutMilliSeconds){
|
||||
log.error("接口超时: url:{}" ,url);
|
||||
}
|
||||
//有日志注解的入库
|
||||
if (logAnnotation != null) {
|
||||
SysLog sysLog = new SysLog();
|
||||
//设置IP地址
|
||||
sysLog.setIp(IPUtils.getIpAddr(request));
|
||||
//param可能过长,只保留1500字节长度
|
||||
if(params!=null && params.length()>1500){
|
||||
params = params.substring(0, 1500);
|
||||
}
|
||||
sysLog.setParams(params);
|
||||
sysLog.setMethod(methodName);
|
||||
sysLog.setOperation(logAnnotation.title() + "-" + logAnnotation.action());
|
||||
//保存日志
|
||||
try {
|
||||
log.info(sysLog.toString());
|
||||
saveLogComponent.saveSysLog(sysLog, userDetail, simpleUser, time);
|
||||
} catch (Exception e) {
|
||||
log.error("e={}", e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//验证token
|
||||
private String checkToken(String token) {
|
||||
if (token == null || StringUtils.isEmpty(token)) {
|
||||
throw new BusinessException(BaseResponseCode.TOKEN_ERROR);
|
||||
}
|
||||
String tokenKey = RedisKeyConstant.User.TOKEN + token;
|
||||
if (!redisService.hasKey(tokenKey)) {
|
||||
throw new BusinessException(BaseResponseCode.TOKEN_PAST_DUE);
|
||||
}
|
||||
return tokenKey;
|
||||
}
|
||||
|
||||
//验证大屏token
|
||||
private String checkLargeToken(String largeToken) {
|
||||
if (largeToken == null || StringUtils.isEmpty(largeToken)) {
|
||||
throw new BusinessException(BaseResponseCode.INVALID_BIG_SCREEN_TOKEN);
|
||||
}
|
||||
String tokenKey = RedisKeyConstant.User.TOKEN_LARGE_SCREEN + largeToken;
|
||||
if (!redisService.hasKey(tokenKey)) {
|
||||
throw new BusinessException(BaseResponseCode.INVALID_BIG_SCREEN_TOKEN);
|
||||
}
|
||||
return tokenKey;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package com.ho.flow.config;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.caffeine.CaffeineCacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author fancl
|
||||
* @desc: Caffeine配置类
|
||||
* @date 2023/4/14
|
||||
*/
|
||||
@Configuration
|
||||
public class CaffeineConfig extends CaffeineCacheManager{
|
||||
|
||||
//10秒钟的缓存
|
||||
@Bean(name = "tenSecondCacheManager")
|
||||
@Primary
|
||||
public CacheManager tenSecondCacheManager(){
|
||||
Caffeine caffeine = Caffeine.newBuilder()
|
||||
.initialCapacity(50) //初始大小
|
||||
.maximumSize(20000) //最大大小
|
||||
.expireAfterWrite(60 ,TimeUnit.MINUTES); //写入/多久过期
|
||||
|
||||
CaffeineCacheManager caffeineCacheManager = new CaffeineCacheManager();
|
||||
caffeineCacheManager.setAllowNullValues(true);
|
||||
caffeineCacheManager.setCaffeine(caffeine);
|
||||
return caffeineCacheManager;
|
||||
}
|
||||
|
||||
//30秒钟的缓存
|
||||
@Bean(name = "thirtySecondCacheManager")
|
||||
public CacheManager thirtySecondCacheManager(){
|
||||
Caffeine caffeine = Caffeine.newBuilder()
|
||||
.initialCapacity(50) //初始大小
|
||||
.maximumSize(2000) //最大大小
|
||||
.expireAfterWrite(30 ,TimeUnit.SECONDS); //写入/多久过期
|
||||
|
||||
CaffeineCacheManager caffeineCacheManager = new CaffeineCacheManager();
|
||||
caffeineCacheManager.setAllowNullValues(true);
|
||||
caffeineCacheManager.setCaffeine(caffeine);
|
||||
return caffeineCacheManager;
|
||||
}
|
||||
|
||||
//2分钟的缓存
|
||||
@Bean(name = "towMinuteCacheManager")
|
||||
public CacheManager towMinuteCacheManager(){
|
||||
Caffeine caffeine = Caffeine.newBuilder()
|
||||
.initialCapacity(50) //初始大小
|
||||
.maximumSize(2000) //最大大小
|
||||
.expireAfterWrite(2, TimeUnit.MINUTES); //写入/多久过期
|
||||
|
||||
CaffeineCacheManager caffeineCacheManager = new CaffeineCacheManager();
|
||||
caffeineCacheManager.setAllowNullValues(true);
|
||||
caffeineCacheManager.setCaffeine(caffeine);
|
||||
return caffeineCacheManager;
|
||||
}
|
||||
|
||||
//5分钟的缓存
|
||||
@Bean(name = "fiveMinuteCacheManager")
|
||||
public CacheManager fiveMinuteCacheManager(){
|
||||
Caffeine caffeine = Caffeine.newBuilder()
|
||||
.initialCapacity(50) //初始大小
|
||||
.maximumSize(5000) //最大大小
|
||||
.expireAfterWrite(50, TimeUnit.MINUTES); //写入/多久过期
|
||||
|
||||
CaffeineCacheManager caffeineCacheManager = new CaffeineCacheManager();
|
||||
caffeineCacheManager.setAllowNullValues(true);
|
||||
caffeineCacheManager.setCaffeine(caffeine);
|
||||
return caffeineCacheManager;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.ho.flow.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.engine.impl.cfg.IdGenerator;
|
||||
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @author fancl
|
||||
* @desc: id生成
|
||||
* @date 2023/1/2
|
||||
*/
|
||||
//@Component
|
||||
@Slf4j
|
||||
public class FlowIdGenerator implements IdGenerator {
|
||||
|
||||
@Autowired
|
||||
ProcessEngineConfigurationImpl processEngineConfigurationImpl;
|
||||
|
||||
@Override
|
||||
public String getNextId() {
|
||||
String nextId = processEngineConfigurationImpl.getDbSqlSessionFactory().getIdGenerator().getNextId();
|
||||
log.info("Flow nextId:" + nextId);
|
||||
return nextId;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
package com.ho.flow.config;
|
||||
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.BusinessException;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import org.hibernate.validator.internal.engine.path.PathImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @描述 全局异常处理
|
||||
* @创建人 fancl
|
||||
* @创建时间 2021/2/26
|
||||
* @修改人
|
||||
*/
|
||||
//迁移到common模块中
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
|
||||
//绑定Exception
|
||||
@ExceptionHandler(Exception.class)
|
||||
public <T> DataResult<T> handle(Exception ex) {
|
||||
|
||||
log.error("业务异常e:", ex);
|
||||
//异常的日志都打印记录
|
||||
log.error(ex.getMessage() + ":" + ex.getMessage());
|
||||
|
||||
|
||||
DataResult result = new DataResult(BaseResponseCode.OPERATION_ERRO);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//绑定 BusinessException
|
||||
@ExceptionHandler(BusinessException.class)
|
||||
public <T> DataResult<T> handler(BusinessException businessException) {
|
||||
log.error("业务 BusinessException 异常e:", businessException);
|
||||
return new DataResult<>(businessException.getMessageCode(), businessException.getDetailMessage());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 参数校验异常处理类
|
||||
* 参数为实体类
|
||||
*
|
||||
* @param ex
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public DataResult handleBindException(MethodArgumentNotValidException ex) {
|
||||
FieldError fieldError = ex.getBindingResult().getFieldError();
|
||||
log.error("参数校验异常:{}({})", fieldError.getDefaultMessage(), fieldError.getField());
|
||||
DataResult result = new DataResult(BaseResponseCode.METHODARGUMENTNOTVALIDEXCEPTION.getCode(),fieldError.getDefaultMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验 非实体请求参数
|
||||
*
|
||||
* @param ex
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(value = ConstraintViolationException.class)
|
||||
public DataResult handle(ConstraintViolationException ex) {
|
||||
log.error("业务ConstraintViolationException异常e:", ex);
|
||||
StringBuilder msg = new StringBuilder();
|
||||
Set<ConstraintViolation<?>> constraintViolations = ex.getConstraintViolations();
|
||||
for (ConstraintViolation<?> constraintViolation : constraintViolations) {
|
||||
PathImpl pathImpl = (PathImpl) constraintViolation.getPropertyPath();
|
||||
String paramName = pathImpl.getLeafNode().getName();
|
||||
String message = constraintViolation.getMessage();
|
||||
msg.append(message);
|
||||
}
|
||||
log.error(msg.toString(), ex);
|
||||
// 返回参数错误提示
|
||||
return new DataResult(BaseResponseCode.METHODARGUMENTNOTVALIDEXCEPTION);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.ho.flow.config;
|
||||
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.AuthorityUtils;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fancl
|
||||
* @desc: 给流程框架自定义用户体系
|
||||
* @date 2023/2/5
|
||||
*/
|
||||
@Component
|
||||
public class MyUserDetailServiceImpl implements UserDetailsService {
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
//只是为了不报错,因为用户和权限已经有框架来控制
|
||||
List<GrantedAuthority> authorities= AuthorityUtils.commaSeparatedStringToAuthorityList("admin");
|
||||
User user = new User(username,"", authorities);
|
||||
return user;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.ho.flow.config;
|
||||
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author fancl
|
||||
* @desc:
|
||||
* @date 2023/1/2
|
||||
*/
|
||||
@Configuration
|
||||
public class ProcessEnginConfig {
|
||||
|
||||
@Autowired
|
||||
RepositoryService repositoryService;
|
||||
|
||||
|
||||
//启动检查流程是否部署,没部署就部署,主要是要根据集团部署多个流程
|
||||
|
||||
|
||||
/*@Autowired
|
||||
FlowIdGenerator flowIdGenerator;
|
||||
|
||||
@Bean
|
||||
ProcessEngineConfigurationImpl processEngineConfigurationImpNew(ProcessEngineConfigurationImpl processEngineConfiguration){
|
||||
processEngineConfiguration.setIdGenerator(flowIdGenerator);
|
||||
processEngineConfiguration.getDbSqlSessionFactory().setIdGenerator(flowIdGenerator);
|
||||
return processEngineConfiguration;
|
||||
}*/
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package com.ho.flow.config;
|
||||
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
import com.ho.common.tools.entity.UserDetailRespVO;
|
||||
import com.ho.flow.feignclient.UserFeignClient;
|
||||
import com.ho.user.api.entity.SysLog;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author fancl
|
||||
* @desc:
|
||||
* @date 2022/10/20
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SaveLogComponent {
|
||||
|
||||
@Autowired
|
||||
Snowflake snowflake;
|
||||
|
||||
@Autowired
|
||||
UserFeignClient userFeignClient;
|
||||
|
||||
//保存日志
|
||||
@Async
|
||||
public void saveSysLog(SysLog sysLog, UserDetailRespVO user, SimpleUser simpleUser, long time) {
|
||||
sysLog.setId(snowflake.nextId());
|
||||
sysLog.setGroupId(simpleUser.getGroupId());
|
||||
sysLog.setDeptId(simpleUser.getDeptId());
|
||||
sysLog.setUsername(user.getUsername());
|
||||
sysLog.setUserId(user.getUserId());
|
||||
sysLog.setTime((int) time);
|
||||
//调用User-center的服务记录日志
|
||||
userFeignClient.insertLog(sysLog);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package com.ho.flow.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
/**
|
||||
* @描述 swagger2配置
|
||||
* @创建人 fancl
|
||||
* @创建时间 2021/2/12
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class Swagger2Config {
|
||||
|
||||
@Value("${swagger2.projectName}")
|
||||
private String projectName;
|
||||
|
||||
@Value("${swagger2.controllerPath}")
|
||||
private String controllerPath;
|
||||
|
||||
//根据配置启用或关闭swagger接口
|
||||
@Value("${swagger2.enable}")
|
||||
private Boolean enable;
|
||||
|
||||
//Swagger2接口文档版本
|
||||
public static final String VERSION = "1.0.0";
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage(controllerPath))
|
||||
.paths(PathSelectors.any()) //可以根据url路径设置哪些请求加入文档,忽略哪些请求
|
||||
.build()
|
||||
.enable(enable);
|
||||
}
|
||||
|
||||
public ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title(projectName) //设置文档的标题
|
||||
.description("REST API") //设置文档的描述
|
||||
.version(VERSION)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package com.ho.flow.config;
|
||||
|
||||
import com.alibaba.druid.support.http.StatViewServlet;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* @author fancl
|
||||
* @desc: 线程池配置类
|
||||
* @date 2022/9/12
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class ThreadPoolConfig {
|
||||
|
||||
@Autowired
|
||||
DataSource dataSource;
|
||||
|
||||
@PostConstruct
|
||||
public void t(){
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@Bean
|
||||
ThreadPoolTaskExecutor flowThreadPoolExecutor(){
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
int core = Runtime.getRuntime().availableProcessors();
|
||||
log.info("core:" +core);
|
||||
executor.setCorePoolSize(core);
|
||||
//最大线程数是核心线程数10倍
|
||||
executor.setMaxPoolSize(core * 10);
|
||||
//
|
||||
executor.setKeepAliveSeconds(600);
|
||||
executor.setQueueCapacity(core * 1000);
|
||||
executor.setThreadNamePrefix("flow-thread-execute");
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
ServletRegistrationBean regisDruid() {
|
||||
//固定写法,配置访问路径
|
||||
ServletRegistrationBean<StatViewServlet> bean = new ServletRegistrationBean<>(new StatViewServlet(), "/druid/*");
|
||||
//配置登录信息,固定写法
|
||||
HashMap<String, String> initParams = new HashMap<>();
|
||||
//账号和密码的key是固定的
|
||||
initParams.put("loginUsername", "fan");
|
||||
initParams.put("loginPassword", "111111");
|
||||
|
||||
//允许谁可以访问
|
||||
initParams.put("allow", "");
|
||||
bean.setInitParameters(initParams);
|
||||
return bean;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,424 @@
|
||||
package com.ho.flow.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ho.business.vo.req.deviceModel.SynchronousReqVo;
|
||||
import com.ho.common.tools.annotation.HzPermission;
|
||||
import com.ho.common.tools.annotation.LogAnnotation;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.constant.PermissionConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.common.tools.util.PageUtils;
|
||||
import com.ho.flow.constant.FlowConstant;
|
||||
import com.ho.flow.service.AlarmConfigService;
|
||||
import com.ho.flow.service.DeviceColDefineService;
|
||||
import com.ho.flow.vo.AlarmConfig;
|
||||
import com.ho.flow.vo.DeviceColDefine;
|
||||
import com.ho.flow.vo.req.AlarmConfig.*;
|
||||
import com.ho.flow.vo.resp.alarm.AlarmMeasureRepVo;
|
||||
import com.ho.flow.vo.resp.alarm.AlarmSignalRepVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author gyan
|
||||
* @desc: 电站告警配置表
|
||||
* @DateTime: 2023/2/1 17:21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT + "alarmConfig")
|
||||
@Api(tags = "电站告警配置")
|
||||
public class AlarmConfigController {
|
||||
|
||||
@Autowired
|
||||
AlarmConfigService alarmConfigService;
|
||||
|
||||
@Autowired
|
||||
DeviceColDefineService deviceColDefineService;
|
||||
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
RedissonClient redissonClient;
|
||||
|
||||
|
||||
@PostMapping("/signalPage")
|
||||
@ApiOperation(value = "分页查询遥信告警配置接口")
|
||||
public DataResult<PageResult<AlarmSignalRepVo>> signalPage(@RequestBody AlarmConfigPageReqVo vo, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
vo.setGroupId(user.getGroupId());
|
||||
//按照设备类型查全部字段定义表中的字段
|
||||
//这个分页需要内存分页
|
||||
DeviceColDefineReqVo defineReqVo = new DeviceColDefineReqVo();
|
||||
defineReqVo.setDeviceType(vo.getDeviceType());
|
||||
defineReqVo.setSensType(vo.getSensType());
|
||||
// defineReqVo.setColName(vo.getColName());
|
||||
defineReqVo.setColNameList(vo.getColNameList());
|
||||
List<DeviceColDefine> deviceColDefines = deviceColDefineService.selectList(defineReqVo);
|
||||
AlarmConfigPageReqVo thisLevelQuery = new AlarmConfigPageReqVo();
|
||||
Integer scope = FlowConstant.AlarmConfig.SCOPE_GROUP;
|
||||
;
|
||||
//如果集团级别,就查集团,电站的就查电站
|
||||
thisLevelQuery.setGroupId(vo.getGroupId());
|
||||
thisLevelQuery.setDeviceType(vo.getDeviceType());
|
||||
thisLevelQuery.setScope(vo.getScope());
|
||||
thisLevelQuery.setSensType(vo.getSensType());
|
||||
thisLevelQuery.setAlarmLevel(vo.getAlarmLevel());
|
||||
//新增字段名匹配
|
||||
// thisLevelQuery.setColName(vo.getColName());
|
||||
thisLevelQuery.setColNameList(vo.getColNameList());
|
||||
if (FlowConstant.AlarmConfig.SCOPE_STATION.equals(vo.getScope())) {
|
||||
scope = FlowConstant.AlarmConfig.SCOPE_STATION;
|
||||
thisLevelQuery.setStationId(vo.getStationId());
|
||||
}
|
||||
//查告警等级是这个类型的数据,进行选中控制
|
||||
List<AlarmConfig> thisLevelList = alarmConfigService.selectList(thisLevelQuery);
|
||||
//查告警等级不是这个的数据,把这些字段排除
|
||||
AlarmConfigPageReqVo otherLevelQuery = new AlarmConfigPageReqVo();
|
||||
BeanUtil.copyProperties(thisLevelQuery, otherLevelQuery);
|
||||
otherLevelQuery.setAlarmLevel(null);
|
||||
otherLevelQuery.setOtherAlarmLevel(vo.getAlarmLevel());
|
||||
// otherLevelQuery.setColName(vo.getColName());
|
||||
thisLevelQuery.setColNameList(vo.getColNameList());
|
||||
List<AlarmConfig> otherLevelList = alarmConfigService.selectList(otherLevelQuery);
|
||||
//把两个alarmconfig集合按col分组
|
||||
Map<String, AlarmConfig> otherLevelMap = otherLevelList.stream().collect(Collectors.toMap(AlarmConfig::getCol, alarmConfig -> alarmConfig));
|
||||
Map<String, AlarmConfig> thisLevelMap = thisLevelList.stream().collect(Collectors.toMap(AlarmConfig::getCol, alarmConfig -> alarmConfig));
|
||||
//
|
||||
List<AlarmSignalRepVo> alarmList = new ArrayList<>();
|
||||
for (DeviceColDefine deviceColDefine : deviceColDefines) {
|
||||
//其他等级已经使用的,就剔除了,没有的才保留这个数据
|
||||
if (!otherLevelMap.containsKey(deviceColDefine.getCol())) {
|
||||
AlarmSignalRepVo alarmSignalRepVo = new AlarmSignalRepVo();
|
||||
alarmSignalRepVo.setId(deviceColDefine.getId());
|
||||
alarmSignalRepVo.setColName(deviceColDefine.getColName());
|
||||
alarmSignalRepVo.setScope(scope);
|
||||
if (thisLevelMap.containsKey(deviceColDefine.getCol())) {
|
||||
alarmSignalRepVo.setChecked(FlowConstant.AlarmConfig.CHECKED);
|
||||
} else {
|
||||
alarmSignalRepVo.setChecked(FlowConstant.AlarmConfig.NOT_CHECKED);
|
||||
}
|
||||
alarmList.add(alarmSignalRepVo);
|
||||
}
|
||||
}
|
||||
//java内存分页
|
||||
PageResult pageResult = new PageResult<>();
|
||||
if (!alarmList.isEmpty()) {
|
||||
List list = PageUtils.dealList(alarmList, vo.getPageNum(), vo.getPageSize());
|
||||
pageResult = PageUtils.getPageResult(new PageInfo<>(list));
|
||||
pageResult.setTotalRows(alarmList.size());
|
||||
pageResult.setTotalPages(alarmList.size() / vo.getPageSize() + 1);
|
||||
} else {
|
||||
pageResult = PageUtils.getPageResult(new PageInfo<>(new ArrayList<>()));
|
||||
}
|
||||
return DataResult.success(pageResult);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/measurePage")
|
||||
@ApiOperation(value = "分页查询遥测告警配置接口")
|
||||
public DataResult<PageResult<AlarmMeasureRepVo>> measurePage(@RequestBody AlarmConfigPageReqVo vo, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
vo.setGroupId(user.getGroupId());
|
||||
//按照设备类型查全部字段定义表中的字段
|
||||
//这个分页需要内存分页
|
||||
DeviceColDefineReqVo defineReqVo = new DeviceColDefineReqVo();
|
||||
defineReqVo.setDeviceType(vo.getDeviceType());
|
||||
defineReqVo.setSensType(vo.getSensType());
|
||||
defineReqVo.setColName(vo.getColName());
|
||||
List<DeviceColDefine> deviceColDefines = deviceColDefineService.selectList(defineReqVo);
|
||||
AlarmConfigPageReqVo thisLevelQuery = new AlarmConfigPageReqVo();
|
||||
thisLevelQuery.setGroupId(vo.getGroupId());
|
||||
thisLevelQuery.setDeviceType(vo.getDeviceType());
|
||||
thisLevelQuery.setScope(vo.getScope());
|
||||
thisLevelQuery.setSensType(vo.getSensType());
|
||||
thisLevelQuery.setColName(vo.getColName());
|
||||
Integer scope = FlowConstant.AlarmConfig.SCOPE_GROUP;
|
||||
//如果集团级别,就查集团,电站的就查电站
|
||||
if (FlowConstant.AlarmConfig.SCOPE_STATION.equals(vo.getScope())) {
|
||||
scope = FlowConstant.AlarmConfig.SCOPE_STATION;
|
||||
thisLevelQuery.setStationId(vo.getStationId());
|
||||
}
|
||||
//查告警等级是这个类型的数据,进行选中控制
|
||||
List<AlarmConfig> thisLevelList = alarmConfigService.selectList(thisLevelQuery);
|
||||
//把两个alarmconfig集合按col分组
|
||||
Map<String, AlarmConfig> thisLevelMap = thisLevelList.stream().collect(Collectors.toMap(AlarmConfig::getCol, alarmConfig -> alarmConfig));
|
||||
//
|
||||
List<AlarmMeasureRepVo> alarmList = new ArrayList<>();
|
||||
for (DeviceColDefine deviceColDefine : deviceColDefines) {
|
||||
//其他等级已经使用的,就剔除了,没有的才保留这个数据
|
||||
AlarmMeasureRepVo measure = new AlarmMeasureRepVo();
|
||||
measure.setId(deviceColDefine.getId());
|
||||
measure.setColName(deviceColDefine.getColName());
|
||||
measure.setScope(scope);
|
||||
String key = deviceColDefine.getCol();
|
||||
if (thisLevelMap.containsKey(key)) {
|
||||
measure.setChecked(FlowConstant.AlarmConfig.CHECKED);
|
||||
measure.setUpperLimit(thisLevelMap.get(key).getUpperLimit());
|
||||
measure.setLowerLimit(thisLevelMap.get(key).getLowerLimit());
|
||||
} else {
|
||||
measure.setChecked(FlowConstant.AlarmConfig.NOT_CHECKED);
|
||||
}
|
||||
alarmList.add(measure);
|
||||
}
|
||||
//java内存分页
|
||||
PageResult pageResult = new PageResult<>();
|
||||
if (!alarmList.isEmpty()) {
|
||||
List list = PageUtils.dealList(alarmList, vo.getPageNum(), vo.getPageSize());
|
||||
pageResult = PageUtils.getPageResult(new PageInfo<>(list));
|
||||
pageResult.setTotalRows(alarmList.size());
|
||||
pageResult.setTotalPages(alarmList.size() / vo.getPageSize() + 1);
|
||||
} else {
|
||||
pageResult = PageUtils.getPageResult(new PageInfo<>(new ArrayList<>()));
|
||||
}
|
||||
return DataResult.success(pageResult);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/signalCheckListPage")
|
||||
@ApiOperation(value = "分页查询遥信告警配置已经选中的接口")
|
||||
public DataResult<PageResult<AlarmSignalRepVo>> signalCheckListPage(@RequestBody AlarmConfigPageReqVo vo, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
vo.setGroupId(user.getGroupId());
|
||||
AlarmConfigPageReqVo thisLevelQuery = new AlarmConfigPageReqVo();
|
||||
Integer scope = FlowConstant.AlarmConfig.SCOPE_GROUP;
|
||||
//如果集团级别,就查集团,电站的就查电站
|
||||
thisLevelQuery.setGroupId(vo.getGroupId());
|
||||
thisLevelQuery.setDeviceType(vo.getDeviceType());
|
||||
thisLevelQuery.setScope(vo.getScope());
|
||||
thisLevelQuery.setSensType(vo.getSensType());
|
||||
thisLevelQuery.setAlarmLevel(vo.getAlarmLevel());
|
||||
if (FlowConstant.AlarmConfig.SCOPE_STATION.equals(vo.getScope())) {
|
||||
scope = FlowConstant.AlarmConfig.SCOPE_STATION;
|
||||
thisLevelQuery.setStationId(vo.getStationId());
|
||||
}
|
||||
//查告警等级是这个类型的数据,进行选中控制
|
||||
List<AlarmConfig> thisLevelList = alarmConfigService.selectList(thisLevelQuery);
|
||||
List<AlarmSignalRepVo> alarmList = new ArrayList<>();
|
||||
for (AlarmConfig alarm : thisLevelList) {
|
||||
AlarmSignalRepVo alarmSignalRepVo = new AlarmSignalRepVo();
|
||||
alarmSignalRepVo.setId(alarm.getColDefineId());
|
||||
alarmSignalRepVo.setColName(alarm.getColName());
|
||||
alarmSignalRepVo.setScope(scope);
|
||||
alarmSignalRepVo.setChecked(FlowConstant.AlarmConfig.CHECKED);
|
||||
alarmList.add(alarmSignalRepVo);
|
||||
}
|
||||
//java内存分页
|
||||
PageResult pageResult = new PageResult<>();
|
||||
if (!alarmList.isEmpty()) {
|
||||
List list = PageUtils.dealList(alarmList, vo.getPageNum(), vo.getPageSize());
|
||||
pageResult = PageUtils.getPageResult(new PageInfo<>(list));
|
||||
pageResult.setTotalRows(alarmList.size());
|
||||
pageResult.setTotalPages(alarmList.size() / vo.getPageSize() + 1);
|
||||
} else {
|
||||
pageResult = PageUtils.getPageResult(new PageInfo<>(new ArrayList<>()));
|
||||
}
|
||||
return DataResult.success(pageResult);
|
||||
}
|
||||
|
||||
//这个方法用不到了
|
||||
@Deprecated
|
||||
@PostMapping("/levelList")
|
||||
@ApiOperation(value = "批量新增遥信时查询电站告警配置列表,不分页")
|
||||
@ApiIgnore
|
||||
public DataResult<List<DeviceColDefine>> levelList(@RequestBody LevelReqVo levelReqVo, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
//先查全量字段定义
|
||||
DeviceColDefineReqVo defineReqVo = new DeviceColDefineReqVo();
|
||||
defineReqVo.setDeviceType(levelReqVo.getDeviceType());
|
||||
defineReqVo.setSensType(levelReqVo.getSensType());
|
||||
//List<DeviceColDefine> deviceColDefines = deviceColDefineService.selectByIdList(defineReqVo);
|
||||
List<DeviceColDefine> deviceColDefines = null;
|
||||
//再查电站在该等级下的已配置字段
|
||||
AlarmConfigPageReqVo alarmConfigPageReqVo = new AlarmConfigPageReqVo();
|
||||
alarmConfigPageReqVo.setGroupId(user.getGroupId());
|
||||
alarmConfigPageReqVo.setStationId(levelReqVo.getStationId());
|
||||
alarmConfigPageReqVo.setDeviceType(levelReqVo.getDeviceType());
|
||||
alarmConfigPageReqVo.setSensType(levelReqVo.getSensType());
|
||||
alarmConfigPageReqVo.setAlarmLevel(levelReqVo.getAlarmLevel());
|
||||
//设置为电站级别数据
|
||||
alarmConfigPageReqVo.setScope(FlowConstant.AlarmConfig.SCOPE_STATION);
|
||||
List<AlarmConfig> stationAlarmConfigs = alarmConfigService.selectList(alarmConfigPageReqVo);
|
||||
//将这个已配置集合转为map,按照 col分组
|
||||
Map<String, AlarmConfig> stationAlarmConfigMap = stationAlarmConfigs.stream().collect(Collectors.toMap(AlarmConfig::getCol, alarmConfig -> alarmConfig));
|
||||
//查集团级
|
||||
alarmConfigPageReqVo = new AlarmConfigPageReqVo();
|
||||
alarmConfigPageReqVo.setGroupId(user.getGroupId());
|
||||
alarmConfigPageReqVo.setDeviceType(levelReqVo.getDeviceType());
|
||||
alarmConfigPageReqVo.setSensType(levelReqVo.getSensType());
|
||||
alarmConfigPageReqVo.setAlarmLevel(levelReqVo.getAlarmLevel());
|
||||
//设置为集团级别
|
||||
alarmConfigPageReqVo.setScope(FlowConstant.AlarmConfig.SCOPE_GROUP);
|
||||
List<AlarmConfig> groupAlarmConfigs = alarmConfigService.selectList(alarmConfigPageReqVo);
|
||||
//将这个已配置集合转为map,按照 col分组
|
||||
Map<String, AlarmConfig> groupAlarmConfigMap = groupAlarmConfigs.stream().collect(Collectors.toMap(AlarmConfig::getCol, alarmConfig -> alarmConfig));
|
||||
|
||||
//默认先设置为未选择
|
||||
for (DeviceColDefine deviceColDefine : deviceColDefines) {
|
||||
//同时包含了这个值才checked =1
|
||||
if (stationAlarmConfigMap.containsKey(deviceColDefine.getCol())
|
||||
&& groupAlarmConfigMap.containsKey(deviceColDefine.getCol())) {
|
||||
deviceColDefine.setChecked(1);
|
||||
} else {
|
||||
deviceColDefine.setChecked(0);
|
||||
}
|
||||
}
|
||||
//将 alarmConfigs存在数据的(已配置的) 修改为
|
||||
return DataResult.success(deviceColDefines);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("add")
|
||||
@ApiOperation(value = "新增电站告警配置接口")
|
||||
@LogAnnotation(title = "电站告警配置", action = "新增电站告警配置")
|
||||
public DataResult<AlarmConfig> add(@RequestBody @Valid AlarmConfigAddReqVo vo, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
alarmConfigService.add(vo, user);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("addSignalBatch")
|
||||
@ApiOperation(value = "批量新增告警遥信配置接口")
|
||||
@LogAnnotation(title = "电站告警配置", action = "批量新增电站告警遥信配置")
|
||||
@HzPermission(PermissionConstant.EVENT_CONFIGURE_YXSAVE)
|
||||
public DataResult<AlarmConfig> addSignalBatch(@RequestBody @Valid AlarmSignalBatchAddReq addReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
addReq.setGroupId(user.getGroupId());
|
||||
//分布式锁
|
||||
//定义锁
|
||||
RLock lock = null;
|
||||
try {
|
||||
lock = redissonClient.getLock(RedisKeyConstant.LOCK_KEY_ALARM_CONFIG);
|
||||
//获取锁,没有获取到锁的阻塞在lock.lock() 这行
|
||||
lock.lock();
|
||||
alarmConfigService.addSignalBatch(addReq);
|
||||
} finally {
|
||||
if (lock != null && lock.isHeldByCurrentThread()) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("addMeasureBatch")
|
||||
@ApiOperation(value = "批量新增告警遥测配置接口")
|
||||
@LogAnnotation(title = "电站告警配置", action = "批量新增电站告警遥测配置")
|
||||
@HzPermission(PermissionConstant.EVENT_CONFIGURE_YCSAVE)
|
||||
public DataResult<AlarmConfig> addMeasureBatch(@RequestBody @Valid AlarmMeasureBatchAddReq addReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
addReq.setGroupId(user.getGroupId());
|
||||
//分布式锁
|
||||
//定义锁
|
||||
RLock lock = null;
|
||||
BigDecimal max = new BigDecimal(1000000000);
|
||||
BigDecimal min = new BigDecimal(-1000000000);
|
||||
try {
|
||||
lock = redissonClient.getLock(RedisKeyConstant.LOCK_KEY_ALARM_CONFIG);
|
||||
//获取锁,没有获取到锁的阻塞在lock.lock() 这行
|
||||
lock.lock();
|
||||
List<MeasureVo> measureList = new ArrayList<>();
|
||||
for (MeasureVo measureVo : addReq.getMeasureList()) {
|
||||
if (measureVo.getLowerLimit() != null && measureVo.getUpperLimit() != null) {
|
||||
if (measureVo.getUpperLimit().compareTo(measureVo.getLowerLimit()) < 0) {
|
||||
return DataResult.getResult(BaseResponseCode.EXISTS_UPPER_LESS_LOWER);
|
||||
}
|
||||
if (measureVo.getUpperLimit().compareTo(max) > 0 || measureVo.getLowerLimit().compareTo(min) < 0) {
|
||||
return DataResult.getResult(BaseResponseCode.EXCEEDING_VALUE_RANGE);
|
||||
}
|
||||
measureList.add(measureVo);
|
||||
}else if((measureVo.getLowerLimit() != null && measureVo.getUpperLimit() == null) || (measureVo.getLowerLimit() == null && measureVo.getUpperLimit() != null)){
|
||||
return DataResult.getResult(BaseResponseCode.TELEMETRY_VALUE_NOT_LIMIT);
|
||||
}
|
||||
}
|
||||
//addReq.setMeasureList(measureList);
|
||||
alarmConfigService.addMeasureBatch(addReq);
|
||||
} finally {
|
||||
if (lock != null && lock.isHeldByCurrentThread()) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
|
||||
//不需要单个删除了,单个删除也调用多个删除方法
|
||||
@GetMapping("deleteById/{id}")
|
||||
@ApiOperation(value = "删除告警配置接口")
|
||||
@LogAnnotation(title = "电站告警配置", action = "删除电站告警配置")
|
||||
@ApiIgnore
|
||||
public DataResult deleteById(@PathVariable @Valid Integer id) {
|
||||
alarmConfigService.deletedById(id);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("deleteSignalBatch")
|
||||
@ApiOperation(value = "批量删除告警遥信配置")
|
||||
@LogAnnotation(title = "电站告警配置", action = "批量删除告警遥信配置")
|
||||
@HzPermission(PermissionConstant.EVENT_CONFIGURE_YXBATCHDELETE)
|
||||
public DataResult deleteSignalBatch(@RequestBody @Valid AlarmBatchDeleteReq batchDeleteReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
batchDeleteReq.setGroupId(user.getGroupId());
|
||||
//批量alarm表删除,传过来的是deviceColId集合,需要根据这个条件找到alarmConfig表中对应的记录
|
||||
alarmConfigService.deleteSignalBatch(batchDeleteReq);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("update")
|
||||
@ApiOperation(value = "更新告警配置接口")
|
||||
@LogAnnotation(title = "电站告警配置", action = "更新电站告警配置")
|
||||
public DataResult update(@RequestBody @Valid AlarmConfigUpdateReqVo vo) {
|
||||
alarmConfigService.update(vo);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("modifyLevel")
|
||||
@ApiOperation(value = "更改电站告警等级接口")
|
||||
@LogAnnotation(title = "电站告警配置", action = "更改电站告警等级")
|
||||
@HzPermission(PermissionConstant.EVENT_CONFIGURE_YXEDIT)
|
||||
public DataResult modifyLevel(@RequestBody @Valid AlarmUpdateLevelReq vo) {
|
||||
AlarmConfigUpdateReqVo updateReqVo = new AlarmConfigUpdateReqVo();
|
||||
BeanUtils.copyProperties(vo, updateReqVo);
|
||||
alarmConfigService.update(updateReqVo);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/syAlarmConfig")
|
||||
@ApiOperation(value = "同步告警配置数据")
|
||||
@LogAnnotation(title = "告警配置", action = "一键同步告警配置")
|
||||
public DataResult syAlarmConfig(@RequestBody SynchronousReqVo vo) {
|
||||
alarmConfigService.syAlarmConfig(vo);
|
||||
return DataResult.success();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,170 @@
|
||||
package com.ho.flow.controller;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.ho.business.vo.req.deviceModel.SynchronousReqVo;
|
||||
import com.ho.common.tools.annotation.LogAnnotation;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.BusinessException;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.flow.service.DeviceColDefineService;
|
||||
import com.ho.flow.vo.DeviceColDefine;
|
||||
import com.ho.flow.vo.req.AlarmConfig.DeviceColDefineReqVo;
|
||||
import com.ho.flow.vo.req.devicecoldefine.DeviceColDefineDeleteVO;
|
||||
import com.ho.flow.vo.req.devicecoldefine.DeviceColDefineModifyVO;
|
||||
import com.ho.flow.vo.req.devicecoldefine.DeviceColDefineReqVO;
|
||||
import com.ho.flow.vo.req.devicecoldefine.DeviceColDefineSyncVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author gyan
|
||||
* @desc: 告警配置功能
|
||||
* @DateTime: 2023/2/1 16:05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT +"deviceColDefine")
|
||||
@Api(tags = "告警字段定义")
|
||||
@Slf4j
|
||||
public class DeviceColDefineController {
|
||||
@Autowired
|
||||
DeviceColDefineService deviceColDefineService;
|
||||
|
||||
@PostMapping("/page")
|
||||
@ApiOperation(value = "分页查询告警配置接口")
|
||||
public DataResult<PageResult<DeviceColDefine>> page(@RequestBody @Valid DeviceColDefineReqVo definePageReq) {
|
||||
DataResult<PageResult<DeviceColDefine>> result = DataResult.success();
|
||||
String deviceType = definePageReq.getDeviceType();
|
||||
if(null!=deviceType && !deviceType.isEmpty()){
|
||||
PageResult<DeviceColDefine> deviceColDefine = deviceColDefineService.selectPage(definePageReq);
|
||||
result.setData(deviceColDefine);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/colDefineList")
|
||||
@ApiOperation(value = "查询告警配置接口,不分页")
|
||||
public DataResult<DeviceColDefine> colDefineList(@RequestBody @Valid DeviceColDefineReqVo vo) {
|
||||
List<DeviceColDefine> deviceColDefine = deviceColDefineService.selectList(vo);
|
||||
return DataResult.success(deviceColDefine);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@ApiOperation(value = "根据设备告警字段id查询告警配置接口")
|
||||
public DataResult<DeviceColDefine> selectById(@PathVariable @Valid Integer id) {
|
||||
DataResult<DeviceColDefine> result = DataResult.success();
|
||||
DeviceColDefine deviceColDefine= deviceColDefineService.selectById(id);
|
||||
result.setData(deviceColDefine);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取excel文件
|
||||
* @param file
|
||||
*/
|
||||
@PostMapping("/importExcel")
|
||||
@ApiOperation(value = "导入模板数据")
|
||||
public DataResult<String> importExcel(@RequestBody MultipartFile file){
|
||||
try {
|
||||
List<DeviceColDefineReqVO> list = EasyExcel.read(file.getInputStream()).head(DeviceColDefineReqVO.class).sheet().doReadSync();
|
||||
int count = deviceColDefineService.insertList(list);
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
throw new BusinessException(BaseResponseCode.SJEKK_EXCEL_DATA);
|
||||
}
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("exportTemplate")
|
||||
@ApiOperation(value = "导出模板")
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
ServletOutputStream out = null;
|
||||
try {
|
||||
String fileName = URLEncoder.encode("deviceColDefineTemplate.xls", "utf-8");
|
||||
InputStream fis = getResourcesFileInputStream("template/deviceColDefineTemplate.xls");
|
||||
byte[] buffer = new byte[fis.available()];
|
||||
fis.read(buffer);
|
||||
fis.close();
|
||||
response.setHeader("Content-disposition", "attachment;fileName=" + fileName);
|
||||
response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
||||
out = response.getOutputStream();
|
||||
out.write(buffer);
|
||||
} catch (Exception ex) {
|
||||
log.error("下载失败,{}", ex.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
assert out != null;
|
||||
out.flush();
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 导出模板
|
||||
private static InputStream getResourcesFileInputStream(String fileName) {
|
||||
return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
|
||||
}
|
||||
|
||||
@PostMapping("/addDeviceColDefine")
|
||||
@ApiOperation(value = "新增告警字段定义")
|
||||
@LogAnnotation(title = "告警字段定义", action = "新增告警字段定义")
|
||||
public DataResult addDeviceColDefine(@RequestBody DeviceColDefineReqVO vo) {
|
||||
deviceColDefineService.addDeviceColDefine(vo);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/modifyDeviceColDefine")
|
||||
@ApiOperation(value = "修改告警字段定义")
|
||||
@LogAnnotation(title = "告警字段定义", action = "修改告警字段定义")
|
||||
public DataResult modifyDeviceColDefine(@RequestBody DeviceColDefineModifyVO vo) {
|
||||
if(vo.getInfo0().length()>200||vo.getInfo1().length()>200){
|
||||
throw new BusinessException(BaseResponseCode.PARAM_EXCEED_LENGTH);
|
||||
}
|
||||
deviceColDefineService.modifyDeviceColDefine(vo);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/deleteDeviceColDefine")
|
||||
@ApiOperation(value = "删除告警字段定义")
|
||||
@LogAnnotation(title = "告警字段定义", action = "删除告警字段定义")
|
||||
public DataResult deleteDeviceColDefine(@RequestBody DeviceColDefineDeleteVO vo) {
|
||||
if(vo.getIdList().size()==0){
|
||||
throw new BusinessException(BaseResponseCode.DELETE_ERROR_NO_DATA);
|
||||
}
|
||||
deviceColDefineService.deleteDeviceColDefine(vo);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/syncDeviceColDefine")
|
||||
@ApiOperation(value = "同步数据")
|
||||
@LogAnnotation(title = "告警字段定义", action = "同步告警字段定义")
|
||||
public DataResult syncDeviceColDefine(@RequestBody SynchronousReqVo vo) {
|
||||
deviceColDefineService.syncNewDeviceColDefine(vo);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/syncDeviceColDefines")
|
||||
@ApiOperation(value = "新同步数据")
|
||||
@LogAnnotation(title = "告警字段定义", action = "同步告警字段定义")
|
||||
public DataResult syncDeviceColDefines(@RequestBody DeviceColDefineSyncVO definePageReq) {
|
||||
deviceColDefineService.syncDeviceColDefine(definePageReq);
|
||||
return DataResult.success();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,792 @@
|
||||
package com.ho.flow.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.ho.business.entity.Device;
|
||||
import com.ho.business.entity.DeviceType;
|
||||
import com.ho.business.entity.Station;
|
||||
import com.ho.business.vo.req.EventColReq;
|
||||
import com.ho.business.vo.req.device.DeviceListReq;
|
||||
import com.ho.common.tools.annotation.LargeScreenToken;
|
||||
import com.ho.common.tools.annotation.LogAnnotation;
|
||||
import com.ho.common.tools.annotation.TokenIgnore;
|
||||
import com.ho.common.tools.constant.CommonConstant;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.constant.DefineConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
import com.ho.common.tools.entity.UserDetailRespVO;
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.BusinessException;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.flow.feignclient.BusinessFeignClient;
|
||||
import com.ho.flow.service.EventService;
|
||||
import com.ho.flow.vo.req.event.DropDownReq;
|
||||
import com.ho.flow.vo.req.event.EventNumReq;
|
||||
import com.ho.flow.vo.req.event.EventReqPageVO;
|
||||
import com.ho.flow.vo.req.event.EventWorkOrder;
|
||||
import com.ho.flow.vo.resp.event.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description 警告管理
|
||||
* Author yule
|
||||
* Date 2022/8/26 16:58
|
||||
*/
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT + "event")
|
||||
@RestController
|
||||
@Api(tags = "告警管理")
|
||||
public class EventController {
|
||||
|
||||
@Autowired
|
||||
private EventService eventService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private BusinessFeignClient businessFeignClient;
|
||||
|
||||
@Value("${event.currentMaxDay}")
|
||||
Integer currentMaxDay;
|
||||
|
||||
@Value("${event.bigScreenEventLimit}")
|
||||
Integer bigScreenEventLimit;
|
||||
|
||||
|
||||
/* @PostMapping("conversion")
|
||||
@ApiOperation(value = "转化工单接口")
|
||||
public DataResult conversion(@RequestBody List<Long> eventIds, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
eventService.conversionWorkOrder(eventIds, user);
|
||||
return DataResult.success();
|
||||
}*/
|
||||
@PostMapping("conversion")
|
||||
@ApiOperation(value = "转化工单接口")
|
||||
public DataResult conversion(@RequestBody @Valid EventWorkOrder eventWorkOrder, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
eventWorkOrder.setUserId(simpleUser.getUserId());
|
||||
eventWorkOrder.setGroupId(simpleUser.getGroupId());
|
||||
eventService.conversion(eventWorkOrder);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("page")
|
||||
@ApiOperation(value = "分页查询事件接口")
|
||||
//@LogAnnotation(title = "告警管理", action = "分页查询告警信息")
|
||||
public DataResult<PageResultMap<EventRespVO>> page(@RequestBody @Valid EventReqPageVO vo, HttpServletRequest
|
||||
request) {
|
||||
//如果有srcIdList ,则根据这个查询deviceType
|
||||
List<Integer> srcIdList = vo.getSrcIdList();
|
||||
|
||||
//这个不传的时候,说明没有选电站或设备,那么查全部就行
|
||||
// if(srcIdList!=null && !srcIdList.isEmpty()){
|
||||
// if(vo.getStationIds()!=null && !vo.getStationIds().isEmpty()){
|
||||
// Integer stationId = vo.getStationIds().get(0);
|
||||
// List<DeviceType> deviceTypes = getDeviceTypeByStationSrcIds(stationId, srcIdList);
|
||||
// vo.setDeviceTypeList(deviceTypes);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (srcIdList != null && !srcIdList.isEmpty()) {
|
||||
//虚拟设备
|
||||
List<Integer> virtualSrcIdList = srcIdList.stream().filter(i -> i < 0).collect(Collectors.toList());
|
||||
//实际设备
|
||||
List<Integer> realSrcIdList = srcIdList.stream().filter(i -> i >= 0).collect(Collectors.toList());
|
||||
vo.setSrcIdList(realSrcIdList);
|
||||
if (virtualSrcIdList.size() > 0) {
|
||||
DeviceListReq deviceListReq = new DeviceListReq();
|
||||
deviceListReq.setStationId(vo.getStationIds().get(0));
|
||||
deviceListReq.setSrcIdList(srcIdList);
|
||||
List<EventColReq> queryEventParamList = businessFeignClient.getQueryEventParam(deviceListReq);
|
||||
if (queryEventParamList.size() > 0) {
|
||||
vo.setSrcIdList(null);
|
||||
vo.setEventColReqList(queryEventParamList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//仅查询近期数据(根据配置参数)
|
||||
//计算当前天数和 max之前的天数
|
||||
Date now = new Date();
|
||||
//开始时间,currentMaxDay之前的那天
|
||||
String beginTime = DateUtil.format(DateUtil.offsetDay(now, currentMaxDay), CommonConstant.DATE_YMD)
|
||||
+ CommonConstant.START_SUFFIX_TIMESTAMP;
|
||||
//今天的23:59:59
|
||||
String endTime = DateUtil.format(DateUtil.endOfDay(now), CommonConstant.DATE);
|
||||
/* vo.setStartTime(beginTime);
|
||||
vo.setEndTime(endTime);*/
|
||||
DataResult<PageResultMap<EventRespVO>> result = DataResult.success();
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
|
||||
//得到这个人的电站集合
|
||||
List<Integer> stationIds = user.getStationIds();
|
||||
if (vo.getStationIds() == null || vo.getStationIds().isEmpty()) {
|
||||
vo.setStationIds(stationIds);
|
||||
}
|
||||
// 当用户传入电站为空,且该用户所关联的电站全部为空的时候,直接返回
|
||||
if (vo.getStationIds() == null || vo.getStationIds().isEmpty()) {
|
||||
PageResultMap<EventRespVO> pageResultMap = new PageResultMap<>();
|
||||
pageResultMap.setList(new ArrayList<EventRespVO>());
|
||||
Map<Integer, Integer> map = new HashMap<>();
|
||||
pageResultMap.setEventLevels(map);
|
||||
pageResultMap.setEventTypes(map);
|
||||
result.setData(pageResultMap);
|
||||
return result;
|
||||
}
|
||||
vo.setUserLevel(user.getUserLevel());
|
||||
//获取EventRespVO对象
|
||||
PageResult<EventRespVO> list = new PageResult<>();
|
||||
if (!(vo.getEventLevels().isEmpty() && vo.getEventTypes().isEmpty())) {
|
||||
/**************实时告警中不能出现已确认的数据********************/
|
||||
vo.setStatus(CommonConstant.ZERO);
|
||||
list = eventService.pageEventInfo(vo);
|
||||
}
|
||||
//获取告警等级和告警级别分别的数量
|
||||
EventNumRespVO eventNumRespVO = eventService.selectNum(vo, user);
|
||||
List<EventLevelNum> levelNums = eventNumRespVO.getLevelNums();
|
||||
Map<Integer, Integer> eventLevels = levelNums.stream().collect(Collectors.toMap(EventLevelNum::getEventLevel, EventLevelNum::getCount));
|
||||
//设置事件等级总数
|
||||
eventLevels.put(-1, eventNumRespVO.getSumLevels());
|
||||
List<EventTypeNum> typeNums = eventNumRespVO.getTypeNums();
|
||||
Map<Integer, Integer> eventTypes = typeNums.stream().collect(Collectors.toMap(EventTypeNum::getEventType, EventTypeNum::getCount));
|
||||
|
||||
//设置事件类型总数
|
||||
eventTypes.put(-1, eventNumRespVO.getSumTypes());
|
||||
//给返回值赋值
|
||||
PageResultMap<EventRespVO> map = new PageResultMap<>();
|
||||
BeanUtils.copyProperties(list, map);
|
||||
if (!eventTypes.isEmpty()) {
|
||||
map.setEventTypes(eventTypes);
|
||||
}
|
||||
if (!eventLevels.isEmpty()) {
|
||||
map.setEventLevels(eventLevels);
|
||||
}
|
||||
result.setData(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据srcIdList查对应设备类型
|
||||
private List<DeviceType> getDeviceTypeByStationSrcIds(Integer stationId, List<Integer> srcIdList) {
|
||||
if (srcIdList == null || srcIdList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<DeviceType> deviceTypeList = new ArrayList<>();
|
||||
DeviceListReq deviceListReq = new DeviceListReq();
|
||||
deviceListReq.setStationId(stationId);
|
||||
deviceListReq.setSrcIdList(srcIdList);
|
||||
//远程调用查询设备
|
||||
DataResult<List<Device>> result = businessFeignClient.selectDeviceByStationIdsAndSrcIdVirtual(deviceListReq);
|
||||
if (result.isSuccess()) {
|
||||
List<Device> data = result.getData();
|
||||
if (data != null && !data.isEmpty()) {
|
||||
for (Device datum : data) {
|
||||
if (datum.getDeviceType() != null) {
|
||||
DeviceType deviceType = new DeviceType();
|
||||
deviceType.setDeviceType(datum.getDeviceType());
|
||||
deviceTypeList.add(deviceType);
|
||||
}
|
||||
}
|
||||
}
|
||||
return deviceTypeList;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@PostMapping("hispage")
|
||||
@ApiOperation(value = "分页查询事件历史接口")
|
||||
//@LogAnnotation(title = "告警管理", action = "分页查询告警历史信息")
|
||||
public DataResult<PageResultMap<EventRespVO>> hispage(@RequestBody @Valid EventReqPageVO vo, HttpServletRequest
|
||||
request) {
|
||||
DataResult<PageResultMap<EventRespVO>> result = DataResult.success();
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
//如果有srcIdList ,则根据这个查询deviceType
|
||||
List<Integer> srcIdList = vo.getSrcIdList();
|
||||
|
||||
//这个不传的时候,说明没有选电站或设备,那么查全部就行
|
||||
// if (srcIdList != null && !srcIdList.isEmpty()) {
|
||||
// if (vo.getStationIds() != null && !vo.getStationIds().isEmpty()) {
|
||||
// Integer stationId = vo.getStationIds().get(0);
|
||||
// List<DeviceType> deviceTypes = getDeviceTypeByStationSrcIds(stationId, srcIdList);
|
||||
// vo.setDeviceTypeList(deviceTypes);
|
||||
// }
|
||||
// }
|
||||
if (srcIdList != null && !srcIdList.isEmpty()) {
|
||||
//虚拟设备
|
||||
List<Integer> virtualSrcIdList = srcIdList.stream().filter(i -> i < 0).collect(Collectors.toList());
|
||||
//实际设备
|
||||
List<Integer> realSrcIdList = srcIdList.stream().filter(i -> i >= 0).collect(Collectors.toList());
|
||||
vo.setSrcIdList(realSrcIdList);
|
||||
if (virtualSrcIdList.size() > 0) {
|
||||
DeviceListReq deviceListReq = new DeviceListReq();
|
||||
deviceListReq.setStationId(vo.getStationIds().get(0));
|
||||
deviceListReq.setSrcIdList(srcIdList);
|
||||
List<EventColReq> queryEventParamList = businessFeignClient.getQueryEventParam(deviceListReq);
|
||||
if (queryEventParamList.size() > 0) {
|
||||
vo.setSrcIdList(null);
|
||||
vo.setEventColReqList(queryEventParamList);
|
||||
}
|
||||
}
|
||||
}
|
||||
//得到这个人的电站集合
|
||||
List<Integer> stationIds = user.getStationIds();
|
||||
//这个人没有电站就返回空集合
|
||||
if (stationIds == null || stationIds.isEmpty()) {
|
||||
PageResultMap<EventRespVO> pageResultMap = new PageResultMap<>();
|
||||
pageResultMap.setList(new ArrayList<EventRespVO>());
|
||||
Map<Integer, Integer> map = new HashMap<>();
|
||||
pageResultMap.setEventLevels(map);
|
||||
pageResultMap.setEventTypes(map);
|
||||
result.setData(pageResultMap);
|
||||
return result;
|
||||
}
|
||||
if (vo.getStationIds() == null || vo.getStationIds().isEmpty()) {
|
||||
vo.setStationIds(stationIds);
|
||||
}
|
||||
//获取EventRespVO对象
|
||||
//2023-01-10 告警数据都从实时表中查询,
|
||||
//PageResult<EventRespVO> list = eventHisService.selectByInfo(vo,user);
|
||||
//给开始时间和结束时间加后缀
|
||||
if (vo.getStartTime() != null) {
|
||||
vo.setStartTime(vo.getStartTime() + CommonConstant.START_SUFFIX_TIMESTAMP);
|
||||
}
|
||||
if (vo.getEndTime() != null) {
|
||||
vo.setEndTime(vo.getEndTime() + CommonConstant.END_SUFFIX_TIMESTAMP);
|
||||
}
|
||||
PageResult<EventRespVO> list = new PageResult<>();
|
||||
vo.setUserLevel(user.getUserLevel());
|
||||
if (!(vo.getEventLevels().isEmpty() && vo.getEventTypes().isEmpty())) {
|
||||
/**************实时告警中不能出现已确认的数据********************/
|
||||
vo.setStatus(CommonConstant.ONE);
|
||||
list = eventService.pageEventInfo(vo);
|
||||
}
|
||||
//获取告警等级和告警级别分别的数量
|
||||
//EventNumRespVO eventNumRespVO = eventHisService.selectNum(vo,user);
|
||||
EventNumRespVO eventNumRespVO = eventService.selectNum(vo, user);
|
||||
List<EventLevelNum> levelNums = eventNumRespVO.getLevelNums();
|
||||
Map<Integer, Integer> eventLevels = levelNums.stream().collect(Collectors.toMap(EventLevelNum::getEventLevel, EventLevelNum::getCount));
|
||||
//设置事件等级总数
|
||||
eventLevels.put(-1, eventNumRespVO.getSumLevels());
|
||||
List<EventTypeNum> typeNums = eventNumRespVO.getTypeNums();
|
||||
Map<Integer, Integer> eventTypes = typeNums.stream().collect(Collectors.toMap(EventTypeNum::getEventType, EventTypeNum::getCount));
|
||||
|
||||
//设置事件类型总数
|
||||
eventTypes.put(-1, eventNumRespVO.getSumTypes());
|
||||
//给返回值赋值
|
||||
PageResultMap<EventRespVO> map = new PageResultMap<>();
|
||||
BeanUtils.copyProperties(list, map);
|
||||
if (!eventTypes.isEmpty()) {
|
||||
map.setEventTypes(eventTypes);
|
||||
}
|
||||
if (!eventLevels.isEmpty()) {
|
||||
map.setEventLevels(eventLevels);
|
||||
}
|
||||
result.setData(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过时接口,已被分页查询接口合并
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* @PostMapping("num")
|
||||
@ApiOperation(value = "查询告警等级数量接口")
|
||||
@LogAnnotation(title = "告警管理",action = "查询告警等级数量接口")
|
||||
public DataResult<EventNumRespVO> getNum(@RequestBody EventReqPageVO vo){
|
||||
DataResult<EventNumRespVO> result = DataResult.success();
|
||||
|
||||
result.setData(eventNumRespVO);
|
||||
return result;
|
||||
}*/
|
||||
@PutMapping("confirm")
|
||||
@ApiOperation(value = "告警清除接口")
|
||||
@LogAnnotation(title = "告警管理", action = "告警清除信息")
|
||||
//@HzPermission(PermissionConstant.EVENT_REALTIMEALARM_ALARMCLEARING)
|
||||
public DataResult confirm
|
||||
(@RequestBody @NotEmpty(message = "请先选择需要清除的数据") @Valid List<Long> ids, HttpServletRequest request) {
|
||||
DataResult result = DataResult.success();
|
||||
if (ids.isEmpty()) {
|
||||
throw new BusinessException(BaseResponseCode.EVENT_IDS_NOT_EMPTY);
|
||||
}
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
UserDetailRespVO userDetail = redisService.getUserDetailByToken(token);
|
||||
eventService.updateById(ids, userDetail);
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/eventList")
|
||||
@ApiOperation(value = "查询事件接口(大屏专用 ,不分页)")
|
||||
@TokenIgnore
|
||||
@LargeScreenToken
|
||||
public DataResult<EventBigScreenResp> eventList(HttpServletRequest request) {
|
||||
EventBigScreenResp eventBigScreenResp = new EventBigScreenResp();
|
||||
//仅查询近期数据(根据配置参数)
|
||||
//计算当前天数和 max之前的天数
|
||||
Date now = new Date();
|
||||
//开始时间,currentMaxDay之前的那天
|
||||
String beginTime = DateUtil.format(DateUtil.offsetDay(now, currentMaxDay), CommonConstant.DATE_YMD)
|
||||
+ CommonConstant.START_SUFFIX_TIMESTAMP;
|
||||
EventReqPageVO vo = new EventReqPageVO();
|
||||
//今天的23:59:59
|
||||
String endTime = DateUtil.format(DateUtil.endOfDay(now), CommonConstant.DATE);
|
||||
vo.setStartTime(beginTime);
|
||||
vo.setEndTime(endTime);
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByBigScreenToken(token);
|
||||
//得到这个人的电站集合
|
||||
DataResult<List<Station>> result = businessFeignClient.selectByGroupId(user.getGroupId());
|
||||
List<Station> stations = result.getData();
|
||||
//如果电站为空就应该为告警事件
|
||||
if (stations.isEmpty()) {
|
||||
eventBigScreenResp.setAlarmNum(0);
|
||||
eventBigScreenResp.setConfirmNum(0);
|
||||
eventBigScreenResp.setEventRespVOS(new ArrayList<>());
|
||||
return DataResult.success(eventBigScreenResp);
|
||||
}
|
||||
List<Integer> stationIds = stations.stream().map(s -> {
|
||||
return s.getId();
|
||||
}
|
||||
).collect(Collectors.toList());
|
||||
if (vo.getStationIds() == null || vo.getStationIds().isEmpty()) {
|
||||
vo.setStationIds(stationIds);
|
||||
}
|
||||
//限制最大条数, 防止数据过大
|
||||
vo.setLimitCount(bigScreenEventLimit);
|
||||
//查询告警数据
|
||||
List<EventRespVO> eventRespVOS = eventService.eventList(vo);
|
||||
//告警次数
|
||||
Integer alarmNum = 0;
|
||||
//确认次数
|
||||
Integer confirmNum = 0;
|
||||
//累加告警次数和确认次数
|
||||
for (EventRespVO event : eventRespVOS) {
|
||||
if (CommonConstant.EventType.alarm.equals(event.getEventType())) {
|
||||
alarmNum++;
|
||||
}
|
||||
if (CommonConstant.ONE.equals(event.getStatus())) {
|
||||
confirmNum++;
|
||||
}
|
||||
}
|
||||
|
||||
eventBigScreenResp.setEventRespVOS(eventRespVOS);
|
||||
eventBigScreenResp.setAlarmNum(alarmNum);
|
||||
eventBigScreenResp.setConfirmNum(confirmNum);
|
||||
return DataResult.success(eventBigScreenResp);
|
||||
}
|
||||
|
||||
@PostMapping("/dropDownList")
|
||||
@ApiOperation(value = "下拉列表告警数据")
|
||||
public DataResult<List<EventRespVO>> dropDownList(@RequestBody @Valid DropDownReq req, HttpServletRequest
|
||||
request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
List<EventRespVO> list = eventService.getDropDownList(user, req);
|
||||
return DataResult.success(list);
|
||||
}
|
||||
|
||||
@PostMapping("/dropDownBatchList")
|
||||
@ApiOperation(value = "批量下拉列表告警数据")
|
||||
public DataResult<List<EventRespVO>> dropDownBatchList(@RequestBody @Valid List<DropDownReq> list, HttpServletRequest
|
||||
request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
List<EventRespVO> eventRespVOList = eventService.dropDownBatchList(user, list);
|
||||
return DataResult.success(eventRespVOList);
|
||||
}
|
||||
|
||||
@PostMapping("eventNum")
|
||||
@ApiOperation(value = "告警数目(给页面头部那个告警铃铛调用)")
|
||||
public DataResult eventNum(@RequestBody EventNumReq eventNumReq, HttpServletRequest request) {
|
||||
DataResult result = DataResult.success();
|
||||
//仅查询近期数据(根据配置参数)
|
||||
//计算当前天数和 max之前的天数
|
||||
Date now = new Date();
|
||||
//开始时间,currentMaxDay之前的那天
|
||||
String beginTime = DateUtil.format(DateUtil.offsetDay(now, currentMaxDay), CommonConstant.DATE_YMD)
|
||||
+ CommonConstant.START_SUFFIX_TIMESTAMP;
|
||||
//今天的23:59:59
|
||||
String endTime = DateUtil.format(DateUtil.endOfDay(now), CommonConstant.DATE);
|
||||
EventReqPageVO vo = new EventReqPageVO();
|
||||
/* vo.setStartTime(beginTime);
|
||||
vo.setEndTime(endTime);*/
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
Integer stationId = eventNumReq.getStationId();
|
||||
if (null != stationId) {
|
||||
List<Integer> stationIds = new ArrayList<>();
|
||||
stationIds.add(stationId);
|
||||
vo.setStationIds(stationIds);
|
||||
}
|
||||
//得到这个人的电站集合
|
||||
List<Integer> stationIds = user.getStationIds();
|
||||
if (vo.getStationIds() == null || vo.getStationIds().isEmpty()) {
|
||||
vo.setStationIds(stationIds);
|
||||
}
|
||||
// 当用户传入电站为空,且该用户所关联的电站全部为空的时候,直接返回
|
||||
if (vo.getStationIds() == null || vo.getStationIds().isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
//默认统计是事故和异常和告警
|
||||
List<Integer> levelList = new ArrayList<>();
|
||||
levelList.add(CommonConstant.ONE);
|
||||
levelList.add(CommonConstant.TWO);
|
||||
levelList.add(CommonConstant.THREE);
|
||||
vo.setUserLevel(user.getUserLevel());
|
||||
vo.setEventLevels(levelList);
|
||||
//获取EventRespVO对象
|
||||
int num = eventService.eventNum(vo, user);
|
||||
result.setData(num);
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/realTimeAlarm")
|
||||
@ApiOperation(value = "查询事件接口(12-14新大屏)")
|
||||
@TokenIgnore
|
||||
public DataResult<List<EventRespVO>> getRealTimeAlarm(HttpServletRequest request) {
|
||||
//得到这个人的电站集合
|
||||
DataResult<List<Station>> result = businessFeignClient.selectStationSNAll();
|
||||
List<Station> stations = result.getData();
|
||||
//如果电站为空就应该为告警事件
|
||||
if (stations.isEmpty()) {
|
||||
return DataResult.success(new ArrayList<>());
|
||||
}
|
||||
List<Station> list = new ArrayList<>();
|
||||
stations.stream().filter(i -> CommonConstant.ONE.equals(i.getStatus())).forEach(s -> list.add(s));
|
||||
List<Integer> stationIds = list.stream().map(s -> {
|
||||
return s.getId();
|
||||
}
|
||||
).collect(Collectors.toList());
|
||||
|
||||
EventReqPageVO vo = new EventReqPageVO();
|
||||
if (vo.getStationIds() == null || vo.getStationIds().isEmpty()) {
|
||||
vo.setStationIds(stationIds);
|
||||
}
|
||||
//查询告警数据
|
||||
vo.setStatus(CommonConstant.ZERO);
|
||||
List<EventRespVO> eventRespVOS = eventService.eventList(vo);
|
||||
//根据告警产生时间倒叙
|
||||
eventRespVOS.stream().sorted(Comparator.comparing(EventRespVO::getTimeStamp).reversed()).limit(30).collect(Collectors.toList());
|
||||
Map<Integer, String> stationStatusMap = stations.stream()
|
||||
.collect(Collectors.toMap(Station::getId, Station::getName));
|
||||
for (EventRespVO eventRespVO : eventRespVOS) {
|
||||
if (stationStatusMap.containsKey(eventRespVO.getStationId())) {
|
||||
eventRespVO.setStationName(stationStatusMap.get(eventRespVO.getStationId()));
|
||||
}
|
||||
}
|
||||
return DataResult.success(eventRespVOS);
|
||||
}
|
||||
|
||||
|
||||
//告警数据导出
|
||||
//历史告警数据导出
|
||||
|
||||
|
||||
/**
|
||||
* 告警数据导出
|
||||
*
|
||||
* @param response
|
||||
*/
|
||||
@PostMapping("/exportEvnData")
|
||||
@ApiOperation(value = "导出实时告警数据")
|
||||
public void exportEvnData(@RequestBody @Valid EventReqPageVO vo, HttpServletRequest request, HttpServletResponse response) {
|
||||
//如果有srcIdList ,则根据这个查询deviceType
|
||||
List<Integer> srcIdList = vo.getSrcIdList();
|
||||
if (srcIdList != null && !srcIdList.isEmpty()) {
|
||||
//虚拟设备
|
||||
List<Integer> virtualSrcIdList = srcIdList.stream().filter(i -> i < 0).collect(Collectors.toList());
|
||||
//实际设备
|
||||
List<Integer> realSrcIdList = srcIdList.stream().filter(i -> i >= 0).collect(Collectors.toList());
|
||||
vo.setSrcIdList(realSrcIdList);
|
||||
if (virtualSrcIdList.size() > 0) {
|
||||
DeviceListReq deviceListReq = new DeviceListReq();
|
||||
deviceListReq.setStationId(vo.getStationIds().get(0));
|
||||
deviceListReq.setSrcIdList(srcIdList);
|
||||
List<EventColReq> queryEventParamList = businessFeignClient.getQueryEventParam(deviceListReq);
|
||||
if (queryEventParamList.size() > 0) {
|
||||
vo.setSrcIdList(null);
|
||||
vo.setEventColReqList(queryEventParamList);
|
||||
}
|
||||
}
|
||||
}
|
||||
//仅查询近期数据(根据配置参数)
|
||||
//计算当前天数和 max之前的天数
|
||||
Date now = new Date();
|
||||
//开始时间,currentMaxDay之前的那天
|
||||
String beginTime = DateUtil.format(DateUtil.offsetDay(now, currentMaxDay), CommonConstant.DATE_YMD)
|
||||
+ CommonConstant.START_SUFFIX_TIMESTAMP;
|
||||
//今天的23:59:59
|
||||
String endTime = DateUtil.format(DateUtil.endOfDay(now), CommonConstant.DATE);
|
||||
vo.setStartTime(beginTime);
|
||||
vo.setEndTime(endTime);
|
||||
DataResult<PageResultMap<EventRespVO>> result = DataResult.success();
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
|
||||
//得到这个人的电站集合
|
||||
List<Integer> stationIds = user.getStationIds();
|
||||
if (vo.getStationIds() == null || vo.getStationIds().isEmpty()) {
|
||||
vo.setStationIds(stationIds);
|
||||
}
|
||||
// 当用户传入电站为空,且该用户所关联的电站全部为空的时候,直接返回
|
||||
if (vo.getStationIds() == null || vo.getStationIds().isEmpty()) {
|
||||
throw new BusinessException(BaseResponseCode.STATION_DATA_NULL_IMPORT_ERROR);
|
||||
//电站为空,导出异常
|
||||
}
|
||||
vo.setUserLevel(user.getUserLevel());
|
||||
//获取EventRespVO对象
|
||||
List<EventRespVO> list = new ArrayList<>();
|
||||
if (!(vo.getEventLevels().isEmpty() && vo.getEventTypes().isEmpty())) {
|
||||
list = eventService.eventInfo(vo);
|
||||
}
|
||||
List<ExportEvnData> resultList = replaceList(list);
|
||||
//在内存操作,写到浏览器
|
||||
ExcelWriter writer = ExcelUtil.getWriter(true);
|
||||
//自定义标题别名
|
||||
writer.addHeaderAlias("stationName", DefineConstant.Event.STATION_NAME);
|
||||
writer.addHeaderAlias("deviceName", DefineConstant.Event.DEVICE_TYPE);
|
||||
writer.addHeaderAlias("name", DefineConstant.Event.DEVICE_NAME);
|
||||
writer.addHeaderAlias("status", DefineConstant.Event.STATUS);
|
||||
writer.addHeaderAlias("eventLevel", DefineConstant.Event.EVENT_LEVEL);
|
||||
writer.addHeaderAlias("timeStamp", DefineConstant.Event.TIME_STAMP);
|
||||
writer.addHeaderAlias("description", DefineConstant.Event.DESCRIPTION);
|
||||
writer.addHeaderAlias("confirmMan", DefineConstant.Event.CONFIRM_MAN);
|
||||
writer.addHeaderAlias("confirmTime", DefineConstant.Event.CONFIRM_TIME);
|
||||
writer.addHeaderAlias("remark", DefineConstant.Event.REMARK);
|
||||
//默认配置
|
||||
writer.write(resultList, true);
|
||||
//自适应宽度
|
||||
widthUtils(writer.getSheet(), 10);
|
||||
//设置content—type
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.addHeader("Access-Control-Expose-Headers", "Content-disposition");
|
||||
response.setHeader("Pragma", "No-cache");
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
ServletOutputStream outputStream = null;
|
||||
try {
|
||||
String fileName = "实时告警数据.xlsx";
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName);
|
||||
outputStream = response.getOutputStream();
|
||||
//将Writer刷新到OutPut
|
||||
writer.flush(outputStream, true);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史告警数据导出
|
||||
*
|
||||
* @param response
|
||||
*/
|
||||
@PostMapping("/exportHisEvnData")
|
||||
@ApiOperation(value = "历史告警数据导出")
|
||||
public void exportHisEvnData(@RequestBody @Valid EventReqPageVO vo, HttpServletRequest request, HttpServletResponse response) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
//如果有srcIdList ,则根据这个查询deviceType
|
||||
List<Integer> srcIdList = vo.getSrcIdList();
|
||||
if (srcIdList != null && !srcIdList.isEmpty()) {
|
||||
//虚拟设备
|
||||
List<Integer> virtualSrcIdList = srcIdList.stream().filter(i -> i < 0).collect(Collectors.toList());
|
||||
//实际设备
|
||||
List<Integer> realSrcIdList = srcIdList.stream().filter(i -> i >= 0).collect(Collectors.toList());
|
||||
vo.setSrcIdList(realSrcIdList);
|
||||
if (virtualSrcIdList.size() > 0) {
|
||||
DeviceListReq deviceListReq = new DeviceListReq();
|
||||
deviceListReq.setStationId(vo.getStationIds().get(0));
|
||||
deviceListReq.setSrcIdList(srcIdList);
|
||||
List<EventColReq> queryEventParamList = businessFeignClient.getQueryEventParam(deviceListReq);
|
||||
if (queryEventParamList.size() > 0) {
|
||||
vo.setSrcIdList(null);
|
||||
vo.setEventColReqList(queryEventParamList);
|
||||
}
|
||||
}
|
||||
}
|
||||
//得到这个人的电站集合
|
||||
List<Integer> stationIds = user.getStationIds();
|
||||
//这个人没有电站就返回空集合
|
||||
if (stationIds == null || stationIds.isEmpty()) {
|
||||
throw new BusinessException(BaseResponseCode.STATION_DATA_NULL_IMPORT_ERROR);
|
||||
//电站为空,导出异常
|
||||
}
|
||||
if (vo.getStationIds() == null || vo.getStationIds().isEmpty()) {
|
||||
vo.setStationIds(stationIds);
|
||||
}
|
||||
if (vo.getStartTime() != null) {
|
||||
vo.setStartTime(vo.getStartTime() + CommonConstant.START_SUFFIX_TIMESTAMP);
|
||||
}
|
||||
if (vo.getEndTime() != null) {
|
||||
vo.setEndTime(vo.getEndTime() + CommonConstant.END_SUFFIX_TIMESTAMP);
|
||||
}
|
||||
List<EventRespVO> list = new ArrayList<>();
|
||||
vo.setUserLevel(user.getUserLevel());
|
||||
if (!(vo.getEventLevels().isEmpty() && vo.getEventTypes().isEmpty())) {
|
||||
list = eventService.eventInfo(vo);
|
||||
}
|
||||
List<ExportEvnData> resultList = replaceList(list);
|
||||
String fileName = "历史告警数据.xlsx";
|
||||
//在内存操作,写到浏览器
|
||||
ExcelWriter writer = ExcelUtil.getWriter(true);
|
||||
//自定义标题别名
|
||||
writer.addHeaderAlias("stationName", DefineConstant.Event.STATION_NAME);
|
||||
writer.addHeaderAlias("deviceName", DefineConstant.Event.DEVICE_TYPE);
|
||||
writer.addHeaderAlias("name", DefineConstant.Event.DEVICE_NAME);
|
||||
writer.addHeaderAlias("status", DefineConstant.Event.STATUS);
|
||||
writer.addHeaderAlias("eventLevel", DefineConstant.Event.EVENT_LEVEL);
|
||||
writer.addHeaderAlias("timeStamp", DefineConstant.Event.TIME_STAMP);
|
||||
writer.addHeaderAlias("description", DefineConstant.Event.DESCRIPTION);
|
||||
writer.addHeaderAlias("confirmMan", DefineConstant.Event.CONFIRM_MAN);
|
||||
writer.addHeaderAlias("confirmTime", DefineConstant.Event.CONFIRM_TIME);
|
||||
writer.addHeaderAlias("remark", DefineConstant.Event.REMARK);
|
||||
//默认配置
|
||||
writer.write(resultList, true);
|
||||
//自适应宽度
|
||||
widthUtils(writer.getSheet(), 10);
|
||||
//设置content—type
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.addHeader("Access-Control-Expose-Headers", "Content-disposition");
|
||||
response.setHeader("Pragma", "No-cache");
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
ServletOutputStream outputStream = null;
|
||||
try {
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName);
|
||||
outputStream = response.getOutputStream();
|
||||
//将Writer刷新到OutPut
|
||||
writer.flush(outputStream, true);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
public List<ExportEvnData> replaceList(List<EventRespVO> list) {
|
||||
List<ExportEvnData> resultList = new ArrayList<>();
|
||||
for (EventRespVO eventRespVO : list) {
|
||||
ExportEvnData exportEvnData = new ExportEvnData();
|
||||
exportEvnData.setStationName(eventRespVO.getStationName());
|
||||
exportEvnData.setDeviceName(eventRespVO.getDeviceName());
|
||||
exportEvnData.setName(eventRespVO.getName());
|
||||
if (eventRespVO.getStatus() != null) {
|
||||
if (CommonConstant.ONE.equals(eventRespVO.getStatus())) {
|
||||
exportEvnData.setStatus(DefineConstant.Event.CONFIRMED);
|
||||
} else if (CommonConstant.ZERO.equals(eventRespVO.getStatus())) {
|
||||
exportEvnData.setStatus(DefineConstant.Event.UNCONFIRMED);
|
||||
}
|
||||
}
|
||||
//一级(事故)2二级(故障)3三级(告警)4四级(提示)5;//五级(告知)")
|
||||
if (eventRespVO.getEventLevel() != null) {
|
||||
if (CommonConstant.ONE.equals(eventRespVO.getEventLevel())) {
|
||||
exportEvnData.setEventLevel(DefineConstant.Event.ACCIDENT);
|
||||
} else if (CommonConstant.TWO.equals(eventRespVO.getEventLevel())) {
|
||||
exportEvnData.setEventLevel(DefineConstant.Event.FAULT);
|
||||
} else if (CommonConstant.THREE.equals(eventRespVO.getEventLevel())) {
|
||||
exportEvnData.setEventLevel(DefineConstant.Event.ALARM);
|
||||
} else if (CommonConstant.FOUR.equals(eventRespVO.getEventLevel())) {
|
||||
exportEvnData.setEventLevel(DefineConstant.Event.PROMPT);
|
||||
} else if (CommonConstant.FIVE.equals(eventRespVO.getEventLevel())) {
|
||||
exportEvnData.setEventLevel(DefineConstant.Event.INFORM);
|
||||
}
|
||||
}
|
||||
exportEvnData.setTimeStamp(eventRespVO.getTimeStamp());
|
||||
exportEvnData.setDescription(eventRespVO.getDescription());
|
||||
exportEvnData.setConfirmMan(eventRespVO.getConfirmMan());
|
||||
exportEvnData.setConfirmTime(eventRespVO.getConfirmTime());
|
||||
exportEvnData.setRemark(eventRespVO.getRemark());
|
||||
exportEvnData.setName(eventRespVO.getName());
|
||||
exportEvnData.setName(eventRespVO.getName());
|
||||
resultList.add(exportEvnData);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
public void widthUtils(Sheet sheet, int size) {
|
||||
for (int columnNum = 0; columnNum <= size; columnNum++) {
|
||||
int columnWidth = sheet.getColumnWidth(columnNum) / 256;
|
||||
for (int rowNum = 0; rowNum <= sheet.getLastRowNum(); rowNum++) {
|
||||
Row currentRow;
|
||||
//当前行未被使用过
|
||||
if (sheet.getRow(rowNum) == null) {
|
||||
currentRow = sheet.createRow(rowNum);
|
||||
} else {
|
||||
currentRow = sheet.getRow(rowNum);
|
||||
}
|
||||
|
||||
if (currentRow.getCell(columnNum) != null) {
|
||||
Cell currentCell = currentRow.getCell(columnNum);
|
||||
if (currentCell.getCellType() == CellType.STRING) {
|
||||
int length = currentCell.getStringCellValue().getBytes().length + 5;
|
||||
if (columnWidth < length) {
|
||||
columnWidth = length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sheet.setColumnWidth(columnNum, columnWidth * 256 + 5);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 告警设备统计
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
@PostMapping("/eventDeviceNum")
|
||||
@ApiOperation(value = "告警设备统计")
|
||||
public DataResult eventDeviceNum(@RequestBody @Valid EventNumReq vo) {
|
||||
Map<String,Integer> result = new HashMap<>();
|
||||
result = eventService.eventDeviceNum(vo);
|
||||
return DataResult.success(result);
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,601 @@
|
||||
package com.ho.flow.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ho.business.entity.DeviceTypeCol;
|
||||
import com.ho.business.vo.DeviceTypeList;
|
||||
import com.ho.business.vo.req.EventColReq;
|
||||
import com.ho.business.vo.req.MonitorQuery;
|
||||
import com.ho.business.vo.req.device.DeviceListReq;
|
||||
import com.ho.common.tools.annotation.TokenIgnore;
|
||||
import com.ho.common.tools.constant.CommonConstant;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.ProcessOrder;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
import com.ho.common.tools.entity.UserDetailRespVO;
|
||||
import com.ho.common.tools.entity.WorkOrderPicture;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.flow.constant.FlowConstant;
|
||||
import com.ho.flow.entity.SendSmsConfig;
|
||||
import com.ho.flow.entity.WorkOrderPlan;
|
||||
import com.ho.flow.entity.WorkOrderPlanSub;
|
||||
import com.ho.flow.entity.WorkOrderSub;
|
||||
import com.ho.flow.entity.process.MovementDTO;
|
||||
import com.ho.flow.feignclient.BusinessFeignClient;
|
||||
import com.ho.flow.feignclient.UserFeignClient;
|
||||
import com.ho.flow.mapper.WorkOrderPlanMapper;
|
||||
import com.ho.flow.mapper.WorkOrderPlanSubMapper;
|
||||
import com.ho.flow.mapper.WorkOrderSubMapper;
|
||||
import com.ho.flow.monitor.EventToProcessMonitor;
|
||||
import com.ho.flow.service.*;
|
||||
import com.ho.flow.service.process.service.ProcessFlowNewService;
|
||||
import com.ho.flow.vo.AlarmConfig;
|
||||
import com.ho.flow.vo.Event;
|
||||
import com.ho.flow.vo.req.AlarmConfig.AlarmConfigQueryVo;
|
||||
import com.ho.flow.vo.req.SendSmsConfig.SendSmsConfigQueryReq;
|
||||
import com.ho.flow.vo.req.event.*;
|
||||
import com.ho.flow.vo.resp.StationStatusRespVO;
|
||||
import com.ho.flow.vo.resp.event.*;
|
||||
import com.ho.user.api.vo.req.SysSubDictVO;
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.Font;
|
||||
import com.itextpdf.text.PageSize;
|
||||
import com.itextpdf.text.Paragraph;
|
||||
import com.itextpdf.text.pdf.BaseFont;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jfree.chart.ChartFactory;
|
||||
import org.jfree.chart.ChartUtils;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
import org.jfree.chart.axis.CategoryAxis;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.data.category.DefaultCategoryDataset;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description 提供给外部调用,不校验token
|
||||
* Author yule
|
||||
* Date 2023/2/6 10:08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT + "outerApi")
|
||||
@Api(tags = "测试")
|
||||
@Slf4j
|
||||
public class OuterApiController {
|
||||
|
||||
@Autowired
|
||||
ProcessFlowService processFlowService;
|
||||
|
||||
@Autowired
|
||||
WorkOrderService workOrderService;
|
||||
|
||||
@Autowired
|
||||
DeviceColDefineService deviceColDefineService;
|
||||
|
||||
|
||||
@Autowired
|
||||
EventService eventService;
|
||||
|
||||
@Autowired
|
||||
WorkOrderPictureService workOrderPictureService;
|
||||
|
||||
@Autowired
|
||||
AlarmConfigService alarmConfigService;
|
||||
|
||||
@Autowired
|
||||
SendSmsConfigService sendSmsConfigService;
|
||||
|
||||
@Autowired
|
||||
FlowOutApiService flowOutApiService;
|
||||
|
||||
@Autowired
|
||||
Snowflake snowflake;
|
||||
|
||||
@Autowired
|
||||
WorkOrderPlanMapper workOrderPlanMapper;
|
||||
|
||||
@Autowired
|
||||
WorkOrderPlanSubMapper workOrderPlanSubMapper;
|
||||
|
||||
@Autowired
|
||||
WorkOrderSubMapper workOrderSubMapper;
|
||||
|
||||
@Autowired
|
||||
BusinessFeignClient businessFeignClient;
|
||||
|
||||
@Autowired
|
||||
UserFeignClient userFeignClient;
|
||||
|
||||
@Autowired
|
||||
ProcessFlowNewService processFlowNewService;
|
||||
|
||||
EventToProcessMonitor monitor = new EventToProcessMonitor();
|
||||
|
||||
@Value("${spring.activiti.flag}")
|
||||
private Integer flag;
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
String env;
|
||||
|
||||
@Value("${openRedis.host}")
|
||||
String host;
|
||||
|
||||
@Value("${openRedis.port}")
|
||||
String port;
|
||||
|
||||
@Value("${openRedis.pass}")
|
||||
String pass;
|
||||
|
||||
@Value("${openTestRedis.host}")
|
||||
String testHost;
|
||||
|
||||
@Value("${openTestRedis.port}")
|
||||
String testPort;
|
||||
|
||||
@Value("${openTestRedis.pass}")
|
||||
String testPass;
|
||||
|
||||
//新增告警数据入库
|
||||
@PostMapping("addEvents")
|
||||
@TokenIgnore
|
||||
public DataResult addEvents(@RequestBody EventAddReq eventAddReq) {
|
||||
List<EventAddReq> list = new ArrayList<>();
|
||||
list.add(eventAddReq);
|
||||
DataResult dataResult = flowOutApiService.addEvents(list);
|
||||
return dataResult;
|
||||
}
|
||||
|
||||
@PostMapping("addEventsList")
|
||||
@TokenIgnore
|
||||
public DataResult addEventsList(@RequestBody List<EventAddReq> list) {
|
||||
flowOutApiService.addEvents(list);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
//新增图片数据入库
|
||||
@PostMapping("/addPicture")
|
||||
@TokenIgnore
|
||||
public WorkOrderPicture addPicture(@RequestBody String url) {
|
||||
WorkOrderPicture picture = workOrderPictureService.insertPicture(url);
|
||||
return picture;
|
||||
}
|
||||
|
||||
@PostMapping("/selectPictureById")
|
||||
@TokenIgnore
|
||||
public WorkOrderPicture selectPictureById(@RequestBody Integer id) {
|
||||
WorkOrderPicture workOrderPicture = workOrderPictureService.selectById(id);
|
||||
return workOrderPicture;
|
||||
}
|
||||
|
||||
@PostMapping("/selectWorkOrderByStationId")
|
||||
@TokenIgnore
|
||||
public DataResult<Integer> selectWorkOrderByStationId(@RequestBody Integer stationId) {
|
||||
Integer orderNum = workOrderService.selectByStationId(stationId);
|
||||
return DataResult.success(orderNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断设备是否正常
|
||||
*
|
||||
* @param alarmConfigQueryVo
|
||||
* @return true代表正常,false代表异常
|
||||
*/
|
||||
@PostMapping("/isRecoveryDevice")
|
||||
@TokenIgnore
|
||||
public Boolean isRecoveryDevice(@RequestBody AlarmConfigQueryVo alarmConfigQueryVo) {
|
||||
return flowOutApiService.isRecoveryDevice(alarmConfigQueryVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断电站是否在正常
|
||||
*
|
||||
* @param stationStatusReq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/isNormalStation")
|
||||
@TokenIgnore
|
||||
public DataResult<List<StationStatusRespVO>> isNormalStation(@RequestBody AlarmConfigQueryVo stationStatusReq) {
|
||||
return DataResult.success(flowOutApiService.isNormalStation(stationStatusReq));
|
||||
}
|
||||
|
||||
@PostMapping("/selectEventByParams")
|
||||
@TokenIgnore
|
||||
public Event selectEventByParams(@RequestBody EventQueryReqVO eventQueryReqVO) {
|
||||
Event event = new Event();
|
||||
event.setStationId(eventQueryReqVO.getStationId());
|
||||
event.setTargetDevice(eventQueryReqVO.getTargetDevice());
|
||||
event.setSignal(eventQueryReqVO.getSignal());
|
||||
return eventService.selectByParams(event);
|
||||
}
|
||||
|
||||
@PostMapping("planAddWorkOrder")
|
||||
@TokenIgnore
|
||||
public void planAddWorkOrder() {
|
||||
//查出所有工单计划
|
||||
List<WorkOrderPlan> workOrderPlans = workOrderPlanMapper.selectAll();
|
||||
//当前时间
|
||||
Date now = new Date();
|
||||
for (WorkOrderPlan workOrderPlan : workOrderPlans) {
|
||||
//获取到生效时间段
|
||||
Date effectDate = workOrderPlan.getEffectDate();
|
||||
Date expireDate = workOrderPlan.getExpireDate();
|
||||
//判断是否在生效时间段类
|
||||
try {
|
||||
if (effectDate != null && expireDate != null) {
|
||||
//判断是否有在有效时间段
|
||||
boolean flag = DateUtil.isIn(now, effectDate, expireDate);
|
||||
if (flag) {
|
||||
addWorkOrder(workOrderPlan);
|
||||
}
|
||||
} else {
|
||||
addWorkOrder(workOrderPlan);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("工单计划执行失败,失败的工单计划id:{}", workOrderPlan.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 计划新增工单数据
|
||||
*
|
||||
* @param workOrderPlan 工单计划
|
||||
*/
|
||||
private void addWorkOrder(WorkOrderPlan workOrderPlan) {
|
||||
//当前时间
|
||||
Date now = new Date();
|
||||
if (workOrderPlan.getDateType() != null) {
|
||||
//查询计划执行人(所有类型)
|
||||
List<WorkOrderPlanSub> workOrderPlanSubs = workOrderPlanSubMapper.selectByPid(workOrderPlan.getId());
|
||||
List<String> userIds = workOrderPlanSubs.stream().filter(s -> {
|
||||
return CommonConstant.WorkOrderPlanSubType.PERSON.equals(s.getType());
|
||||
}).map(WorkOrderPlanSub::getUserId).collect(Collectors.toList());
|
||||
//查询出电站以及设备的子表数据
|
||||
List<WorkOrderSub> workOrderSubs = workOrderPlanSubs.stream().filter(s -> {
|
||||
return !CommonConstant.WorkOrderPlanSubType.PERSON.equals(s.getType());
|
||||
}).map(s -> {
|
||||
WorkOrderSub workOrderSub = new WorkOrderSub();
|
||||
BeanUtils.copyProperties(s, workOrderSub);
|
||||
workOrderSub.setSrcId(s.getSrcId().longValue());
|
||||
return workOrderSub;
|
||||
}).collect(Collectors.toList());
|
||||
//对比执行时间是否为当前时间
|
||||
//执行周期分为三种(月,周,天)
|
||||
if (CommonConstant.MONTH.equals(workOrderPlan.getDateType())) {
|
||||
//查询当前月份的号数
|
||||
int i = DateUtil.dayOfMonth(now);
|
||||
if (i == workOrderPlan.getDay()) {
|
||||
processFlowService.planAddWorkOrder(workOrderPlan, userIds, workOrderSubs);
|
||||
}
|
||||
} else if (CommonConstant.WEEK.equals(workOrderPlan.getDateType())) {
|
||||
//1表示周日,2表示周一
|
||||
int i = DateUtil.dayOfWeek(now);
|
||||
Integer day = workOrderPlan.getDay();
|
||||
if (i == 1) {
|
||||
i = 7;
|
||||
if (i == day) {
|
||||
processFlowService.planAddWorkOrder(workOrderPlan, userIds, workOrderSubs);
|
||||
}
|
||||
} else if (i > 1 && i <= 7) {
|
||||
i = i - 1;
|
||||
if (i == day) {
|
||||
processFlowService.planAddWorkOrder(workOrderPlan, userIds, workOrderSubs);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (CommonConstant.DAY.equals(workOrderPlan.getDateType())) {
|
||||
processFlowService.planAddWorkOrder(workOrderPlan, userIds, workOrderSubs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 部署工作流
|
||||
*
|
||||
* @param groupId 集团id
|
||||
*/
|
||||
@PostMapping("deploymentWorkflow")
|
||||
@TokenIgnore
|
||||
public DataResult deploymentWorkflow(@RequestBody Integer groupId) {
|
||||
processFlowService.deploymentWorkflow(groupId);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断电站接入点状态(是否产生告警数据)定时任务
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("accessPointEvent")
|
||||
@TokenIgnore
|
||||
public DataResult accessPointEvent() {
|
||||
eventService.accessPointEvent();
|
||||
//判断外接电表状态(是否产生告警数据)定时任务
|
||||
eventService.outsideEleEvent();
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
// @PostMapping("outsideEleEvent")
|
||||
// @TokenIgnore
|
||||
// public DataResult outsideEleEvent() {
|
||||
// eventService.outsideEleEvent();
|
||||
// return DataResult.success();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 判断告警类型为告警等级(等级为3)定时发生短信任务
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("regularlySendNotifications")
|
||||
@TokenIgnore
|
||||
public DataResult regularlySendNotifications(@RequestBody MonitorQuery monitorQuery) {
|
||||
log.info("jobIntegratedCabinet, {}", monitorQuery);
|
||||
eventService.regularlySendNotifications(monitorQuery);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时删除图片和文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("deletedPicture")
|
||||
@TokenIgnore
|
||||
public DataResult deletedPicture() {
|
||||
//查询全部数据
|
||||
List<WorkOrderPicture> workOrderPictures = workOrderPictureService.selectAll();
|
||||
//筛选未关联的工单号的图片和文件数据
|
||||
workOrderPictures = workOrderPictures.stream().filter(s -> {
|
||||
return s.getWorkOrderId() == null;
|
||||
}).collect(Collectors.toList());
|
||||
//工单图片的id
|
||||
List<Long> workOrderPictureIds = new ArrayList<>();
|
||||
for (WorkOrderPicture workOrderPicture : workOrderPictures) {
|
||||
workOrderPictureIds.add(workOrderPicture.getId().longValue());
|
||||
//删除在虚拟机中的文件
|
||||
File file = new File(workOrderPicture.getUrl());
|
||||
file.delete();
|
||||
}
|
||||
//再删除数据库中的对象
|
||||
workOrderPictureService.deletedByIds(workOrderPictureIds);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 告警存在故障时长
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("faultDuration")
|
||||
@TokenIgnore
|
||||
public DataResult<List<EventDemo>> faultDuration(@RequestBody EventDemoReqVo eventDemoReqVo) {
|
||||
//查询全部数据
|
||||
List<EventDemo> eventDemoList = eventService.getFaultDuration(eventDemoReqVo);
|
||||
return DataResult.success(eventDemoList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 告警存在故障时长
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("faultDurations")
|
||||
@TokenIgnore
|
||||
public DataResult<List<EventDemo>> faultDurations(@RequestBody EventDemoReqVo eventDemoReqVo) {
|
||||
//查询全部数据
|
||||
List<EventDemo> eventDemoList = eventService.getFaultDurations(eventDemoReqVo);
|
||||
return DataResult.success(eventDemoList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对外提供上送数据接口
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/eventPage")
|
||||
@TokenIgnore
|
||||
public DataResult<PageResult<ApiEventRespVO>> eventPage(@RequestBody @Valid ApiEventReqVO vo, HttpServletRequest request) {
|
||||
Date now = new Date();
|
||||
String beginTime = DateUtil.format(DateUtil.offsetMinute(now, -5), CommonConstant.DATE);
|
||||
String endTime = DateUtil.format(now, CommonConstant.DATE);
|
||||
vo.setStartTime(beginTime);
|
||||
vo.setEndTime(endTime);
|
||||
PageResult<ApiEventRespVO> list = getEventRespVOPageResult(vo);
|
||||
return DataResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对外提供上送数据接口
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/hisEventPage")
|
||||
@TokenIgnore
|
||||
public DataResult<PageResult<ApiEventRespVO>> hisEventPage(@RequestBody @Valid ApiEventReqVO vo, HttpServletRequest request) {
|
||||
Date now = new Date();
|
||||
String beginTime = DateUtil.format(DateUtil.offsetDay(now, -6), CommonConstant.DATE);
|
||||
String endTime = DateUtil.format(now, CommonConstant.DATE);
|
||||
vo.setStartTime(beginTime);
|
||||
vo.setEndTime(endTime);
|
||||
PageResult<ApiEventRespVO> list = getEventRespVOPageResult(vo);
|
||||
return DataResult.success(list);
|
||||
}
|
||||
|
||||
private PageResult<ApiEventRespVO> getEventRespVOPageResult(ApiEventReqVO vo) {
|
||||
SysSubDictVO sysSubDictVO = new SysSubDictVO();
|
||||
sysSubDictVO.setType(CommonConstant.PUSH_DATA);
|
||||
Map<String, String> sysSubDict = userFeignClient.getSysSubDict(sysSubDictVO);
|
||||
Map<Object, Object> hgetall = new HashMap<>();
|
||||
String stationId = sysSubDict.get(vo.getApiSecret());
|
||||
PageResult<ApiEventRespVO> list = new PageResult<>();
|
||||
if (stationId != null) {
|
||||
|
||||
List<Integer> srcIdList = vo.getSrcIdList();
|
||||
if (srcIdList != null && !srcIdList.isEmpty()) {
|
||||
//虚拟设备
|
||||
List<Integer> virtualSrcIdList = srcIdList.stream().filter(i -> i < 0).collect(Collectors.toList());
|
||||
//实际设备
|
||||
List<Integer> realSrcIdList = srcIdList.stream().filter(i -> i >= 0).collect(Collectors.toList());
|
||||
vo.setSrcIdList(realSrcIdList);
|
||||
if (virtualSrcIdList.size() > 0) {
|
||||
DeviceListReq deviceListReq = new DeviceListReq();
|
||||
deviceListReq.setStationId(vo.getStationIds().get(0));
|
||||
deviceListReq.setSrcIdList(srcIdList);
|
||||
List<EventColReq> queryEventParamList = businessFeignClient.getQueryEventParam(deviceListReq);
|
||||
if (queryEventParamList.size() > 0) {
|
||||
vo.setSrcIdList(null);
|
||||
vo.setEventColReqList(queryEventParamList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Integer> stationIds = new ArrayList<>();
|
||||
stationIds.add(Integer.valueOf(stationId));
|
||||
vo.setStationIds(stationIds);
|
||||
EventReqPageVO eventReqPageVO = new EventReqPageVO();
|
||||
BeanUtils.copyProperties(vo, eventReqPageVO);
|
||||
String description = vo.getDescription() == null ? vo.getDescription() : vo.getDescription().trim();
|
||||
if ("".equals(description)) {
|
||||
eventReqPageVO.setDescription(null);
|
||||
} else {
|
||||
eventReqPageVO.setDescription(description);
|
||||
}
|
||||
PageResult<EventRespVO> pageResult = eventService.pageEventInfo(eventReqPageVO);
|
||||
List<EventRespVO> pageList = pageResult.getList();
|
||||
List<ApiEventRespVO> resultList = new ArrayList<>();
|
||||
ApiEventRespVO apiEventRespVO = null;
|
||||
for (EventRespVO event : pageList) {
|
||||
apiEventRespVO = new ApiEventRespVO();
|
||||
BeanUtils.copyProperties(event, apiEventRespVO);
|
||||
resultList.add(apiEventRespVO);
|
||||
}
|
||||
list.setPageNum(pageResult.getPageNum());
|
||||
list.setPageSize(pageResult.getPageSize());
|
||||
list.setTotalPages(pageResult.getTotalPages());
|
||||
list.setTotalRows(pageResult.getTotalRows());
|
||||
list.setList(resultList);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@PostMapping("/deviceColDefine")
|
||||
@ApiOperation(value = "同步数据告警字段定义")
|
||||
@TokenIgnore
|
||||
public DataResult deviceColDefine(@RequestBody List<DeviceTypeCol> deviceTypeCols) {
|
||||
deviceColDefineService.deviceColDefine(deviceTypeCols);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/syncAlarmConfig")
|
||||
@ApiOperation(value = "同步数据告警配置")
|
||||
@TokenIgnore
|
||||
public DataResult syncAlarmConfig(@RequestBody DeviceTypeList deviceTypeList) {
|
||||
deviceColDefineService.syncAlarmConfigList(deviceTypeList);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取电站告警最后一条离线数据
|
||||
*
|
||||
* @param stationStatusReq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getNotRecovered")
|
||||
@TokenIgnore
|
||||
public DataResult<Event> getNotRecovered(@RequestBody AlarmConfigQueryVo stationStatusReq) {
|
||||
Event event = flowOutApiService.getNotRecovered(stationStatusReq);
|
||||
return DataResult.success(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取电站告警发生的次数和已解决
|
||||
*
|
||||
* @param stationStatusReq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/alarmDataStatistics")
|
||||
@TokenIgnore
|
||||
public DataResult<EventTypeAndLevelsReqVO> alarmDataStatistics(@RequestBody AlarmConfigQueryVo stationStatusReq) {
|
||||
EventTypeAndLevelsReqVO eventNum = flowOutApiService.getAlarmDataStatistics(stationStatusReq);
|
||||
return DataResult.success(eventNum);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 进行发短信
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getSendSms")
|
||||
@TokenIgnore
|
||||
public DataResult getSendSms(@RequestBody SendSmsConfigQueryReq vo) {
|
||||
sendSmsConfigService.sendSms(vo);
|
||||
return DataResult.success();
|
||||
}
|
||||
/**
|
||||
* 根据天统计告警数目
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/countEventByDay")
|
||||
@TokenIgnore
|
||||
public List<EventDayNum> countEventByDay(@RequestBody EventReqPageVO vo) {
|
||||
List<EventDayNum> eventDayNums = eventService.countEventByDay(vo);
|
||||
return eventDayNums;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 手动修改用户信息,同步更新告警短信中用户信息
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updateSendSmsUserInfo")
|
||||
@TokenIgnore
|
||||
public void updateSendSmsUserInfo(@RequestBody SendSmsConfig vo) {
|
||||
sendSmsConfigService.updateByUserId(vo);
|
||||
}
|
||||
|
||||
@PostMapping("initProcessInstance")
|
||||
@TokenIgnore
|
||||
public DataResult initProcessInstance(@RequestBody @Valid ProcessOrder processOrder) {
|
||||
|
||||
Integer orderNum = processFlowNewService.initProcessInstance(processOrder);
|
||||
DataResult result = new DataResult();
|
||||
result.setData(orderNum);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,367 @@
|
||||
package com.ho.flow.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ho.common.tools.annotation.LogAnnotation;
|
||||
import com.ho.common.tools.constant.CommonConstant;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.OrderDept;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.BusinessException;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.common.tools.util.PageUtils;
|
||||
import com.ho.flow.constant.WorkOrderConstant;
|
||||
import com.ho.flow.entity.WorkOrder;
|
||||
import com.ho.flow.service.ProcessFlowService;
|
||||
import com.ho.flow.service.WorkOrderPictureService;
|
||||
import com.ho.flow.service.WorkOrderService;
|
||||
import com.ho.flow.vo.req.workorder.*;
|
||||
import com.ho.flow.vo.resp.workorder.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author fancl
|
||||
* @desc: 工作流Controller
|
||||
* @date 2023/2/5
|
||||
*/
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT + "processFlow")
|
||||
@RestController
|
||||
@Api(tags = "工单工作流")
|
||||
public class ProcessFlowController {
|
||||
|
||||
@Autowired
|
||||
ProcessFlowService processFlowService;
|
||||
|
||||
@Autowired
|
||||
WorkOrderService workOrderService;
|
||||
|
||||
@Autowired
|
||||
WorkOrderPictureService pictureService;
|
||||
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
|
||||
//执行工单的岗位
|
||||
@Value("#{'${flow.workOrder.doing}'.split(',')}")
|
||||
String[] doing;
|
||||
|
||||
//验收工单的岗位
|
||||
@Value("#{'${flow.workOrder.check}'.split(',')}")
|
||||
String[] check;
|
||||
|
||||
//评价工单的岗位
|
||||
@Value("#{'${flow.workOrder.appraise}'.split(',')}")
|
||||
String[] appraise;
|
||||
|
||||
@PostMapping("preDo")
|
||||
@ApiOperation(value = "流转前的方法")
|
||||
public DataResult<PreDoResp> preDo(@RequestBody @Valid TaskUserReq taskUserReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
String userTokenKey = RedisKeyConstant.User.TOKEN + token;
|
||||
List<Integer> depts = new ArrayList<>();
|
||||
Integer groupId = null;
|
||||
//根据用户的登陆方式(账号还是手机号),延长对应缓存
|
||||
if (redisService.hasKey(userTokenKey)) {
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
depts = simpleUser.getDepts();
|
||||
groupId = simpleUser.getGroupId();
|
||||
}
|
||||
taskUserReq.setTenantId(String.valueOf(groupId));
|
||||
//查当前任务,并根据任务查询对应岗位列表
|
||||
Task task = processFlowService.getTaskById(taskUserReq);
|
||||
//取到
|
||||
String taskKeyName = task.getTaskDefinitionKey();
|
||||
//根据岗位查询可分配人员
|
||||
List<String> postCodes = new ArrayList<>();
|
||||
if (WorkOrderConstant.TaskNodeName.node1.equals(taskKeyName)) {
|
||||
postCodes = Arrays.asList(doing);
|
||||
} else if (WorkOrderConstant.TaskNodeName.node2.equals(taskKeyName)) {
|
||||
postCodes = Arrays.asList(check);
|
||||
} else if (WorkOrderConstant.TaskNodeName.node3.equals(taskKeyName)) {
|
||||
postCodes = Arrays.asList(appraise);
|
||||
}
|
||||
PreDoResp preDoResp = new PreDoResp();
|
||||
//查可选人员列表
|
||||
List<OrderDept> orderDeptUsers = workOrderService.selectOrderUser(groupId, postCodes);
|
||||
preDoResp.setOrderDeptUsers(orderDeptUsers);
|
||||
//查下一节点任务名
|
||||
String nextTaskName = processFlowService.getNextTaskName(taskUserReq.getProcessInstId());
|
||||
preDoResp.setNextTaskName(nextTaskName);
|
||||
//查询对应任务详情
|
||||
Task taskById = processFlowService.getTaskById(taskUserReq);
|
||||
if (taskById != null) {
|
||||
WorkOrderRespVO workOrderRespVO = workOrderService.findByProcInstId(taskById.getProcessInstanceId());
|
||||
if (workOrderRespVO != null) {
|
||||
preDoResp.setTitle(workOrderRespVO.getTitle());
|
||||
}
|
||||
}
|
||||
return DataResult.success(preDoResp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 只有工单发起人可以保存工单
|
||||
* 其他人只能处理工单
|
||||
*
|
||||
* @param addReq
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("saveOrder")
|
||||
@ApiOperation(value = "保存工单")
|
||||
@LogAnnotation(title = "工单工作流", action = "保存工单")
|
||||
public DataResult<String> saveOrder(@RequestBody @Valid WorkOrderAddReqVO addReq, HttpServletRequest request) {
|
||||
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//因为可以多次保存
|
||||
//所以判断工单是否已经创建,没创建就创建,已经创建就修改
|
||||
//只在新建时发起流程,修改不需要再次发起流程
|
||||
Long id = addReq.getId();
|
||||
if (id == null) {
|
||||
//新增工单和图片信息,并发起流程
|
||||
//设置groupId
|
||||
addReq.setGroupId(simpleUser.getGroupId());
|
||||
//设置发起人
|
||||
addReq.setUserId(simpleUser.getUserId());
|
||||
String processInstanceId = processFlowService.saveOrderAndStartProcess(addReq);
|
||||
return DataResult.success(processInstanceId);
|
||||
} else {
|
||||
//只修改表单信息
|
||||
WorkOrderRespVO one = workOrderService.getOne(id);
|
||||
if (one == null) {
|
||||
throw new BusinessException(BaseResponseCode.WORK_ORDER_NOT_EXISTS);
|
||||
}
|
||||
//修改工单表单,调用修改方法
|
||||
//更新图片
|
||||
WorkOrderUpdateReqVO workOrderUpdateReq = new WorkOrderUpdateReqVO();
|
||||
BeanUtil.copyProperties(addReq, workOrderUpdateReq);
|
||||
workOrderService.updateWorkOrder(workOrderUpdateReq);
|
||||
return DataResult.success(one.getProcessId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("claimTask")
|
||||
@ApiOperation(value = "接收任务")
|
||||
@LogAnnotation(title = "工单工作流", action = "接收任务")
|
||||
public DataResult claimTask(@RequestBody @Valid TaskUserReq taskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
taskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
taskReq.setUserId(simpleUser.getUserId());
|
||||
processFlowService.doClaimTask(taskReq);
|
||||
//代办应该分页,做个java内存分页处理
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("queryTodoList")
|
||||
@ApiOperation(value = "查询代办列表")
|
||||
public DataResult<List<TaskDone>> queryTodoList(@RequestBody(required = false) @Valid DoListTaskReq doListTaskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
Map<String, List<Task>> taskMap = processFlowService.getTodoList(simpleUser);
|
||||
List<TaskDone> todoList = new ArrayList<>();
|
||||
//代办不分页,转换为TaskDone对象
|
||||
if (!taskMap.isEmpty()) {
|
||||
todoList = processFlowService.getToDoListFromTask(taskMap, doListTaskReq);
|
||||
}
|
||||
if (!todoList.isEmpty()) {
|
||||
//根据优先级排序然后根据时间
|
||||
todoList = todoList.stream().sorted(
|
||||
Comparator.comparing(TaskDone::getPriority, Comparator.nullsLast(String::compareTo)).reversed().
|
||||
thenComparing(TaskDone::getStartTime, Comparator.nullsLast(Date::compareTo)).reversed()
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
return DataResult.success(todoList);
|
||||
}
|
||||
|
||||
@PostMapping("queryDoneList")
|
||||
@ApiOperation(value = "查询已办列表")
|
||||
public DataResult<PageResult<TaskDone>> queryDoneList(@RequestBody @Valid DoListTaskReq doListTaskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
List<HistoricTaskInstance> taskList = processFlowService.getDoneList(simpleUser);
|
||||
List<TaskDone> doneList = new ArrayList<>();
|
||||
|
||||
if (!taskList.isEmpty()) {
|
||||
doneList = processFlowService.getDoneListFromTask(taskList, doListTaskReq);
|
||||
}
|
||||
doneList = doneList.stream().collect(Collectors.toMap(TaskDone::getProcessInstanceId, a -> a, (s1, s2) -> {
|
||||
//如果两个任务标题相同,比较时间,选择时间大的
|
||||
long difference = DateUtil.betweenMs(s1.getStartTime(), s2.getStartTime());
|
||||
if (difference > 0) {
|
||||
return s2;
|
||||
} else {
|
||||
return s1;
|
||||
}
|
||||
})).values().stream().sorted(
|
||||
//根据时间倒序排序
|
||||
Comparator.comparing(TaskDone::getStartTime).reversed()
|
||||
).collect(Collectors.toList());
|
||||
PageResult pageResult = new PageResult<>();
|
||||
if (!doneList.isEmpty()) {
|
||||
//获取到代办任务
|
||||
DataResult<List<TaskDone>> listDataResult = queryTodoList(doListTaskReq, request);
|
||||
//代办的任务
|
||||
List<TaskDone> todoList = listDataResult.getData();
|
||||
Map<String, List<TaskDone>> todoMap = todoList.stream().collect(Collectors.groupingBy(TaskDone::getProcessInstanceId));
|
||||
//移除在代办任务中存在的任务对象
|
||||
doneList.removeIf(s -> {
|
||||
boolean flag = false;
|
||||
if (todoMap.get(s.getProcessInstanceId()) != null) {
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
});
|
||||
}
|
||||
if (!doneList.isEmpty()) {
|
||||
List list = PageUtils.dealList(doneList, doListTaskReq.getPageNum(), doListTaskReq.getPageSize());
|
||||
pageResult = PageUtils.getPageResult(new PageInfo<>(list));
|
||||
pageResult.setTotalRows(doneList.size());
|
||||
pageResult.setTotalPages(doneList.size() / doListTaskReq.getPageSize() + 1);
|
||||
}
|
||||
return DataResult.success(pageResult);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("doTask")
|
||||
@ApiOperation(value = "完成任务,即流转任务")
|
||||
@LogAnnotation(title = "工单工作流", action = "流转任务")
|
||||
public DataResult doTask(@RequestBody @Valid DoTaskReq doTaskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
doTaskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
//设置发送者的id
|
||||
doTaskReq.setSenderId(simpleUser.getUserId());
|
||||
//完成任务的责任人必须和自己相同,否则需要给出提示
|
||||
doTaskReq.setAssigneeUser(simpleUser.getUserId());
|
||||
processFlowService.doCompleteTask(doTaskReq);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("nullify")
|
||||
@ApiOperation(value = "流程作废")
|
||||
@LogAnnotation(title = "工单工作流", action = "流程作废")
|
||||
public DataResult nullifyTask(@RequestBody DoTaskReq doTaskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
doTaskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
//完成任务的责任人必须和自己相同,否则需要给出提示
|
||||
doTaskReq.setAssigneeUser(simpleUser.getUserId());
|
||||
WorkOrderRespVO vo = workOrderService.selectByProcessInstId(doTaskReq.getProcessInstId());
|
||||
if (vo != null) {
|
||||
WorkOrder workOrder = new WorkOrder();
|
||||
BeanUtils.copyProperties(vo, workOrder);
|
||||
workOrder.setDeleted(CommonConstant.DELETED_FLAG);
|
||||
workOrderService.update(workOrder);
|
||||
}
|
||||
processFlowService.doNullifyTaskTask(doTaskReq);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("rejectTask")
|
||||
@ApiOperation(value = "退回任务")
|
||||
@LogAnnotation(title = "工单工作流", action = "退回任务")
|
||||
public DataResult rejectTask(@RequestBody RejectTaskReq rejectTaskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置发送人
|
||||
rejectTaskReq.setUserId(simpleUser.getUserId());
|
||||
//设置租户id
|
||||
rejectTaskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
processFlowService.doRejectTask(rejectTaskReq);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("discardTask")
|
||||
@ApiOperation(value = "作废任务")
|
||||
@LogAnnotation(title = "工单工作流", action = "作废任务")
|
||||
public DataResult discardTask(@RequestBody TaskReq taskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
taskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
processFlowService.doDiscardTask(taskReq);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("fallBackTask")
|
||||
@ApiOperation(value = "回退任务列表")
|
||||
public DataResult<List<FallBackTaskResp>> fallBackTask(@RequestBody FallBackTaskReq fallBackTaskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
fallBackTaskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
List<FallBackTaskResp> fallBackTaskResps = processFlowService.getFallBackTask(fallBackTaskReq);
|
||||
return DataResult.success(fallBackTaskResps);
|
||||
}
|
||||
|
||||
@PostMapping("circulationTask")
|
||||
@ApiOperation(value = "流转记录")
|
||||
public DataResult<List<HisTaskResp>> circulationTask(@RequestBody CirculationTaskReq taskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
taskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
List<HisTaskResp> hisTaskRespList = processFlowService.getCirculationTask(taskReq);
|
||||
return DataResult.success(hisTaskRespList);
|
||||
}
|
||||
|
||||
@PostMapping("workOrderDetails")
|
||||
@ApiOperation(value = "工单详情")
|
||||
public DataResult<WorkOrderRespVO> workOrderDetails(@RequestBody TaskReq taskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//根据流程id获取工单业务对象
|
||||
WorkOrderRespVO vo = workOrderService.selectByProcessInstId(taskReq.getProcessInstId());
|
||||
|
||||
TaskUserReq taskUserReq = new TaskUserReq();
|
||||
taskUserReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
taskUserReq.setProcessInstId(taskReq.getProcessInstId());
|
||||
//根据流程实例查询任务对象taskUserReq
|
||||
Task task = processFlowService.getTaskById(taskUserReq);
|
||||
if (task != null) {
|
||||
//设置当前步骤节点
|
||||
vo.setCurrentStep(task.getTaskDefinitionKey());
|
||||
//有执行人就设置haveAssignee为true
|
||||
if (task.getAssignee() != null) {
|
||||
vo.setHaveAssignee(true);
|
||||
} else {
|
||||
vo.setHaveAssignee(false);
|
||||
}
|
||||
} else if (CommonConstant.DELETED_FLAG.equals(vo.getDeleted())) {
|
||||
//设置当前步骤节点
|
||||
vo.setCurrentStep(WorkOrderConstant.TaskNodeName.deleted);
|
||||
} else {
|
||||
vo.setCurrentStep(WorkOrderConstant.TaskNodeName.end);
|
||||
}
|
||||
//查询工单业务相关的图片信息
|
||||
List<PictureRespVO> pictureRespVOS = pictureService.selectByOrderId(vo.getId());
|
||||
vo.setPictureResps(pictureRespVOS);
|
||||
return DataResult.success(vo);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
package com.ho.flow.controller;
|
||||
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.BusinessException;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.flow.entity.SendSmsConfig;
|
||||
import com.ho.flow.service.SendSmsConfigService;
|
||||
import com.ho.flow.vo.req.SendSmsConfig.SendSmsConfigDeleteReq;
|
||||
import com.ho.flow.vo.req.SendSmsConfig.SendSmsConfigQueryReq;
|
||||
import com.ho.flow.vo.resp.SendSmsConfig.SendSmsConfigRsp;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 发送短信配置界面
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT + "sendSmsConfig")
|
||||
@Api(tags = "短信配置人员界面")
|
||||
@Slf4j
|
||||
public class SendSmsConfigController {
|
||||
|
||||
@Autowired
|
||||
SendSmsConfigService sendSmsConfigService;
|
||||
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
|
||||
@PostMapping(value = "page")
|
||||
@ApiOperation("分页查询短信配置信息")
|
||||
public DataResult page(@RequestBody SendSmsConfigQueryReq vo){
|
||||
PageResult<SendSmsConfigRsp> pageList = sendSmsConfigService.getPageList(vo);
|
||||
return DataResult.success(pageList);
|
||||
}
|
||||
|
||||
@PostMapping(value = "insertList")
|
||||
@ApiOperation("批量插入")
|
||||
public DataResult insertList(@RequestBody List<SendSmsConfig> list, HttpServletRequest request){
|
||||
if(!list.isEmpty()){
|
||||
List<String> useIds = list.stream().map(SendSmsConfig::getUserId).collect(Collectors.toList());
|
||||
SendSmsConfigQueryReq vo = new SendSmsConfigQueryReq();
|
||||
vo.setStationId(list.get(0).getStationId());
|
||||
vo.setSmsType(list.get(0).getSmsType());
|
||||
vo.setUserIds(useIds);
|
||||
List<SendSmsConfigRsp> queryList = sendSmsConfigService.getList(vo);
|
||||
if(!queryList.isEmpty()){
|
||||
throw new BusinessException(BaseResponseCode.EXISTS_DUPLICATE_DATA);
|
||||
}
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
list.stream().forEach(i->i.setCreateId(user.getUserId()));
|
||||
sendSmsConfigService.insertList(list);
|
||||
}
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping(value = "updateById")
|
||||
@ApiOperation("更新")
|
||||
public DataResult updateById(@RequestBody SendSmsConfig vo, HttpServletRequest request){
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser user = redisService.getSimpleUserByToken(token);
|
||||
vo.setUpdateId(user.getUserId());
|
||||
int record = sendSmsConfigService.updateById(vo);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping(value = "deleteList")
|
||||
@ApiOperation("批量删除")
|
||||
public DataResult updateById(@RequestBody SendSmsConfigDeleteReq vo){
|
||||
int record = sendSmsConfigService.deleteList(vo.getIds());
|
||||
return DataResult.success();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,129 @@
|
||||
package com.ho.flow.controller;
|
||||
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.BusinessException;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.flow.service.WorkOrderPictureService;
|
||||
import com.ho.flow.service.WorkOrderService;
|
||||
import com.ho.flow.vo.req.workorder.WorkOrderAddReqVO;
|
||||
import com.ho.flow.vo.req.workorder.WorkOrderPageReq;
|
||||
import com.ho.flow.vo.req.workorder.WorkOrderUpdateReqVO;
|
||||
import com.ho.flow.vo.resp.workorder.PictureRespVO;
|
||||
import com.ho.flow.vo.resp.workorder.WorkOrderRespVO;
|
||||
import com.ho.common.tools.entity.OrderDept;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @Description 工单业务
|
||||
* Author yule
|
||||
* Date 2023/2/4 12:54
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT + "workOrder")
|
||||
@Slf4j
|
||||
@Api(tags = "工单查询")
|
||||
public class WorkOrderController {
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
WorkOrderService workOrderService;
|
||||
|
||||
@Autowired
|
||||
WorkOrderPictureService pictureService;
|
||||
|
||||
|
||||
@PostMapping("add")
|
||||
@ApiOperation(value = "新增工单业务数据")
|
||||
public DataResult add(@RequestBody @Valid WorkOrderAddReqVO vo) {
|
||||
int i = workOrderService.add(vo);
|
||||
if (i > 0) {
|
||||
return DataResult.success();
|
||||
} else {
|
||||
throw new BusinessException(BaseResponseCode.WORK_ORDER_ADD_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("delete")
|
||||
@ApiOperation(value = "删除工单业务数据")
|
||||
public DataResult delete(@RequestBody List<Long> ids) {
|
||||
|
||||
int i = workOrderService.delete(ids);
|
||||
|
||||
//删除电站相关图片数据
|
||||
pictureService.deletedByWorkOrderIds(ids);
|
||||
if (i > 0) {
|
||||
return DataResult.success();
|
||||
} else {
|
||||
throw new BusinessException(BaseResponseCode.WORK_ORDER_DELETE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("update")
|
||||
@ApiOperation(value = "修改工单业务数据")
|
||||
public DataResult update(@RequestBody @Valid WorkOrderUpdateReqVO vo) {
|
||||
//更新图片
|
||||
pictureService.updatePicture(vo);
|
||||
int i = workOrderService.update(vo);
|
||||
if (i > 0) {
|
||||
return DataResult.success();
|
||||
} else {
|
||||
throw new BusinessException(BaseResponseCode.WORK_ORDER_UPDATE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("getOne")
|
||||
@ApiOperation(value = "获取单个工单业务数据")
|
||||
public DataResult<WorkOrderRespVO> getOne(@RequestBody Long id) {
|
||||
//获取工单业务对象
|
||||
WorkOrderRespVO vo = workOrderService.getOne(id);
|
||||
//查询工单业务相关的图片信息
|
||||
List<PictureRespVO> pictureRespVOS = pictureService.selectByOrderId(id);
|
||||
vo.setPictureResps(pictureRespVOS);
|
||||
return DataResult.success(vo);
|
||||
}
|
||||
|
||||
@PostMapping("page")
|
||||
@ApiOperation(value = "分页查询工单业务数据")
|
||||
public DataResult<PageResult<WorkOrderRespVO>> page(@RequestBody @Valid WorkOrderPageReq vo) {
|
||||
PageResult<WorkOrderRespVO> page = workOrderService.getPage(vo);
|
||||
return DataResult.success(page);
|
||||
}
|
||||
|
||||
@PostMapping("orderUser")
|
||||
@ApiOperation(value = "查询流转可操作的人员")
|
||||
public DataResult<List<OrderDept>> selectOrderUser(HttpServletRequest request, @RequestBody List<String> postCodes) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
String userTokenKey = RedisKeyConstant.User.TOKEN + token;
|
||||
//List<Integer> depts = new ArrayList<>();
|
||||
Integer groupId = null;
|
||||
//根据用户的登陆方式(账号还是手机号),延长对应缓存
|
||||
if (redisService.hasKey(userTokenKey)) {
|
||||
SimpleUser simpleUser = (SimpleUser) redisService.getSimpleUserByToken(token);
|
||||
//depts = simpleUser.getDepts();
|
||||
groupId = simpleUser.getGroupId();
|
||||
}
|
||||
|
||||
List<OrderDept> orderDeptList = workOrderService.selectOrderUser(groupId, postCodes);
|
||||
return DataResult.success(orderDeptList);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,447 @@
|
||||
package com.ho.flow.controller;
|
||||
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.ho.common.tools.annotation.LogAnnotation;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
import com.ho.common.tools.entity.UserDetailRespVO;
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.BusinessException;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.flow.common.FlowTool;
|
||||
import com.ho.flow.constant.WorkOrderConstant;
|
||||
import com.ho.flow.service.FlowWorkOrderService;
|
||||
import com.ho.flow.service.WorkOrderCirculationService;
|
||||
import com.ho.flow.service.WorkOrderHisService;
|
||||
import com.ho.flow.vo.WorkOrderOld;
|
||||
import com.ho.flow.vo.WorkOrderCirculation;
|
||||
import com.ho.flow.vo.req.workorder.*;
|
||||
import com.ho.flow.vo.resp.workorder.WorkOrderCirculationRespVO;
|
||||
import com.ho.flow.vo.resp.workorder.WorkOrderOldPageRespVO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author fancl
|
||||
* @desc: 工作流 工单
|
||||
* @date 2023/1/22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT +"workOrderHis")
|
||||
@Slf4j
|
||||
public class WorkOrderHisController {
|
||||
|
||||
@Autowired
|
||||
WorkOrderHisService workOrderHisService;
|
||||
|
||||
@Autowired
|
||||
WorkOrderCirculationService workOrderCirculationService;
|
||||
|
||||
@Autowired
|
||||
FlowWorkOrderService flowWorkOrderService;
|
||||
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
Snowflake snowflake;
|
||||
|
||||
@Autowired
|
||||
FlowTool flowTool;
|
||||
|
||||
//执行工单的岗位
|
||||
@Value("#{'${flow.workOrder.doing}'.split(',')}")
|
||||
String[] doing;
|
||||
|
||||
//验收工单的岗位
|
||||
@Value("#{'${flow.workOrder.check}'.split(',')}")
|
||||
String[] check;
|
||||
|
||||
//评价工单的岗位
|
||||
@Value("#{'${flow.workOrder.appraise}'.split(',')}")
|
||||
String[] appraise;
|
||||
|
||||
|
||||
//工单结合工作流进行审批控制, 能够分配和执行任务的是具有特定岗位的人员
|
||||
@PostMapping("add")
|
||||
@ApiOperation(value = "新增工单")
|
||||
//@LogAnnotation(title = "工单管理", action = "新增工单信息")
|
||||
public DataResult add(@RequestBody @Valid WorkOrderAddReq vo ,HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
String workOrderId = flowTool.getNextWorkOrderId(WorkOrderConstant.IdTypeWorkOrder);
|
||||
//原有工单流程中增加工作流
|
||||
workOrderHisService.insertStation(vo,simpleUser,workOrderId);
|
||||
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("detail/{orderId}")
|
||||
@ApiOperation(value = "根据工单id查询工单详情")
|
||||
public DataResult<WorkOrderOld> selectById(@PathVariable @Valid String orderId) {
|
||||
WorkOrderOld workOrderOld = workOrderHisService.selectById(orderId);
|
||||
return DataResult.success(workOrderOld);
|
||||
}
|
||||
|
||||
@PostMapping("update")
|
||||
@ApiOperation(value = "修改工单")
|
||||
@LogAnnotation(title = "工单管理", action = "修改工单信息")
|
||||
public DataResult update(@RequestBody @Valid WorkOrderUpdateReq vo , HttpServletRequest request) {
|
||||
//判断工单
|
||||
WorkOrderOld workOrderOld = workOrderHisService.findByOrderId(vo.getOrderId());
|
||||
if (workOrderOld == null) {
|
||||
//没找到数据
|
||||
throw new BusinessException(BaseResponseCode.DATA_NOT_EXISTS);
|
||||
}
|
||||
//工单状态必须是待分配 人工派单
|
||||
if(!WorkOrderConstant.WorkOrderStatus.toBeAllocate.equals(workOrderOld.getWorkOrderStatus())) {
|
||||
throw new BusinessException(BaseResponseCode.WORK_ORDER_STATUS_MUST_BE_NOT_EDIT);
|
||||
}
|
||||
if(!WorkOrderConstant.WorkOrderType.dispatcher.equals(workOrderOld.getWorkOrderType())){
|
||||
throw new BusinessException(BaseResponseCode.WORK_ORDER_TYPE_NOT_MANUAL_CANNOT_BE_MODIFIED);
|
||||
}
|
||||
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
workOrderHisService.updateWorkOrder(vo,simpleUser);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
//一次只删除一个
|
||||
@PostMapping("delete")
|
||||
@ApiOperation(value = "删除工单")
|
||||
@LogAnnotation(title = "工单管理", action = "删除工单信息")
|
||||
public DataResult delete(@RequestBody @Valid WorkDeleteOrderReq req) {
|
||||
//判断工单
|
||||
WorkOrderOld workOrderOld = workOrderHisService.findByOrderId(req.getOrderId());
|
||||
if(workOrderOld == null) {
|
||||
//没找到数据
|
||||
throw new BusinessException(BaseResponseCode.DATA_NOT_EXISTS);
|
||||
}
|
||||
if(!WorkOrderConstant.WorkOrderStatus.toBeAllocate.equals(workOrderOld.getWorkOrderStatus())) {
|
||||
throw new BusinessException(BaseResponseCode.EXISTENCE_NOT_PENDING_ASSIGNMENT_CANNOT_DELETED);
|
||||
}
|
||||
workOrderHisService.delete(req.getOrderId());
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
// ctrl+shift+/
|
||||
/* @PostMapping("delete")
|
||||
@ApiOperation(value = "删除工单")
|
||||
@LogAnnotation(title = "工单管理", action = "删除工单信息")
|
||||
public DataResult delete(@RequestBody List<String> orderIds) {
|
||||
//判断工单
|
||||
for (String orderId : orderIds) {
|
||||
WorkOrder workOrder = workOrderService.findByOrderId(orderId);
|
||||
if(workOrder == null) {
|
||||
//没找到数据
|
||||
throw new BusinessException(BaseResponseCode.DATA_NOT_EXISTS);
|
||||
}
|
||||
if(!WorkOrderConstant.WorkOrderStatus.toBeAllocate.equals(workOrder.getWorkOrderStatus())) {
|
||||
throw new BusinessException(BaseResponseCode.EXISTENCE_NOT_PENDING_ASSIGNMENT_CANNOT_DELETED);
|
||||
}
|
||||
}
|
||||
workOrderService.deleteWorkOrder(orderIds);
|
||||
return DataResult.success();
|
||||
}*/
|
||||
|
||||
//代办数据来自工作流
|
||||
@PostMapping("needToDoList")
|
||||
@ApiOperation(value = "待办的工单列表")
|
||||
public DataResult<PageResult<WorkOrderOldPageRespVO>> needToDoList(@RequestBody @Valid WorkOrderPageReq vo, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
UserDetailRespVO userDetailRespVO = redisService.getUserDetailByToken(token);
|
||||
//岗位列表
|
||||
List<String> positions = userDetailRespVO.getPositions();
|
||||
List<WorkOrderOldPageRespVO> list = new ArrayList<>();
|
||||
//没有岗位啥也做不了
|
||||
if(positions==null ||positions.isEmpty()){
|
||||
log.error("positions is Empty !!");
|
||||
return DataResult.success(list);
|
||||
}
|
||||
//查询SimpleUser
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
UserDetailRespVO userDetail = redisService.getUserDetailByToken(token);
|
||||
List<Integer> stationIds = simpleUser.getStationIds();
|
||||
if(stationIds==null || stationIds.isEmpty()){
|
||||
log.error("stationIds is Empty !!");
|
||||
return DataResult.success(list);
|
||||
}
|
||||
List<String> stationIdsList = flowWorkOrderService.intToString(stationIds);
|
||||
//是否有分配权
|
||||
boolean bDoingUser = false;
|
||||
//是否有验收工单权限
|
||||
boolean bCheckUser = false;
|
||||
//是否有评价权限
|
||||
boolean bAppraiseUser = false;
|
||||
//租户id
|
||||
String tenantId = simpleUser.getGroupId().toString();
|
||||
//定义三种集合,待分配 ,待执行 ,待验收
|
||||
Map<String,String> toDistributeMap = new HashMap<>();
|
||||
Map<String,String> toDoMap = new HashMap<>();
|
||||
Map<String,String> toCheckMap = new HashMap<>();
|
||||
//执行
|
||||
if(flowWorkOrderService.matchPermit(positions ,doing)){
|
||||
bDoingUser = true;
|
||||
List<String> candidateUsers =new ArrayList<>();
|
||||
candidateUsers.add(WorkOrderConstant.canDistributeOrder);
|
||||
//查询可分配的代办
|
||||
toDistributeMap = flowWorkOrderService.queryToBeDoneMap(WorkOrderConstant.categoryWorkOrder, WorkOrderConstant.canDistributeOrder,candidateUsers,
|
||||
stationIdsList, tenantId);
|
||||
}
|
||||
//验收
|
||||
if(flowWorkOrderService.matchPermit(positions ,check)){
|
||||
bCheckUser = true;
|
||||
toDoMap = flowWorkOrderService.queryPersonalTask(WorkOrderConstant.categoryWorkOrder, userDetail.getUsername(), tenantId);
|
||||
}
|
||||
//是否可以验收工单
|
||||
if(flowWorkOrderService.matchPermit(positions ,appraise)){
|
||||
bAppraiseUser = true;
|
||||
//候选角色
|
||||
List<String> candidateUsers =new ArrayList<>();
|
||||
candidateUsers.add(WorkOrderConstant.canCheckOrder);
|
||||
toCheckMap = flowWorkOrderService.queryToBeDoneMap(WorkOrderConstant.categoryWorkOrder, WorkOrderConstant.canCheckOrder,candidateUsers,
|
||||
stationIdsList, tenantId);
|
||||
}
|
||||
//如果 stationId没传 要查所辖电站的数据
|
||||
if(org.springframework.util.StringUtils.isEmpty(vo.getStationId())){
|
||||
vo.setStationIds(stationIds);
|
||||
}
|
||||
//因为是使用 stationIds 查询的,不为空时那么把stationId加进去
|
||||
//查询电站时只用 stationIds 就行了
|
||||
else{
|
||||
stationIds = new ArrayList<>();
|
||||
stationIds.add(vo.getStationId());
|
||||
vo.setStationIds(stationIds);
|
||||
}
|
||||
//从得到的几个代办map中处理得到工单id列表
|
||||
List<String> orderIdList = flowWorkOrderService.getOrderIdList(toDistributeMap, toDoMap, toCheckMap);
|
||||
vo.setGroupId(simpleUser.getGroupId());
|
||||
vo.setOrderIds(orderIdList);
|
||||
//根据代办查工单,再根据工单状态确定下一步动作
|
||||
//1.待分配的工单 2.待操作的工单(接受) 3.待验收的
|
||||
PageResult<WorkOrderOldPageRespVO> result = workOrderHisService.selectPage(vo,simpleUser);
|
||||
return DataResult.success(result);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("allocate")
|
||||
@ApiOperation(value = "分配工单")
|
||||
@LogAnnotation(title = "工单管理", action = "分配工单")
|
||||
public DataResult allocate(@RequestBody @Valid WorkOrderApplyReqVO reqVO, HttpServletRequest request) {
|
||||
//判断必填参数
|
||||
if(StringUtils.isEmpty(reqVO.getOrderId())){
|
||||
throw new BusinessException(BaseResponseCode.WORK_ORDER_ID_REQUIRED);
|
||||
}
|
||||
if(StringUtils.isEmpty(reqVO.getToId())){
|
||||
throw new BusinessException(BaseResponseCode.WORK_ORDER_TO_ID_REQUIRED);
|
||||
}
|
||||
if(StringUtils.isEmpty(reqVO.getPhone())){
|
||||
throw new BusinessException(BaseResponseCode.WORK_ORDER_PHONE_REQUIRED);
|
||||
}
|
||||
//当前登陆人
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
UserDetailRespVO userDetail = redisService.getUserDetailByToken(token);
|
||||
//使用岗位判断是否可以分配工单
|
||||
List<String> positions = userDetail.getPositions();
|
||||
if(positions.isEmpty()){
|
||||
throw new BusinessException(BaseResponseCode.IS_NOT_ROLE_WORK_ORDER_LEADER);
|
||||
}
|
||||
//岗位不为空,判断是否包含岗位权限,只要包含一个就是有权限
|
||||
//没有对应岗位,报个提示
|
||||
if(!flowWorkOrderService.matchPermit(positions, doing)){
|
||||
throw new BusinessException(BaseResponseCode.IS_NOT_ROLE_WORK_ORDER_LEADER);
|
||||
}
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
|
||||
workOrderHisService.allocateOrder(reqVO, simpleUser);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
// 接受工单acceptWorkOrder
|
||||
@PostMapping("acceptWorkOrder")
|
||||
@ApiOperation(value = "接受工单")
|
||||
@LogAnnotation(title = "工单管理", action = "接受工单")
|
||||
public DataResult acceptWorkOrder(@RequestBody @Valid WorkOrderApplyReqVO vo,HttpServletRequest request) {
|
||||
//判断工单
|
||||
WorkOrderOld workOrderOld = workOrderHisService.findByOrderId(vo.getOrderId());
|
||||
if (workOrderOld == null) {
|
||||
//没找到数据
|
||||
throw new BusinessException(BaseResponseCode.DATA_NOT_EXISTS);
|
||||
}
|
||||
//工单状态必须是已分配
|
||||
if (!WorkOrderConstant.WorkOrderStatus.allocated.equals(workOrderOld.getWorkOrderStatus())) {
|
||||
throw new BusinessException(BaseResponseCode.WORK_ORDER_STATUS_NOT_ASSIGNED_CANNOT_CONFIRMED);
|
||||
}
|
||||
//接受后将状态改为处理中
|
||||
workOrderOld.setWorkOrderStatus(WorkOrderConstant.WorkOrderStatus.working);
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//生成流转记录
|
||||
// workOrderAction 指定当前动作
|
||||
WorkOrderCirculation workOrderAccept = new WorkOrderCirculation();
|
||||
workOrderAccept.setId(snowflake.nextId());
|
||||
workOrderAccept.setOrderId(vo.getOrderId());
|
||||
workOrderAccept.setFromId(simpleUser.getUserId());
|
||||
workOrderAccept.setToId(vo.getToId());
|
||||
workOrderAccept.setCreateTime(new Date());
|
||||
workOrderAccept.setWorkOrderAction(WorkOrderConstant.WorkOrderAction.workOrderDo);
|
||||
workOrderHisService.acceptWorkOrder(workOrderOld,workOrderAccept);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
// 退回工单returnWorkOrder
|
||||
@PostMapping("returnWorkOrder")
|
||||
@ApiOperation(value = "退回工单")
|
||||
@LogAnnotation(title = "工单管理", action = "退回工单")
|
||||
public DataResult returnWorkOrder(@RequestBody @Valid WorkOrderApplyReqVO vo,HttpServletRequest request) {
|
||||
//判断工单
|
||||
WorkOrderOld workOrderOld = workOrderHisService.findByOrderId(vo.getOrderId());
|
||||
if (workOrderOld == null) {
|
||||
//没找到数据
|
||||
throw new BusinessException(BaseResponseCode.DATA_NOT_EXISTS);
|
||||
}
|
||||
//工单状态必须是已分配的状态 (2,3都可以退回)
|
||||
if (!WorkOrderConstant.WorkOrderStatus.allocated.equals(workOrderOld.getWorkOrderStatus()) && !WorkOrderConstant.WorkOrderStatus.working.equals(workOrderOld.getWorkOrderStatus()) ) {
|
||||
throw new BusinessException(BaseResponseCode.WORK_ORDER_STATUS_NOT_ASSIGNED_CANNOT_RETURNED);
|
||||
}
|
||||
//退回将状态改为待分配状态
|
||||
workOrderOld.setWorkOrderStatus(WorkOrderConstant.WorkOrderStatus.toBeAllocate);
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//生成流转记录
|
||||
// workOrderAction 指定当前动作
|
||||
WorkOrderCirculation workOrderReturn = new WorkOrderCirculation();
|
||||
workOrderReturn.setId(snowflake.nextId());
|
||||
workOrderReturn.setOrderId(workOrderOld.getOrderId());
|
||||
workOrderReturn.setFromId(simpleUser.getUserId());
|
||||
workOrderReturn.setToId(vo.getToId());
|
||||
workOrderReturn.setCreateTime(new Date());
|
||||
workOrderReturn.setWorkOrderAction(WorkOrderConstant.WorkOrderAction.workOrderReject);
|
||||
workOrderReturn.setDesc(vo.getDistributionDesc());
|
||||
workOrderHisService.returnWorkOrder(workOrderOld,workOrderReturn);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
// 关闭工单closeJob
|
||||
@PostMapping("closeWorkOrder")
|
||||
@ApiOperation(value = "关闭工单")
|
||||
@LogAnnotation(title = "工单管理", action = "关闭工单")
|
||||
public DataResult closeWorkOrder(@RequestBody @Valid WorkOrderApplyReqVO vo,HttpServletRequest request) {
|
||||
//判断工单
|
||||
WorkOrderOld workOrderOld = workOrderHisService.findByOrderId(vo.getOrderId());
|
||||
if (workOrderOld == null) {
|
||||
//没找到数据
|
||||
throw new BusinessException(BaseResponseCode.DATA_NOT_EXISTS);
|
||||
}
|
||||
//工单状态必须是处理中的状态
|
||||
if (!WorkOrderConstant.WorkOrderStatus.working.equals(workOrderOld.getWorkOrderStatus())) {
|
||||
throw new BusinessException(BaseResponseCode.WORK_ORDER_STATUS_NOT_PROCESS_CANNOT_CLOSED);
|
||||
}
|
||||
//关闭工单时将状态改为已完成的状态
|
||||
workOrderOld.setWorkOrderStatus(WorkOrderConstant.WorkOrderStatus.finished);
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//生成流转记录
|
||||
// workOrderAction 指定当前动作
|
||||
WorkOrderCirculation workOrderClose = new WorkOrderCirculation();
|
||||
workOrderClose.setId(snowflake.nextId());
|
||||
workOrderClose.setOrderId(workOrderOld.getOrderId());
|
||||
workOrderClose.setFromId(simpleUser.getUserId());
|
||||
workOrderClose.setToId(vo.getToId());
|
||||
workOrderClose.setCreateTime(new Date());
|
||||
workOrderClose.setDesc(vo.getDistributionDesc());
|
||||
//原来对应工单关闭,现在对应验收完成
|
||||
//workOrderClose.setWorkOrderAction(WorkOrderConstant.WorkOrderAction.workOrderClose);
|
||||
workOrderClose.setWorkOrderAction(WorkOrderConstant.WorkOrderAction.workOrderCheckComplete);
|
||||
workOrderHisService.closeWorkOrder(workOrderOld,workOrderClose);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
//一个人可以查询的工单是自己所辖电站的全部工单
|
||||
@PostMapping("page")
|
||||
@ApiOperation(value = "查询工单")
|
||||
public DataResult<PageResult<WorkOrderOldPageRespVO>> selectByPage(@RequestBody @Valid WorkOrderPageReq vo, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
UserDetailRespVO userDetailRespVO = redisService.getUserDetailByToken(token);
|
||||
List<String> roles = userDetailRespVO.getRoles();
|
||||
//查询SimpleUser
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
List<Integer> stationIds = simpleUser.getStationIds();
|
||||
//如果 stationId没传 要查所辖电站的数据
|
||||
if(org.springframework.util.StringUtils.isEmpty(vo.getStationId())){
|
||||
vo.setStationIds(stationIds);
|
||||
}
|
||||
//因为是使用stationIds查询的,不为空时那么把stationId加进去
|
||||
else{
|
||||
stationIds = new ArrayList<>();
|
||||
stationIds.add(vo.getStationId());
|
||||
vo.setStationIds(stationIds);
|
||||
}
|
||||
String roleLeader = null;
|
||||
String roleWorker = null;
|
||||
//工单使用岗位进行流程控制,不再使用角色
|
||||
//
|
||||
/*for (String role : roles) {
|
||||
if (CommonConstant.ROLE_WORK_ORDER_LEADER.equals(role)){
|
||||
roleLeader = CommonConstant.ROLE_WORK_ORDER_LEADER;
|
||||
}else if (CommonConstant.ROLE_WORK_ORDER_DO.equals(role)){
|
||||
roleWorker = CommonConstant.ROLE_WORK_ORDER_DO;
|
||||
}
|
||||
}*/
|
||||
|
||||
//判断3种情况(1都没有; 2:worker 3: leader 或 leader he worker 或 leader )
|
||||
//情况1
|
||||
/*if(roleLeader ==null &&roleWorker ==null){
|
||||
vo.setRoleOther(CommonConstant.ROLE_WORK_ORDER_OTHER);
|
||||
vo.setFromId(userDetailRespVO.getUserId());
|
||||
vo.setToId(userDetailRespVO.getUserId());
|
||||
}else if(roleLeader ==null && roleWorker !=null){
|
||||
//
|
||||
vo.setRoleWorker(CommonConstant.ROLE_WORK_ORDER_DO);
|
||||
vo.setFromId(userDetailRespVO.getUserId());
|
||||
vo.setToId(userDetailRespVO.getUserId());
|
||||
}else{
|
||||
vo.setRoleLeader(CommonConstant.ROLE_WORK_ORDER_LEADER);
|
||||
vo.setToId(userDetailRespVO.getUserId());
|
||||
vo.setFromId(userDetailRespVO.getUserId());
|
||||
}*/
|
||||
//能查到的工单和这个人的角色或岗位没有关系,只和该用户所辖电站有关
|
||||
|
||||
PageResult<WorkOrderOldPageRespVO> result = workOrderHisService.selectPage(vo,simpleUser);
|
||||
return DataResult.success(result);
|
||||
}
|
||||
|
||||
@PostMapping("hisPage")
|
||||
@ApiOperation(value = "查询历史工单")
|
||||
public DataResult<PageResult<WorkOrderOldPageRespVO>> selectHisByPage(@RequestBody @Valid WorkOrderPageReq vo, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//如果 stationId没传 要查所辖电站的数据
|
||||
if(org.springframework.util.StringUtils.isEmpty(vo.getStationId())){
|
||||
vo.setStationIds(simpleUser.getStationIds());
|
||||
}
|
||||
PageResult<WorkOrderOldPageRespVO> result = workOrderHisService.selectHisPage(vo);
|
||||
return DataResult.success(result);
|
||||
}
|
||||
|
||||
@GetMapping("circulation/{orderId}")
|
||||
@ApiOperation(value = "查询工单流转记录")
|
||||
public DataResult<List<WorkOrderCirculationRespVO>> getWorkOrderControllerList(@PathVariable @Valid String orderId) {
|
||||
List<WorkOrderCirculationRespVO> list = workOrderCirculationService.selectByOrderId(orderId);
|
||||
return DataResult.success(list);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package com.ho.flow.controller;
|
||||
|
||||
import com.ho.common.tools.annotation.TokenIgnore;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.entity.WorkOrderPicture;
|
||||
import com.ho.flow.service.WorkOrderPictureService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @Description 图片
|
||||
* Author yule
|
||||
* Date 2023/1/4 10:48
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping( ContextConstant.FLOW_CONTEXT + "picture")
|
||||
public class WorkOrderPictureController {
|
||||
|
||||
@Autowired
|
||||
WorkOrderPictureService workOrderPictureService;
|
||||
|
||||
//根据路径新增图片对象数据入库
|
||||
@PostMapping("/addPicture")
|
||||
@TokenIgnore
|
||||
public WorkOrderPicture addPicture(@RequestBody String url){
|
||||
WorkOrderPicture picture = workOrderPictureService.insertPicture(url);
|
||||
return picture;
|
||||
}
|
||||
//根据id查询图片对象
|
||||
@PostMapping("/selectByIdPicture")
|
||||
@TokenIgnore
|
||||
public WorkOrderPicture selectPicture(@RequestBody Integer id){
|
||||
WorkOrderPicture picture = workOrderPictureService.selectById(id);
|
||||
return picture;
|
||||
}
|
||||
|
||||
@PostMapping("/deletePicture")
|
||||
@TokenIgnore
|
||||
public void deletePicture(@RequestBody Integer id){
|
||||
WorkOrderPicture picture = workOrderPictureService.selectById(id);
|
||||
//先删除文件
|
||||
File file = new File(picture.getUrl());
|
||||
if (file.exists()){
|
||||
file.delete();
|
||||
}
|
||||
//在删除数据库中数据
|
||||
workOrderPictureService.deletedById(id);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,132 @@
|
||||
package com.ho.flow.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ho.common.tools.annotation.LogAnnotation;
|
||||
import com.ho.common.tools.constant.CommonConstant;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.OrderDept;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.common.tools.util.PageUtils;
|
||||
import com.ho.flow.service.WorkOrderPlanService;
|
||||
import com.ho.flow.service.WorkOrderService;
|
||||
import com.ho.flow.vo.req.workorderplan.WorkOrderPlanAddReqVO;
|
||||
import com.ho.flow.vo.req.workorderplan.WorkOrderPlanReqVO;
|
||||
import com.ho.flow.vo.resp.workorderplan.WorkOrderPlanRespVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description 工单计划
|
||||
* Author yule
|
||||
* Date 2023/3/16 15:28
|
||||
*/
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT + "workOrderPlan")
|
||||
@RestController
|
||||
@Api(tags = "工单计划")
|
||||
public class WorkOrderPlanController {
|
||||
|
||||
@Autowired
|
||||
WorkOrderPlanService workOrderPlanService;
|
||||
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
WorkOrderService workOrderService;
|
||||
|
||||
//执行工单的岗位
|
||||
@Value("#{'${flow.workOrder.doing}'.split(',')}")
|
||||
String[] doing;
|
||||
|
||||
@PostMapping("getPersons")
|
||||
@ApiOperation(value = "选择计划的执行人员列表")
|
||||
public DataResult<List<OrderDept>> getPersons(HttpServletRequest request) {
|
||||
String token = request.getHeader(CommonConstant.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
List<String> postCodes = Arrays.asList(doing);
|
||||
List<OrderDept> orderDeptUsers = workOrderService.selectOrderUser(simpleUser.getGroupId(), postCodes);
|
||||
return DataResult.success(orderDeptUsers);
|
||||
}
|
||||
|
||||
@PostMapping("add")
|
||||
@ApiOperation(value = "新增工单计划")
|
||||
@LogAnnotation(title = "工单计划", action = "新增工单计划")
|
||||
public DataResult add(@RequestBody @Valid WorkOrderPlanAddReqVO vo, HttpServletRequest request) {
|
||||
//根据登录人设置集团id和用户id
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
String userTokenKey = RedisKeyConstant.User.TOKEN + token;
|
||||
if (redisService.hasKey(userTokenKey)) {
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
vo.setGroupId(simpleUser.getGroupId());
|
||||
vo.setUserId(simpleUser.getUserId());
|
||||
}
|
||||
workOrderPlanService.add(vo);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("delete")
|
||||
@ApiOperation(value = "删除工单计划")
|
||||
@LogAnnotation(title = "工单计划", action = "删除工单计划")
|
||||
public DataResult delete(@RequestBody @Valid WorkOrderPlanReqVO vo) {
|
||||
workOrderPlanService.delete(vo);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("update")
|
||||
@ApiOperation(value = "修改工单计划")
|
||||
@LogAnnotation(title = "工单计划", action = "修改工单计划")
|
||||
public DataResult update(@RequestBody @Valid WorkOrderPlanAddReqVO vo) {
|
||||
workOrderPlanService.update(vo);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("all")
|
||||
@ApiOperation(value = "查询全部工单计划")
|
||||
public DataResult<PageResult<WorkOrderPlanRespVO>> getAll(@RequestBody @Valid WorkOrderPlanReqVO vo,HttpServletRequest request) {
|
||||
//根据登录人设置集团id和用户id
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
String userTokenKey = RedisKeyConstant.User.TOKEN + token;
|
||||
if (redisService.hasKey(userTokenKey)) {
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
vo.setGroupId(simpleUser.getGroupId());
|
||||
}
|
||||
List<WorkOrderPlanRespVO> workOrderPlanRespVOList = workOrderPlanService.getAll(vo);
|
||||
//根据时间排序
|
||||
workOrderPlanRespVOList = workOrderPlanRespVOList.stream().sorted(
|
||||
Comparator.comparing(WorkOrderPlanRespVO::getEffectDate, Comparator.nullsLast(Date::compareTo)).reversed()
|
||||
).collect(Collectors.toList());
|
||||
PageResult pageResult = new PageResult<>();
|
||||
if (!workOrderPlanRespVOList.isEmpty()) {
|
||||
List list = PageUtils.dealList(workOrderPlanRespVOList, vo.getPageNum(), vo.getPageSize());
|
||||
pageResult = PageUtils.getPageResult(new PageInfo<>(list));
|
||||
pageResult.setTotalRows(workOrderPlanRespVOList.size());
|
||||
pageResult.setTotalPages(list.size() / vo.getPageSize() + 1);
|
||||
}
|
||||
return DataResult.success(pageResult);
|
||||
}
|
||||
|
||||
@PostMapping("getOne")
|
||||
@ApiOperation(value = "查询单个工单计划")
|
||||
public DataResult<WorkOrderPlanRespVO> getOne(@RequestBody @Valid WorkOrderPlanReqVO vo) {
|
||||
WorkOrderPlanRespVO workOrderPlanRespVO = workOrderPlanService.getOne(vo);
|
||||
return DataResult.success(workOrderPlanRespVO);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.ho.flow.controller.process;
|
||||
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.flow.service.process.service.OrderFormService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author yule
|
||||
* @Date 2023/9/7 20:36
|
||||
* @desc ${}
|
||||
*/
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT + "OrderForm")
|
||||
@RestController
|
||||
@Api(tags = "表单数据")
|
||||
public class OrderFormController {
|
||||
|
||||
@Autowired
|
||||
OrderFormService orderFormService;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,161 @@
|
||||
package com.ho.flow.controller.process;
|
||||
|
||||
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.flow.entity.process.ProcessDefinitionDTO;
|
||||
import com.ho.flow.service.process.service.IProcessDefinitionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT + "processDefinition")
|
||||
@RestController
|
||||
@Api(tags = "流程定义(绘制流程)")
|
||||
public class ProcessDefinitionController {
|
||||
|
||||
@Autowired
|
||||
private IProcessDefinitionService processDefinitionService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 获取流程定义集合
|
||||
*
|
||||
* @param processDefinition
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/list")
|
||||
@ApiOperation(value = "分页查询流程定义集合")
|
||||
public DataResult<PageResult<ProcessDefinitionDTO>> list(@RequestBody ProcessDefinitionDTO processDefinition,HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
processDefinition.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
return DataResult.success(processDefinitionService.selectProcessDefinitionList(processDefinition));
|
||||
}
|
||||
|
||||
|
||||
/* @ApiOperation(value = "")
|
||||
@GetMapping("/getDefinitions/{instanceId}")
|
||||
public DataResult getDefinitionsByInstanceId(@PathVariable("instanceId") String instanceId) {
|
||||
return DataResult.success(processDefinitionService.getDefinitionsByInstanceId(instanceId));
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 删除流程定义
|
||||
*
|
||||
* @param deploymentId
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/remove/{deploymentId}")
|
||||
@ApiOperation(value = "删除流程定义")
|
||||
public DataResult delDefinition(@PathVariable("deploymentId") String deploymentId) {
|
||||
processDefinitionService.deleteProcessDefinitionById(deploymentId);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传并部署流程定义
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@PostMapping(value = "/uploadStreamAndDeployment")
|
||||
@ApiOperation(value = "上传并部署流程定义")
|
||||
public DataResult uploadStreamAndDeployment(@RequestBody MultipartFile file) throws IOException {
|
||||
processDefinitionService.uploadStreamAndDeployment(file);
|
||||
return DataResult.success();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动挂起流程流程定义
|
||||
*
|
||||
* @param processDefinition
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/suspendOrActiveApply")
|
||||
@ApiOperation(value = "启动挂起流程流程定义")
|
||||
public DataResult suspendOrActiveApply(@RequestBody ProcessDefinitionDTO processDefinition) {
|
||||
processDefinitionService.suspendOrActiveApply(processDefinition.getId(), processDefinition.getSuspendState());
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
/* *//**
|
||||
* 上传流程流程定义
|
||||
*
|
||||
* @param multipartFile
|
||||
* @return
|
||||
* @throws IOException
|
||||
*//*
|
||||
@PostMapping(value = "/upload")
|
||||
@ApiOperation(value = "上传流程流程定义")
|
||||
public DataResult upload(@RequestParam("processFile") MultipartFile multipartFile) throws IOException {
|
||||
|
||||
if (multipartFile.isEmpty()) {
|
||||
throw new BusinessException(BaseResponseCode.FILE_IS_EMPTY);
|
||||
}
|
||||
String fileName = processDefinitionService.upload(multipartFile);
|
||||
return DataResult.success();
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* 通过stringBPMN添加流程定义
|
||||
*
|
||||
* @param stringBPMN
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/addDeploymentByString")
|
||||
@ApiOperation(value = "新增流程定义")
|
||||
public DataResult addDeploymentByString(@RequestBody String stringBPMN, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
processDefinitionService.addDeploymentByString(stringBPMN,String.valueOf(simpleUser.getGroupId()));
|
||||
return DataResult.success();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取流程定义XML
|
||||
*
|
||||
* @param response
|
||||
* @param deploymentId
|
||||
* @param resourceName
|
||||
*/
|
||||
@GetMapping(value = "/getDefinitionXML")
|
||||
@ApiOperation(value = "获取流程定义XML")
|
||||
public void getProcessDefineXML(HttpServletResponse response,
|
||||
@RequestParam("deploymentId") String deploymentId,
|
||||
@RequestParam("resourceName") String resourceName) throws IOException {
|
||||
|
||||
processDefinitionService.getProcessDefineXML(response, deploymentId, resourceName);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/initDeploymentByString")
|
||||
@ApiOperation(value = "初始化固定流程")
|
||||
public DataResult initDeploymentByString() {
|
||||
processDefinitionService.initDeploymentByString();
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,759 @@
|
||||
package com.ho.flow.controller.process;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ho.business.entity.Station;
|
||||
import com.ho.business.vo.resp.DeviceRespVO;
|
||||
import com.ho.common.tools.annotation.HzPermission;
|
||||
import com.ho.common.tools.constant.CommonConstant;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.constant.PermissionConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.OrderForm;
|
||||
import com.ho.common.tools.entity.ProcessOrder;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
import com.ho.common.tools.entity.file.OrderFile;
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.BusinessException;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.common.tools.util.PageUtils;
|
||||
import com.ho.flow.entity.process.MovementDTO;
|
||||
import com.ho.flow.entity.process.PreDoUser;
|
||||
import com.ho.flow.entity.process.TaskOrderInfo;
|
||||
import com.ho.flow.feignclient.BusinessFeignClient;
|
||||
import com.ho.flow.feignclient.UserFeignClient;
|
||||
import com.ho.flow.mapper.EventMapper;
|
||||
import com.ho.flow.monitor.EventToProcessMonitor;
|
||||
import com.ho.flow.service.ProcessFlowService;
|
||||
import com.ho.flow.service.process.service.ProcessFlowNewService;
|
||||
import com.ho.flow.util.PDFutil;
|
||||
import com.ho.flow.vo.Event;
|
||||
import com.ho.flow.vo.req.workorder.*;
|
||||
import com.ho.flow.vo.resp.workorder.*;
|
||||
import com.ho.user.api.entity.SysUser;
|
||||
import com.itextpdf.text.*;
|
||||
import com.itextpdf.text.pdf.BaseFont;
|
||||
import com.itextpdf.text.pdf.PdfPCell;
|
||||
import com.itextpdf.text.pdf.PdfPTable;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author yule
|
||||
* @Date 2023/8/29 10:41
|
||||
* @desc ${}
|
||||
*/
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT + "processFlowNew")
|
||||
@RestController
|
||||
@Api(tags = "工单模块")
|
||||
public class ProcessFlowNewController {
|
||||
|
||||
@Autowired
|
||||
ProcessFlowNewService processFlowNewService;
|
||||
|
||||
@Autowired
|
||||
ProcessFlowService processFlowService;
|
||||
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
|
||||
|
||||
@PostMapping("deployment")
|
||||
@ApiOperation(value = "部署")
|
||||
public DataResult<String> deployment(@RequestBody @Valid ProcessOrder processOrder, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
processOrder.setUserId(simpleUser.getUserId());
|
||||
return DataResult.success(processFlowNewService.deployment(processOrder));
|
||||
}
|
||||
|
||||
@PostMapping("initProcessInstance")
|
||||
@ApiOperation(value = "发起工单")
|
||||
public DataResult initProcessInstance(@RequestBody @Valid ProcessOrder processOrder, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
processOrder.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
processOrder.setUserId(simpleUser.getUserId());
|
||||
processFlowNewService.initProcessInstance(processOrder);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("preForward")
|
||||
@ApiOperation(value = "转发前选择候选人")
|
||||
public DataResult<List<PreDoUser>> preForward(HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
simpleUser.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
return DataResult.success(processFlowNewService.preForward(simpleUser));
|
||||
}
|
||||
|
||||
@PostMapping("forward")
|
||||
@ApiOperation(value = "转发")
|
||||
public DataResult forward(@RequestBody @Valid TaskDone taskDone, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
simpleUser.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
taskDone.setSender(simpleUser.getUserId());
|
||||
processFlowNewService.forward(taskDone);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("queryTodoList")
|
||||
@ApiOperation(value = "查询代办列表")
|
||||
public DataResult<List<TaskDone>> queryTodoList(@RequestBody(required = false) @Valid DoListTaskReq doListTaskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
simpleUser.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
doListTaskReq.setUserId(simpleUser.getUserId());
|
||||
Map<String, List<Task>> taskMap = processFlowNewService.getTodoList(simpleUser);
|
||||
List<TaskDone> todoList = new ArrayList<>();
|
||||
//代办不分页,转换为TaskDone对象
|
||||
if (!taskMap.isEmpty()) {
|
||||
todoList = processFlowNewService.getToDoListFromTask(taskMap, doListTaskReq);
|
||||
}
|
||||
if (!todoList.isEmpty()) {
|
||||
//根据优先级排序然后根据时间和条件进行过滤
|
||||
todoList = todoList.stream().filter(s -> {
|
||||
boolean flag = true;
|
||||
String title = doListTaskReq.getTitle();
|
||||
if (!StringUtils.isEmpty(title)) {
|
||||
if (!StringUtils.isEmpty(s.getTitle()) && !s.getTitle().contains(title)) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
Integer stationId = doListTaskReq.getStationId();
|
||||
if (stationId != null) {
|
||||
if (s.getStationId() != null && !stationId.equals(s.getStationId())) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}).sorted(
|
||||
Comparator.comparing(TaskDone::getPriority, Comparator.nullsLast(String::compareTo)).reversed().
|
||||
thenComparing(TaskDone::getStartTime, Comparator.nullsLast(Date::compareTo)).reversed()
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
return DataResult.success(todoList);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("queryTodoCount")
|
||||
@ApiOperation(value = "查询代办数量")
|
||||
public DataResult<Integer> queryTodoCount(@RequestBody(required = false) @Valid DoListTaskReq doListTaskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
simpleUser.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
if (doListTaskReq == null) {
|
||||
doListTaskReq = new DoListTaskReq();
|
||||
doListTaskReq.setUserId(simpleUser.getUserId());
|
||||
}
|
||||
Map<String, List<Task>> taskMap = processFlowNewService.getTodoList(simpleUser);
|
||||
List<TaskDone> todoList = new ArrayList<>();
|
||||
//代办不分页,转换为TaskDone对象
|
||||
if (!taskMap.isEmpty()) {
|
||||
todoList = processFlowNewService.getToDoListFromTask(taskMap, doListTaskReq);
|
||||
return DataResult.success(todoList.size());
|
||||
}else {
|
||||
return DataResult.success(0);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("queryDoneList")
|
||||
@ApiOperation(value = "查询已办列表")
|
||||
public DataResult<PageResult<TaskDone>> queryDoneList(@RequestBody @Valid DoListTaskReq doListTaskReq, HttpServletRequest request) {
|
||||
Date date = new Date();
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
simpleUser.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
doListTaskReq.setUserId(simpleUser.getUserId());
|
||||
List<HistoricTaskInstance> taskList = processFlowNewService.getDoneList(simpleUser);
|
||||
List<TaskDone> doneList = new ArrayList<>();
|
||||
doneList = processFlowNewService.getDoneListFromTask(taskList, doListTaskReq);
|
||||
doneList = doneList.stream().filter(s -> {
|
||||
boolean flag = true;
|
||||
String title = doListTaskReq.getTitle();
|
||||
if (!StringUtils.isEmpty(title)) {
|
||||
if (!StringUtils.isEmpty(s.getTitle()) && !s.getTitle().contains(title)) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
Integer stationId = doListTaskReq.getStationId();
|
||||
if (stationId != null) {
|
||||
if (s.getStationId() != null && !stationId.equals(s.getStationId())) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}).sorted(
|
||||
//根据时间倒序排序
|
||||
Comparator.comparing(TaskDone::getStartTime).reversed()
|
||||
).collect(Collectors.toList());
|
||||
if (!doneList.isEmpty()) {
|
||||
//获取到代办任务
|
||||
DataResult<List<TaskDone>> listDataResult = queryTodoList(doListTaskReq, request);
|
||||
//代办的任务
|
||||
List<TaskDone> todoList = listDataResult.getData();
|
||||
todoList = todoList.stream().filter(s->{
|
||||
if (s.getProcessInstanceId() != null){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
Map<String, List<TaskDone>> todoMap = todoList.stream().collect(Collectors.groupingBy(TaskDone::getProcessInstanceId));
|
||||
//移除在代办任务中存在的任务对象
|
||||
doneList.removeIf(s -> {
|
||||
boolean flag = false;
|
||||
if (todoMap.get(s.getProcessInstanceId()) != null) {
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
});
|
||||
}
|
||||
PageResult pageResult = new PageResult<>();
|
||||
if (!doneList.isEmpty()) {
|
||||
List list = PageUtils.dealList(doneList, doListTaskReq.getPageNum(), doListTaskReq.getPageSize());
|
||||
pageResult = PageUtils.getPageResult(new PageInfo<>(list));
|
||||
pageResult.setTotalRows(doneList.size());
|
||||
pageResult.setPageSize(doListTaskReq.getPageSize());
|
||||
pageResult.setTotalPages(doneList.size() / doListTaskReq.getPageSize() + 1);
|
||||
}
|
||||
return DataResult.success(pageResult);
|
||||
}
|
||||
|
||||
@PostMapping("queryInspectionList")
|
||||
@ApiOperation(value = "查询巡检任务列表")
|
||||
public DataResult<List<TaskDone>> queryInspectionList(@RequestBody(required = false) @Valid DoListTaskReq doListTaskReq, HttpServletRequest request) {
|
||||
DataResult result = new DataResult();
|
||||
//查询巡检相关的工单号列表
|
||||
List<OrderForm> orderFormList = processFlowNewService.getInspectionOrders(doListTaskReq.getStationId());
|
||||
//未发起流程的工单id集合
|
||||
List<Integer> orderFormId = orderFormList.stream().filter(e ->e.getProcessInstanceId() == null&& e.getStatus() == 0).map(OrderForm::getId).collect(Collectors.toList());
|
||||
//已发起工单的流程实例id集合
|
||||
List<String> processInstanceId = orderFormList.stream().filter(e ->e.getProcessInstanceId() != null&& e.getStatus() == 1).map(OrderForm::getProcessInstanceId).collect(Collectors.toList());
|
||||
List<TaskDone> totalTask = new ArrayList<>();
|
||||
DataResult<List<TaskDone>> toDoList = queryTodoList(doListTaskReq,request);
|
||||
// DataResult<PageResult<TaskDone>> doneList = queryDoneList(doListTaskReq,request);
|
||||
totalTask.addAll(toDoList.getData());
|
||||
// totalTask.addAll(doneList.getData().getList());
|
||||
//筛选巡检相关的待办工单(未发起流程的工单比较id,发起流程的工单比较processInstanceId)
|
||||
totalTask = totalTask.stream().filter(e ->
|
||||
(orderFormId.size()>0 && orderFormId.contains(e.getId()))||(processInstanceId.size()>0 && processInstanceId.contains(e.getProcessInstanceId())))
|
||||
.collect(Collectors.toList());
|
||||
result.setData(totalTask);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("preDo")
|
||||
@ApiOperation(value = "流转前的方法")
|
||||
public DataResult<List<PreDoUser>> preDo(@RequestBody @Valid TaskUserReq taskUserReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
taskUserReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
taskUserReq.setUserId(simpleUser.getUserId());
|
||||
taskUserReq.setDeptId(String.valueOf(simpleUser.getDeptId()));
|
||||
List<PreDoUser> users = new ArrayList<>();
|
||||
if (taskUserReq.getProcessInstId() != null) {
|
||||
users = processFlowNewService.getPreDo(taskUserReq);
|
||||
} else {
|
||||
users = processFlowNewService.getFristPreDo(taskUserReq);
|
||||
}
|
||||
return DataResult.success(users);
|
||||
}
|
||||
|
||||
@PostMapping("approval")
|
||||
@ApiOperation(value = "审批通过(流转)")
|
||||
public DataResult approval(@RequestBody @Valid DoTaskReq doTaskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置发送者的id
|
||||
doTaskReq.setSenderId(simpleUser.getUserId());
|
||||
//设置租户id
|
||||
doTaskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
//完成任务的责任人必须和自己相同,否则需要给出提示
|
||||
doTaskReq.setAssigneeUser(simpleUser.getUserId());
|
||||
if (doTaskReq.getProcessInstId() != null) {
|
||||
processFlowNewService.approval(doTaskReq);
|
||||
} else {
|
||||
processFlowNewService.getFristApproval(doTaskReq);
|
||||
}
|
||||
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("approvalFailed")
|
||||
@ApiOperation(value = "审批不通过")
|
||||
public DataResult approvalFailed(@RequestBody @Valid DoTaskReq doTaskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置发送者的id
|
||||
doTaskReq.setSenderId(simpleUser.getUserId());
|
||||
//设置租户id
|
||||
doTaskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
//完成任务的责任人必须和自己相同,否则需要给出提示
|
||||
doTaskReq.setAssigneeUser(simpleUser.getUserId());
|
||||
processFlowNewService.approvalFailed(doTaskReq);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("fallBackTaskList")
|
||||
@ApiOperation(value = "回退任务列表")
|
||||
public DataResult<List<FallBackTaskResp>> fallBackTask(@RequestBody FallBackTaskReq fallBackTaskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
fallBackTaskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
List<FallBackTaskResp> fallBackTaskResps = new ArrayList<>();
|
||||
if (fallBackTaskReq.getProcessInstId() != null) {
|
||||
fallBackTaskResps = processFlowNewService.getFallBackTask(fallBackTaskReq);
|
||||
}
|
||||
return DataResult.success(fallBackTaskResps);
|
||||
}
|
||||
|
||||
@PostMapping("fallBackTask")
|
||||
@ApiOperation(value = "回退任务")
|
||||
public DataResult rejectTask(@RequestBody RejectTaskReq rejectTaskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置发送人
|
||||
rejectTaskReq.setUserId(simpleUser.getUserId());
|
||||
//设置租户id
|
||||
rejectTaskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
processFlowNewService.fallBackTask(rejectTaskReq);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("detailsTask")
|
||||
@ApiOperation(value = "工单详情")
|
||||
public DataResult<List<HisTaskResp>> detailsTask(@RequestBody CirculationTaskReq taskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
taskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
taskReq.setAssigneeUser(simpleUser.getUserId());
|
||||
List<HisTaskResp> hisTaskRespList = new ArrayList<>();
|
||||
if (taskReq.getProcessInstId() != null) {
|
||||
hisTaskRespList = processFlowNewService.detailsTask(taskReq);
|
||||
} else {
|
||||
hisTaskRespList = processFlowNewService.detailsFirstTask(taskReq);
|
||||
}
|
||||
return DataResult.success(hisTaskRespList);
|
||||
}
|
||||
|
||||
@PostMapping("taskInfo")
|
||||
@ApiOperation(value = "任务详情")
|
||||
public DataResult<TaskOrderInfo> taskInfo(@RequestBody CirculationTaskReq taskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
taskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
taskReq.setAssigneeUser(simpleUser.getUserId());
|
||||
TaskOrderInfo taskOrderInfo = new TaskOrderInfo();
|
||||
if (taskReq.getProcessInstId() != null) {
|
||||
taskOrderInfo = processFlowNewService.taskInfo(taskReq);
|
||||
} else {
|
||||
taskOrderInfo = processFlowNewService.firstTaskInfo(taskReq);
|
||||
}
|
||||
return DataResult.success(taskOrderInfo);
|
||||
}
|
||||
|
||||
@PostMapping("claimTask")
|
||||
@ApiOperation(value = "接收任务")
|
||||
public DataResult claimTask(@RequestBody @Valid TaskUserReq taskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
taskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
taskReq.setUserId(simpleUser.getUserId());
|
||||
processFlowNewService.doClaimTask(taskReq);
|
||||
//代办应该分页,做个java内存分页处理
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("save")
|
||||
@ApiOperation(value = "保存")
|
||||
public DataResult save(@RequestBody @Valid TaskUserReq taskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
taskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
taskReq.setUserId(simpleUser.getUserId());
|
||||
if (taskReq.getProcessInstId() != null) {
|
||||
processFlowNewService.save(taskReq);
|
||||
} else {
|
||||
processFlowNewService.saveOrderForm(taskReq);
|
||||
}
|
||||
//代办应该分页,做个java内存分页处理
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("cancel")
|
||||
@ApiOperation(value = "作废")
|
||||
public DataResult cancel(@RequestBody @Valid TaskUserReq taskReq, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
//设置租户id
|
||||
taskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
taskReq.setUserId(simpleUser.getUserId());
|
||||
processFlowNewService.cancel(taskReq);
|
||||
//代办应该分页,做个java内存分页处理
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
PDFutil pdFutil;
|
||||
|
||||
@PostMapping("exportPDF")
|
||||
@ApiOperation(value = "导出PDF")
|
||||
public void exportPDF(@RequestBody CirculationTaskReq taskReq, HttpServletRequest request, HttpServletResponse response) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
taskReq.setTenantId(String.valueOf(simpleUser.getGroupId()));
|
||||
taskReq.setAssigneeUser(simpleUser.getUserId());
|
||||
List<List<HisTaskResp>> list = new ArrayList<>();
|
||||
|
||||
if (!taskReq.getProcessInstIds().isEmpty()) {
|
||||
for (String processInstId : taskReq.getProcessInstIds()) {
|
||||
taskReq.setProcessInstId(processInstId);
|
||||
List<HisTaskResp> hisTaskRespList = new ArrayList<>();
|
||||
if (taskReq.getProcessInstId() != null) {
|
||||
hisTaskRespList = processFlowNewService.detailsTask(taskReq);
|
||||
} else {
|
||||
hisTaskRespList = processFlowNewService.detailsFirstTask(taskReq);
|
||||
}
|
||||
list.add(hisTaskRespList);
|
||||
}
|
||||
}
|
||||
// 设置页面编码格式
|
||||
String pdfName = "流程跟踪";
|
||||
try {
|
||||
response.setContentType("application/pdf");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + new String((pdfName).getBytes(), "ISO-8859-1") + ".pdf");
|
||||
// 1).定义A4纸
|
||||
Document document = new Document(PageSize.A4, 48, 48, 60, 65);
|
||||
// 2).建立一个书写器(Writer)与document对象关联,通过书写器(Writer)可以将文档写入到磁盘中
|
||||
// 3).写入数据之前要打开文档
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
PdfWriter contentWriter = PdfWriter.getInstance(document, os);
|
||||
document.open();
|
||||
for (List<HisTaskResp> hisTaskRespList : list) {
|
||||
//创建需要导出的对象并赋值
|
||||
WorkOrderPDF workOrderPDF = new WorkOrderPDF();
|
||||
List<WorkOrderPDFText> workOrderPDFTexts = new ArrayList<>();
|
||||
int maxFileNum = getWorkOrderPDF(hisTaskRespList, workOrderPDF, workOrderPDFTexts);
|
||||
|
||||
//添加中文字体
|
||||
BaseFont bfCN = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
|
||||
|
||||
// 正文的字体
|
||||
Font titleFont = new Font(bfCN, 12f);
|
||||
Font textFont = new Font(bfCN, 10f);
|
||||
Font fileFont = new Font(bfCN, 10f);
|
||||
fileFont.setColor(BaseColor.BLUE);
|
||||
// 创建表格
|
||||
PdfPTable table = new PdfPTable(4);
|
||||
// 设置表格宽度百分比
|
||||
table.setWidthPercentage(100);
|
||||
float[] columnWidths = {0.5f, 0.5f, 0.5f, 0.5f};
|
||||
table.setWidths(columnWidths);
|
||||
setTitlePDF(titleFont, textFont, table, workOrderPDF);
|
||||
//电站数据表
|
||||
PdfPTable stationTable = new PdfPTable(4);
|
||||
stationTable.setWidthPercentage(100);
|
||||
stationTable.setWidths(columnWidths);
|
||||
setStationPDF(titleFont, textFont, stationTable, workOrderPDF);
|
||||
// 创建表格
|
||||
PdfPTable tableText = new PdfPTable(4 + maxFileNum);
|
||||
// 设置表格宽度百分比
|
||||
tableText.setWidthPercentage(100);
|
||||
// 设置表格列宽度
|
||||
float[] textColumnWidths = new float[4 + maxFileNum];
|
||||
textColumnWidths[0] = 1.5f;
|
||||
textColumnWidths[1] = 0.8f;
|
||||
textColumnWidths[2] = 1.8f;
|
||||
textColumnWidths[3] = 1.8f;
|
||||
for (int i = 0; i < maxFileNum; i++) {
|
||||
textColumnWidths[4 + i] = 2.0f;
|
||||
}
|
||||
tableText.setWidths(textColumnWidths);
|
||||
//添加流程跟踪数据
|
||||
setPDFText(workOrderPDFTexts, maxFileNum, titleFont, textFont,fileFont, tableText);
|
||||
document.add(table);
|
||||
document.add(stationTable);
|
||||
document.add(tableText);
|
||||
document.newPage();
|
||||
}
|
||||
|
||||
document.close();
|
||||
os.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setStationPDF(Font titleFont, Font textFont, PdfPTable table, WorkOrderPDF workOrderPDF) {
|
||||
String string = "";
|
||||
|
||||
//第一行
|
||||
pdFutil.cellFillChar(table, "电站", textFont);
|
||||
if (workOrderPDF.getStationName() != null) {
|
||||
string = workOrderPDF.getStationName();
|
||||
}
|
||||
pdFutil.cellFillChar(table, string, textFont);
|
||||
|
||||
string = "";
|
||||
pdFutil.cellFillChar(table, "设备", textFont);
|
||||
if (workOrderPDF.getDeviceName() != null) {
|
||||
string = workOrderPDF.getDeviceName();
|
||||
}
|
||||
pdFutil.cellFillChar(table, string, textFont);
|
||||
|
||||
//第二行
|
||||
string = "";
|
||||
pdFutil.cellFillChar(table, "告警", textFont);
|
||||
if (workOrderPDF.getEventDecs() != null) {
|
||||
string = workOrderPDF.getEventDecs();
|
||||
}
|
||||
PdfPCell title = new PdfPCell(new Paragraph(string, textFont));
|
||||
title.setColspan(3);
|
||||
title.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(title);
|
||||
}
|
||||
|
||||
private void setPDFText(List<WorkOrderPDFText> workOrderPDFTexts, int maxFileNum, Font titleFont, Font textFont,Font fileFont,PdfPTable tableText) {
|
||||
pdFutil.cellFillChar(tableText, "任务状态", textFont);
|
||||
pdFutil.cellFillChar(tableText, "处理人", textFont);
|
||||
pdFutil.cellFillChar(tableText, "处理时间", textFont);
|
||||
pdFutil.cellFillChar(tableText, "意见", textFont);
|
||||
if (maxFileNum != 1) {
|
||||
PdfPCell title = new PdfPCell(new Paragraph("文件", titleFont));
|
||||
title.setColspan(maxFileNum);
|
||||
title.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
title.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
|
||||
tableText.addCell(title);
|
||||
} else {
|
||||
pdFutil.cellFillChar(tableText, "文件", textFont);
|
||||
}
|
||||
for (WorkOrderPDFText workOrderPDFText : workOrderPDFTexts) {
|
||||
String string1 = "";
|
||||
if (workOrderPDFText.getTaskStatus() != null) {
|
||||
string1 = workOrderPDFText.getTaskStatus();
|
||||
}
|
||||
pdFutil.cellFillChar(tableText, string1, textFont);
|
||||
|
||||
String string2 = "";
|
||||
if (workOrderPDFText.getAssignee() != null) {
|
||||
string2 = workOrderPDFText.getAssignee();
|
||||
}
|
||||
pdFutil.cellFillChar(tableText, string2, textFont);
|
||||
|
||||
String string3 = "";
|
||||
if (workOrderPDFText.getEndTime() != null) {
|
||||
string3 = workOrderPDFText.getEndTime();
|
||||
}
|
||||
pdFutil.cellFillChar(tableText, string3, textFont);
|
||||
|
||||
String string4 = "";
|
||||
if (workOrderPDFText.getSuggestion() != null) {
|
||||
string4 = workOrderPDFText.getSuggestion();
|
||||
}
|
||||
pdFutil.cellFillChar(tableText, string4, textFont);
|
||||
|
||||
List<OrderFile> files = workOrderPDFText.getFiles();
|
||||
for (int i = 0; i < maxFileNum; i++) {
|
||||
if (files != null && files.size() > i && files.get(i) != null) {
|
||||
String fileName = files.get(i).getFileName();
|
||||
if (fileName != null && fileName.contains("jdg") || fileName.contains("png")) {
|
||||
pdFutil.cellFillImage(tableText, files.get(i).getUrl());
|
||||
}else {
|
||||
pdFutil.cellFillFile(tableText, files.get(i).getUrl(),fileName,fileFont);
|
||||
}
|
||||
} else {
|
||||
pdFutil.cellFillChar(tableText, "", textFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setTitlePDF(Font titleFont, Font textFont, PdfPTable table, WorkOrderPDF workOrderPDF) {
|
||||
|
||||
|
||||
//第一行
|
||||
String string1 = "";
|
||||
if (workOrderPDF.getTitle() != null) {
|
||||
string1 = workOrderPDF.getTitle();
|
||||
}
|
||||
PdfPCell title = new PdfPCell(new Paragraph(string1, titleFont));
|
||||
title.setColspan(4);
|
||||
title.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(title);
|
||||
|
||||
|
||||
//第二行
|
||||
String string2 = "";
|
||||
pdFutil.cellFillChar(table, "工单类型", textFont);
|
||||
if (workOrderPDF.getWorkOrderType() != null) {
|
||||
string2 = workOrderPDF.getWorkOrderType();
|
||||
}
|
||||
pdFutil.cellFillChar(table, string2, textFont);
|
||||
|
||||
String string22 = "";
|
||||
pdFutil.cellFillChar(table, "创建人", textFont);
|
||||
if (workOrderPDF.getCreateName() != null) {
|
||||
string22 = workOrderPDF.getCreateName();
|
||||
}
|
||||
pdFutil.cellFillChar(table, string22, textFont);
|
||||
|
||||
//第三行
|
||||
String string3 = "";
|
||||
pdFutil.cellFillChar(table, "创建时间", textFont);
|
||||
if (workOrderPDF.getCreatTime() != null) {
|
||||
string3 = workOrderPDF.getCreatTime();
|
||||
}
|
||||
pdFutil.cellFillChar(table, string3, textFont);
|
||||
|
||||
String string32 = "";
|
||||
pdFutil.cellFillChar(table, "计划处理时间", textFont);
|
||||
if (workOrderPDF.getPlanTime() != null) {
|
||||
string32 = workOrderPDF.getPlanTime();
|
||||
}
|
||||
pdFutil.cellFillChar(table, string32, textFont);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Autowired
|
||||
BusinessFeignClient businessFeignClient;
|
||||
|
||||
@Autowired
|
||||
UserFeignClient userFeignClient;
|
||||
|
||||
@Autowired
|
||||
EventMapper eventMapper;
|
||||
|
||||
private int getWorkOrderPDF(List<HisTaskResp> hisTaskRespList, WorkOrderPDF workOrderPDF, List<WorkOrderPDFText> workOrderPDFTexts) {
|
||||
if (!hisTaskRespList.isEmpty()) {
|
||||
HisTaskResp hisTaskResp = hisTaskRespList.get(0);
|
||||
OrderForm orderForm = hisTaskResp.getOrderForm();
|
||||
if (orderForm != null) {
|
||||
workOrderPDF.setTitle(orderForm.getTitle());
|
||||
if (orderForm.getUserId() != null){
|
||||
DataResult<SysUser> result = userFeignClient.getUserById(orderForm.getUserId());
|
||||
if (result.isSuccess() && result.getData() != null){
|
||||
workOrderPDF.setCreateName(result.getData().getRealName());
|
||||
}else {
|
||||
workOrderPDF.setCreateName("");
|
||||
}
|
||||
}
|
||||
workOrderPDF.setCreatTime(DateUtil.format(orderForm.getCreateTime(), CommonConstant.DATE));
|
||||
workOrderPDF.setPlanTime(DateUtil.format(orderForm.getPlannedTime(), CommonConstant.DATE));
|
||||
if (orderForm.getOrderType() != null) {
|
||||
switch (orderForm.getOrderType()){
|
||||
case 3:
|
||||
workOrderPDF.setWorkOrderType("清洗工单");
|
||||
break;
|
||||
case 2:
|
||||
workOrderPDF.setWorkOrderType("巡检单");
|
||||
break;
|
||||
default:
|
||||
workOrderPDF.setWorkOrderType("故障检修单");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (orderForm.getStationId() != null){
|
||||
DataResult<Station> result = businessFeignClient.selectByStationId(orderForm.getStationId());
|
||||
if (result.isSuccess() && result.getData() != null){
|
||||
workOrderPDF.setStationName(result.getData().getName());
|
||||
}else {
|
||||
workOrderPDF.setStationName("");
|
||||
}
|
||||
}
|
||||
|
||||
if (orderForm.getDeviceId() != null && orderForm.getStationId() != null){
|
||||
Map<Integer, List<Integer>> map = new HashMap<>();
|
||||
List<Integer> deviceSrcIds = new ArrayList<>();
|
||||
deviceSrcIds.add(orderForm.getDeviceId());
|
||||
map.put(orderForm.getStationId(),deviceSrcIds);
|
||||
DataResult<List<DeviceRespVO>> result = businessFeignClient.selectDeviceByStationIdsAndSrcId(map);
|
||||
if (result.isSuccess() && result.getData() != null){
|
||||
List<DeviceRespVO> deviceRespVOS = result.getData();
|
||||
if (!deviceRespVOS.isEmpty()) {
|
||||
workOrderPDF.setDeviceName(deviceRespVOS.get(0).getDeviceName());
|
||||
}
|
||||
}else {
|
||||
workOrderPDF.setDeviceName("");
|
||||
}
|
||||
}
|
||||
|
||||
if (orderForm.getEventId() != null){
|
||||
Event event = eventMapper.selectByPrimaryKey(orderForm.getEventId());
|
||||
if (event != null){
|
||||
workOrderPDF.setEventDecs(event.getDescription());
|
||||
}else {
|
||||
workOrderPDF.setEventDecs("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
int maxFileNum = 1;
|
||||
for (HisTaskResp hisTaskResp : hisTaskRespList) {
|
||||
WorkOrderPDFText text = new WorkOrderPDFText();
|
||||
text.setAssignee(hisTaskResp.getUserName());
|
||||
text.setTaskStatus(hisTaskResp.getName());
|
||||
text.setEndTime(DateUtil.format(hisTaskResp.getEndTime(), CommonConstant.DATE));
|
||||
text.setSuggestion(hisTaskResp.getSuggestion());
|
||||
if (hisTaskResp.getOrderForm() != null && !hisTaskResp.getOrderForm().getOrderFiles().isEmpty()) {
|
||||
List<OrderFile> orderFiles = hisTaskResp.getOrderForm().getOrderFiles();
|
||||
text.setFiles(orderFiles);
|
||||
if (orderFiles.size() > maxFileNum) {
|
||||
maxFileNum = orderFiles.size();
|
||||
}
|
||||
}
|
||||
workOrderPDFTexts.add(text);
|
||||
}
|
||||
return maxFileNum;
|
||||
}
|
||||
|
||||
EventToProcessMonitor monitor = new EventToProcessMonitor();
|
||||
|
||||
|
||||
@PostMapping("movement")
|
||||
@ApiOperation(value = "手动转工单")
|
||||
@HzPermission(value = {PermissionConstant.EVENT_MANUAL_TRANSFER_WORK_ORDER})
|
||||
public DataResult movement(@RequestBody @Valid MovementDTO movementDTO, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
SimpleUser simpleUser = redisService.getSimpleUserByToken(token);
|
||||
if ( movementDTO.getEvents() != null ) {
|
||||
movementDTO.setUserId(simpleUser.getUserId());
|
||||
monitor.setEvents(movementDTO);
|
||||
return DataResult.success();
|
||||
} else {
|
||||
throw new BusinessException(BaseResponseCode.MOVEMENT_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
package com.ho.flow.controller.process;
|
||||
|
||||
import com.ho.common.tools.annotation.LogAnnotation;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.flow.entity.ProcessTemplate;
|
||||
import com.ho.flow.service.process.service.ProcessManagementService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @Author yule
|
||||
* @Date 2023/8/18 9:20
|
||||
* @desc ${}
|
||||
*/
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT + "processManagement")
|
||||
@RestController
|
||||
@Api(tags = "流程管理")
|
||||
public class ProcessManagementController {
|
||||
|
||||
@Autowired
|
||||
ProcessManagementService processManagementService;
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "分页查询")
|
||||
public DataResult<PageResult<ProcessTemplate>> page(@RequestBody @Valid ProcessTemplate processTemplate) {
|
||||
PageResult<ProcessTemplate> page = processManagementService.selectPage(processTemplate);
|
||||
return DataResult.success(page);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("add")
|
||||
@ApiOperation(value = "新增流程模板")
|
||||
@LogAnnotation(title = "流程模板", action = "新增流程模板")
|
||||
public DataResult add(@RequestBody @Valid ProcessTemplate processTemplate) {
|
||||
processManagementService.add(processTemplate);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("delete")
|
||||
@ApiOperation(value = "删除流程模板")
|
||||
@LogAnnotation(title = "流程模板", action = "删除流程模板")
|
||||
public DataResult delete(@RequestBody @Valid ProcessTemplate processTemplate) {
|
||||
processManagementService.delete(processTemplate);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("edit")
|
||||
@ApiOperation(value = "修改流程模板")
|
||||
@LogAnnotation(title = "流程模板", action = "修改流程模板")
|
||||
public DataResult edit(@RequestBody @Valid ProcessTemplate processTemplate) {
|
||||
processManagementService.edit(processTemplate);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@ApiOperation(value = "查询详情")
|
||||
public DataResult<ProcessTemplate> getInfo(@PathVariable Integer id) {
|
||||
return DataResult.success(processManagementService.getInfo(id));
|
||||
}
|
||||
|
||||
@PostMapping("/{id}")
|
||||
@ApiOperation(value = "查询流程图")
|
||||
public DataResult<String> getBpmn(@PathVariable Integer id) {
|
||||
return DataResult.success(processManagementService.getBpmn(id));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package com.ho.flow.controller.process;
|
||||
|
||||
import com.ho.common.tools.annotation.LogAnnotation;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.flow.entity.ProcessTemplate;
|
||||
import com.ho.flow.service.process.service.ProcessTemplateService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author yule
|
||||
* @Date 2023/8/17 10:51
|
||||
* @desc ${}
|
||||
*/
|
||||
@RequestMapping(ContextConstant.FLOW_CONTEXT + "processTemplate")
|
||||
@RestController
|
||||
@Api(tags = "流程模板")
|
||||
public class ProcessTemplateController {
|
||||
|
||||
@Autowired
|
||||
ProcessTemplateService processTemplateService;
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "分页查询")
|
||||
public DataResult<PageResult<ProcessTemplate>> page(@RequestBody @Valid ProcessTemplate processTemplate) {
|
||||
PageResult<ProcessTemplate> page = processTemplateService.selectPage(processTemplate);
|
||||
return DataResult.success(page);
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
@ApiOperation(value = "下拉查询模版")
|
||||
public DataResult<List<ProcessTemplate>> list(@RequestBody(required = false) @Valid ProcessTemplate processTemplate) {
|
||||
List<ProcessTemplate> list = processTemplateService.selectList(processTemplate);
|
||||
return DataResult.success(list);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("add")
|
||||
@ApiOperation(value = "新增流程模板")
|
||||
@LogAnnotation(title = "流程模板", action = "新增流程模板")
|
||||
public DataResult add(@RequestBody @Valid ProcessTemplate processTemplate) {
|
||||
processTemplateService.add(processTemplate);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("delete")
|
||||
@ApiOperation(value = "删除流程模板")
|
||||
@LogAnnotation(title = "流程模板", action = "删除流程模板")
|
||||
public DataResult delete(@RequestBody @Valid ProcessTemplate processTemplate) {
|
||||
processTemplateService.delete(processTemplate);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("edit")
|
||||
@ApiOperation(value = "修改流程模板")
|
||||
@LogAnnotation(title = "流程模板", action = "修改流程模板")
|
||||
public DataResult edit(@RequestBody @Valid ProcessTemplate processTemplate) {
|
||||
processTemplateService.edit(processTemplate);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@ApiOperation(value = "查询详情")
|
||||
public DataResult<ProcessTemplate> getInfo(@PathVariable Integer id) {
|
||||
return DataResult.success(processTemplateService.getInfo(id));
|
||||
}
|
||||
|
||||
@GetMapping("getProcessXML/{id}")
|
||||
@ApiOperation(value = "查询流程图")
|
||||
public void getBpmn(HttpServletResponse response,@PathVariable Integer id) throws IOException {
|
||||
processTemplateService.getBpmn(response,id);
|
||||
}
|
||||
|
||||
}
|
||||
96
flowable-center/src/main/resources/application-dev.yml
Normal file
96
flowable-center/src/main/resources/application-dev.yml
Normal file
@ -0,0 +1,96 @@
|
||||
#文件中心
|
||||
server:
|
||||
port: 8021
|
||||
servlet:
|
||||
#上下文统一使用api,屏蔽前端路径差异
|
||||
context-path: /api
|
||||
tomcat:
|
||||
min-spare-threads: 30
|
||||
spring:
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
name: flowable-center
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.100.244:3306/flow_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowMultiQueries=true
|
||||
username: root
|
||||
password: 123456
|
||||
druid:
|
||||
initialSize: 5
|
||||
minIdle: 5
|
||||
maxActive: 5
|
||||
keepAlive: true #保持长连接
|
||||
connection-error-retry-attempts: 3
|
||||
|
||||
#Redis
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 300000ms #连接超时
|
||||
host: 192.168.100.244 #单机
|
||||
password: 123456
|
||||
database: 0
|
||||
|
||||
#port: 6379 #端口
|
||||
#timeout: 5000ms #连接超时
|
||||
#host: 127.0.0.1 #单机
|
||||
#password:
|
||||
#database: 0
|
||||
#集群 真实环境开启
|
||||
# record:
|
||||
# nodes:
|
||||
# - 127.0.0.1:6379
|
||||
# - 127.0.0.1:6380
|
||||
# - 127.0.0.1:6381
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
max-idle: 8 #连接池中最大空闲连接 默认8
|
||||
min-idle: 1 #连接池中最小空闲连接 默认0
|
||||
max-wait: 2000ms #连接池最大阻塞等待时间 使用负值表示没有限制
|
||||
#工作流
|
||||
activiti:
|
||||
# 自动部署,验证设置:true-开启(默认)、false-关闭
|
||||
check-process-definitions: false
|
||||
# 保存历史数据
|
||||
history-level: full
|
||||
# 检测历史表是否存在
|
||||
db-history-used: true
|
||||
# 关闭自动部署
|
||||
deployment-mode: never-fail
|
||||
# 对数据库中所有表进行更新操作,如果表不存在,则自动创建
|
||||
# create_drop:启动时创建表,在关闭时删除表(必须手动关闭引擎,才能删除表)
|
||||
# drop-create:启动时删除原来的旧表,然后在创建新表(不需要手动关闭引擎)
|
||||
database-schema-update: true
|
||||
# 解决频繁查询SQL问题
|
||||
async-executor-activate: false
|
||||
use-strong-uuids: false
|
||||
initialDelay: 5
|
||||
flag: 0
|
||||
|
||||
#自定义工作量变量
|
||||
flow:
|
||||
#工单流程配置
|
||||
workOrder:
|
||||
#流程定义的key ,根据实际的名称来
|
||||
procDefKey: workOrder
|
||||
#处理工单的岗位 ,后续可能是多个
|
||||
doing: tro,worker
|
||||
#验收工单的岗位
|
||||
check: tro,worker
|
||||
#评价工单的岗位
|
||||
appraise: ceo
|
||||
|
||||
#swagger2配置
|
||||
swagger2:
|
||||
enable: true #开启swagger
|
||||
projectName: 云平台--flow-前端接口
|
||||
controllerPath: com.ho.flow.controller
|
||||
|
||||
|
||||
|
||||
|
||||
3
flowable-center/src/main/resources/application.yml
Normal file
3
flowable-center/src/main/resources/application.yml
Normal file
@ -0,0 +1,3 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
69
flowable-center/src/main/resources/bootstrap.yml
Normal file
69
flowable-center/src/main/resources/bootstrap.yml
Normal file
@ -0,0 +1,69 @@
|
||||
spring:
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
#caffeine缓存
|
||||
cache:
|
||||
type: caffeine
|
||||
caffeine:
|
||||
spec: initialCapacity=50,maximumSize=500,expireAfterWrite=120s
|
||||
cache-names: alarmConfigList
|
||||
#禁止servlet懒加载
|
||||
mvc:
|
||||
servlet:
|
||||
load-on-startup: 1
|
||||
mybatis:
|
||||
type-aliases-package: com.ho.flow.entity
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
configuration:
|
||||
#驼峰
|
||||
mapUnderscoreToCamelCase: true
|
||||
|
||||
#对比电站下的采集点时间差值
|
||||
station:
|
||||
timeDifference: 5
|
||||
outSideMinute: 25
|
||||
|
||||
#ribbon的超时时间
|
||||
ribbon:
|
||||
ReadTimeout: 10000
|
||||
ConnectTimeout: 10000
|
||||
|
||||
#Logging
|
||||
logging:
|
||||
config: classpath:logback.xml
|
||||
|
||||
#开放端点用于SpringBoot Admin的监控
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: '*'
|
||||
|
||||
#流程公共配置
|
||||
flow:
|
||||
#最大上传图片个数
|
||||
maxPicUploadNum: 9
|
||||
|
||||
#告警配置
|
||||
event:
|
||||
#当前告警查询的时间跨度 (天)
|
||||
currentMaxDay: -10
|
||||
#大屏最大告警条数
|
||||
bigScreenEventLimit: 200
|
||||
|
||||
#173redeis密码
|
||||
openRedis:
|
||||
host: 124.70.135.173
|
||||
port: 6379
|
||||
pass: rD?vL&/26H
|
||||
|
||||
#183redeis密码
|
||||
openTestRedis:
|
||||
host: 192.168.1.183
|
||||
port: 6379
|
||||
pass: 123456
|
||||
|
||||
#开关相关配置
|
||||
switch:
|
||||
#系统默认的告警逻辑实现(com.ho.flow.service.impl.FlowOutApiServiceImpl),配置true时使用默认逻辑,如果配置了false则需要自定义告警逻辑实现
|
||||
usedDefaultAlarmLogic: true
|
||||
BIN
flowable-center/src/main/resources/lib/flowable-src-1.0.jar
Normal file
BIN
flowable-center/src/main/resources/lib/flowable-src-1.0.jar
Normal file
Binary file not shown.
72
flowable-center/src/main/resources/logback.xml
Normal file
72
flowable-center/src/main/resources/logback.xml
Normal file
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<configuration>
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%date{yyyy-MM-dd HH:mm:ss.SSS,CTT} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/flowable-center/flowable-center.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/flowable-center/flowable-center.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<!--180天-->
|
||||
<maxHistory>7</maxHistory>
|
||||
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,
|
||||
命名日志文件,例如log-error-2013-12-21.0.log -->
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>256MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date{yyyy-MM-dd HH:mm:ss.SSS,CTT} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!--Error级别-->
|
||||
<appender name="errorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/flowable-center/flowable-center-error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/flowable-center/flowable-center-error.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<!--180天-->
|
||||
<maxHistory>7</maxHistory>
|
||||
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,
|
||||
命名日志文件,例如log-error-2013-12-21.0.log -->
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>256MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
<!-- 此filter过滤debug级别以下的日志-->
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>ERROR</level>
|
||||
</filter>
|
||||
<!-- 级别过滤器,根据日志级别进行过滤。-->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- project default level -->
|
||||
<logger name="com.ho.flow" level="info"/>
|
||||
|
||||
<!--log4jdbc -->
|
||||
<logger name="jdbc.sqltiming" level="DEBUG"/>
|
||||
<logger name="org.activiti.engine.impl.persistence.entity" level="DEBUG"/>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="rollingFile"/>
|
||||
<appender-ref ref="errorFile"/>
|
||||
</root>
|
||||
</configuration>
|
||||
Binary file not shown.
Reference in New Issue
Block a user