Browse Source

日志模块查询接口

zhongwei
段飞宇 2 years ago
parent
commit
4e4f8179ba
  1. 1
      hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/aop/SysLogAspect.java
  2. 25
      hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/to/SysLogTo.java
  3. 8
      hzims-service/hzims-middle/pom.xml
  4. 59
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/config/Swagger2Config.java
  5. 62
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/StatisticsController.java
  6. 59
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/SysLogController.java
  7. 11
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java
  8. 14
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java
  9. 12
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java
  10. 18
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java
  11. 41
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java
  12. 34
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/StatisticsVo.java
  13. 33
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogVo.java
  14. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java
  15. 4
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessTypeController.java
  16. 114
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

1
hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/aop/SysLogAspect.java

@ -56,6 +56,7 @@ public class SysLogAspect {
//private StopWatch stopWatch = new StopWatch();
private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<>("Cost Time");

25
hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/to/SysLogTo.java

@ -1,5 +1,6 @@
package com.hnac.hzims.common.logs.to;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ -21,97 +22,115 @@ public class SysLogTo {
/**
* 租户ID
*/
@ApiModelProperty("租户ID")
private String tenantId;
/**
* 服务器ip
*/
@ApiModelProperty("服务器ip")
protected String serverIp;
/**
* 服务器地址
*/
@ApiModelProperty("服务器地址")
protected String serverHost;
/**
* 服务名称
*/
@ApiModelProperty("服务名称")
protected String serverName;
/**
* 环境
*/
@ApiModelProperty("环境")
protected String env;
/**
* 操作人 id
*/
@ApiModelProperty("操作人id")
private Long operationUserId;
/**
* 操作人
*/
@ApiModelProperty("操作人")
private String operationUserName;
/**
* 请求路径 操作地址
*/
@ApiModelProperty(" 请求路径 (操作地址)")
private String path;
/**
* 用户代理
*/
@ApiModelProperty("用户代理")
protected String userAgent;
/**
* 操作方式
*/
@ApiModelProperty("操作方式")
protected String method;
/**
* 方法类
*/
@ApiModelProperty("方法类")
protected String methodClass;
/**
* 方法名
*/
@ApiModelProperty("方法名")
protected String methodName;
/**
* 方法执行时间 消耗时间 毫秒
*/
@ApiModelProperty("法执行时间 消耗时间 毫秒")
private String costTime;
/**
* 方法入参
*/
@ApiModelProperty("方法入参")
private String parameter;
/**
* 操作方法
*/
@ApiModelProperty("操作方法")
private String title;
/**
* 方法描述
*/
@ApiModelProperty("方法描述")
private String action;
/**
* 系统类型
*/
@ApiModelProperty("系统类型")
private String operatorType;
/**
* 操作人类别
*/
@ApiModelProperty("操作人类别")
private String businessType;
@ -120,32 +139,38 @@ public class SysLogTo {
*
* @param jsonResult
*/
@ApiModelProperty("返回结果")
public String jsonResult;
/**
* 请求的Ip
*/
@ApiModelProperty("请求的Ip")
private String localIp;
/**
* 错误消息
*/
@ApiModelProperty("错误消息")
private String errorMsg;
/**
* 操作时间
*/
@ApiModelProperty("操作时间")
private LocalDateTime operationTime;
/**
* 操作状态0 正常 1 异常
*/
@ApiModelProperty("操作状态")
private Integer status;
/**
* 功能模块
*/
@ApiModelProperty("功能模块")
private String moduleName;
}

8
hzims-service/hzims-middle/pom.xml

@ -17,6 +17,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.6.13</spring-boot.version>
<swagger-bootstrap-ui.version>1.9.6</swagger-bootstrap-ui.version>
</properties>
<dependencies>
@ -59,6 +60,13 @@
</dependency>
<!--swagger-bootstrap-ui-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>${swagger-bootstrap-ui.version}</version>
</dependency>
</dependencies>
<build>

59
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/config/Swagger2Config.java

@ -0,0 +1,59 @@
package com.hnac.hzims.middle.systemlog.config;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/4/13 13:40
*/
@Configuration
@EnableSwagger2
public class Swagger2Config implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/");
registry.addResourceHandler("doc.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@Bean
public Docket webApiConfig(){
return new Docket(DocumentationType.SWAGGER_2)
.groupName("日志模块")
.apiInfo(webApiInfo())
.select()
//只显示api路径下的页面
.paths(Predicates.and(PathSelectors.regex("/systemlog/.*")))
.build();
}
private ApiInfo webApiInfo() {
return new ApiInfoBuilder()
.title("网站-API文档")
.description("本文档描述了网站微服务接口定义")
.version("1.0")
.contact(new Contact("WL", "http://localhost:8501/", "55317332@qq.com"))
.build();
}
}

62
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/StatisticsController.java

@ -1,9 +1,21 @@
package com.hnac.hzims.middle.systemlog.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
import com.hnac.hzims.common.logs.enums.BusinessType;
import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.middle.systemlog.entity.Statistics;
import com.hnac.hzims.middle.systemlog.service.StatisticsService;
import com.hnac.hzims.middle.systemlog.vo.StatisticsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
@ -13,9 +25,55 @@ import org.springframework.web.bind.annotation.RestController;
* @author dfy
* @since 2023-04-08
*/
@Api(tags = "操作日志统计数据")
@RestController
@RequestMapping("/systemlog/statistics")
public class StatisticsController {
@Autowired
private StatisticsService statisticsService;
/**
* 查询
*
* @param statistics
* @return
*/
@ApiOperation("操作日志统计数据分页查询")
@OperationAnnotation(moduleName = "操作日志",
operatorType = OperatorType.MANAGE,
businessType = BusinessType.INSERT
, title = "操作日志统计数据", action = "操作日志统计数据分页查询")
@GetMapping("/selectPage/{page}/{size}")
public R selectPage(
@PathVariable Long page,
@PathVariable Long size,
StatisticsVo statistics) {
Page<Statistics> page1 = new Page(page, size);
IPage<Statistics> pageSize = statisticsService.selectPage(page1, statistics);
return R.data(pageSize);
}
/**
* 根据Id查询日志
*
* @param id
* @return
*/
@ApiOperation("根据Id查询日志")
@OperationAnnotation(moduleName = "操作日志",
operatorType = OperatorType.MANAGE,
businessType = BusinessType.INSERT
, title = "操作日志统计数据", action = "根据Id查询日志")
@GetMapping("/get/{id}")
public R list(@PathVariable Long id) {
Statistics statistics = statisticsService.getById(id);
return R.data(statistics);
}
}

59
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/SysLogController.java

@ -2,17 +2,24 @@ package com.hnac.hzims.middle.systemlog.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
import com.hnac.hzims.common.logs.enums.BusinessType;
import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.common.logs.to.SysLogTo;
import com.hnac.hzims.middle.systemlog.entity.Statistics;
import com.hnac.hzims.middle.systemlog.entity.SysLog;
import com.hnac.hzims.middle.systemlog.service.SysLogService;
import com.hnac.hzims.middle.systemlog.vo.StatisticsVo;
import com.hnac.hzims.middle.systemlog.vo.SysLogVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.beans.BeanUtils;
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 org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
@ -39,6 +46,11 @@ public class SysLogController {
* 保存操作日志
* @param sysLogToList
*/
@OperationAnnotation(moduleName = "操作日志",
operatorType = OperatorType.MANAGE,
businessType = BusinessType.INSERT
,title = "系统日志",action = "保存操作日志")
@ApiOperation("保存操作日志")
@PostMapping("/batchSave")
public void saveBatch(@RequestBody List<SysLogTo> sysLogToList) {
//数据转换
@ -56,5 +68,44 @@ public class SysLogController {
log.info("操作日志新增失败 ~~~");
throw new IllegalArgumentException("操作日志新增失败");
}
/**
* 日志分页查询
* @param page
* @param size
* @return
*/
@OperationAnnotation(moduleName = "操作日志",
operatorType = OperatorType.MANAGE,
businessType = BusinessType.INSERT
,title = "系统日志",action = "日志分页查询")
@ApiOperation("日志分页查询")
@GetMapping("/selectPage/{page}/{size}")
public R selectPage(
@PathVariable Long page,
@PathVariable Long size,
SysLogVo sysLog) {
Page<SysLog> page1 = new Page(page, size);
IPage<SysLog> pageSize = sysLogService.selectPage(page1, sysLog);
return R.data(pageSize);
}
/**
* 根据Id获取日志数据
* @return
*/
@OperationAnnotation(moduleName = "操作日志",
operatorType = OperatorType.MANAGE,
businessType = BusinessType.INSERT
,title = "系统日志",action = "根据Id获取日志数据")
@ApiOperation("根据Id获取日志数据")
@GetMapping("/get/{id}")
public R getById(@PathVariable Long id) {
SysLog sysLog = sysLogService.getById(id);
return R.data(sysLog);
}
}

11
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.time.YearMonth;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@ -29,12 +30,14 @@ public class Statistics implements Serializable {
/**
* 编号
*/
@ApiModelProperty("编号")
@TableField("id")
private Long id;
/**
* 统计日期
*/
@ApiModelProperty("统计日期")
@TableField("date_calculated")
private String dateCalculated;
@ -42,6 +45,7 @@ public class Statistics implements Serializable {
/**
* 操作模块
*/
@ApiModelProperty("操作模块")
@TableField("title")
private String title;
@ -49,6 +53,7 @@ public class Statistics implements Serializable {
/**
* 操作模块统计
*/
@ApiModelProperty("操作模块统计")
@TableField("title_num")
private Integer titleNum;
@ -56,6 +61,7 @@ public class Statistics implements Serializable {
/**
* 功能模块统计
*/
@ApiModelProperty("功能模块统计")
@TableField("module_name")
private String moduleName;
@ -63,6 +69,7 @@ public class Statistics implements Serializable {
/**
* 功能模块统计
*/
@ApiModelProperty("功能模块统计")
@TableField("module_name_num")
private Integer moduleNameNum;
@ -70,24 +77,28 @@ public class Statistics implements Serializable {
/**
* 请求路径统计
*/
@ApiModelProperty("请求路径统计")
@TableField("path")
private String path;
/**
* 请求路径统计
*/
@ApiModelProperty("请求路径统计")
@TableField("path_num")
private Integer pathNum;
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
@TableField("create_time")
private LocalDateTime createTime;
/**
* 更新时间
*/
@ApiModelProperty("更新时间")
@TableField("update_time")
private LocalDateTime updateTime;

14
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java

@ -1,9 +1,13 @@
package com.hnac.hzims.middle.systemlog.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.middle.systemlog.entity.Statistics;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.middle.systemlog.vo.StatisticsVo;
import java.time.YearMonth;
import java.util.List;
/**
* <p>
@ -26,4 +30,14 @@ public interface StatisticsService extends IService<Statistics> {
* @return
*/
Statistics getStatisticsBydateCalculated(String operationTime);
/**
* 分页查询
* @param page1
* @param statistics
* @return
*/
IPage<Statistics> selectPage(Page<Statistics> page1, StatisticsVo statistics);
}

12
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java

@ -1,8 +1,11 @@
package com.hnac.hzims.middle.systemlog.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.middle.systemlog.entity.SysLog;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo;
import com.hnac.hzims.middle.systemlog.vo.SysLogVo;
import java.util.List;
@ -21,4 +24,13 @@ public interface SysLogService extends IService<SysLog> {
* @return
*/
List<SysLogStatisticsVo> countStatistics();
/**
* 分页查询
* @param page1
* @param sysLog
* @return
*/
IPage<SysLog> selectPage(Page<SysLog> page1, SysLogVo sysLog);
}

18
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java

@ -1,11 +1,14 @@
package com.hnac.hzims.middle.systemlog.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.middle.systemlog.entity.Statistics;
import com.hnac.hzims.middle.systemlog.mapper.StatisticsMapper;
import com.hnac.hzims.middle.systemlog.service.StatisticsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.middle.systemlog.service.SysLogService;
import com.hnac.hzims.middle.systemlog.vo.StatisticsVo;
import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -84,4 +87,19 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
statisticsQueryWrapper.eq("date_calculated", operationTime);
return baseMapper.selectOne(statisticsQueryWrapper);
}
/**
* 分页查询
*
* @param page1
* @param statistics
* @return
*/
@Override
public IPage<Statistics> selectPage(Page<Statistics> page1, StatisticsVo statistics) {
QueryWrapper<Statistics> queryWrapper = new QueryWrapper<>();
IPage<Statistics> statisticsPage = baseMapper.selectPage(page1, queryWrapper);
return statisticsPage;
}
}

41
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java

@ -1,12 +1,20 @@
package com.hnac.hzims.middle.systemlog.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.middle.systemlog.entity.Statistics;
import com.hnac.hzims.middle.systemlog.entity.SysLog;
import com.hnac.hzims.middle.systemlog.mapper.SysLogMapper;
import com.hnac.hzims.middle.systemlog.service.SysLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo;
import com.hnac.hzims.middle.systemlog.vo.SysLogVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
/**
@ -29,4 +37,37 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
public List<SysLogStatisticsVo> countStatistics() {
return baseMapper.countStatistics();
}
/**
* 分页查询
*
* @param page1
* @param sysLog
* @return
*/
@Override
public IPage<SysLog> selectPage(Page<SysLog> page1, SysLogVo sysLog) {
String keyword = sysLog.getKeyword();
LocalDate createTime = sysLog.getCreateTime();
LocalDate endTime = sysLog.getEndTime();
QueryWrapper<SysLog> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotEmpty(sysLog.getKeyword())) {
queryWrapper.lambda().like(SysLog::getModuleName, keyword);
queryWrapper.lambda().or().like(SysLog::getTitle, keyword);
queryWrapper.lambda().or().like(SysLog::getAction, keyword);
}
if (ObjectUtils.isNotEmpty(createTime)){
queryWrapper.lambda().ge(SysLog::getOperationTime,createTime);
}
if (ObjectUtils.isNotEmpty(endTime)){
queryWrapper.lambda().le(SysLog::getOperationTime,endTime);
}
IPage<SysLog> statisticsPage = baseMapper.selectPage(page1, queryWrapper);
return statisticsPage;
}
}

34
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/StatisticsVo.java

@ -0,0 +1,34 @@
package com.hnac.hzims.middle.systemlog.vo;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/4/21 9:21
*/
@Data
public class StatisticsVo {
/**
* key
*/
public String keyword;
/**
* 开始时间
*/
private LocalDate createTime;
/**
* 结束时间
*/
private LocalDate endTime;
}

33
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogVo.java

@ -0,0 +1,33 @@
package com.hnac.hzims.middle.systemlog.vo;
import lombok.Data;
import java.time.LocalDate;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/4/21 9:53
*/
@Data
public class SysLogVo {
/**
* key
*/
public String keyword;
/**
* 开始时间
*/
private LocalDate createTime;
/**
* 结束时间
*/
private LocalDate endTime;
}

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java

@ -11,5 +11,5 @@ package com.hnac.hzims.ticket.processflow.constant;
public class TicketProcessConstant {
// public final static String STARTEVENT = "startEvent1";
public final static String STARTEVENT = "newFirstWorkTicket";
public final static String STARTEVENT = "newFirstWorkTicket";
}

4
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessTypeController.java

@ -105,8 +105,8 @@ public class ProcessTypeController {
public void addList() {
ProcessWorkFlowResponse workTicketMessageResponse = new ProcessWorkFlowResponse();
workTicketMessageResponse.setTaskId("1");
workTicketMessageResponse.setProcessDefinitionKey("1");
workTicketMessageResponse.setTaskName("1");
workTicketMessageResponse.setProcessDefinitionKey("newFirstWorkTicket");
workTicketMessageResponse.setTaskName("签发人签发");
workTicketMessageResponse.setFormData("1");
String qqqq = JsonUtil.toJson(workTicketMessageResponse);
queueProduceService.sendMessage("blade:queue:flow", qqqq);

114
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

@ -5,18 +5,25 @@ import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService;
import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.apache.bcel.generic.TABLESWITCH;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.entity.FlowAttachment;
import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.flow.core.vo.ComleteTask;
import org.springblade.flow.core.vo.TaskList;
import org.springframework.stereotype.Service;
import javax.crypto.Mac;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 开票处理流程实现类
*
* @Author WL
* @Version v1.0
* @Serial 1.0
@ -28,11 +35,16 @@ import java.util.Map;
public class TicketProcessServiceImpl implements TicketProcessService {
private final IFlowClient flowClient;
private final IFlowClient flowClient;
private final IWorkTicketInfoService workTicketInfoService;
private Map<String,Boolean> map = new HashMap<String,Boolean>(){{
put("key",true);
}};
/**
* 启动开票流程
*
@ -40,6 +52,9 @@ public class TicketProcessServiceImpl implements TicketProcessService {
*/
@Override
public void startUp(ProcessWorkFlowResponse response) {
Boolean key = map.get("key");
//当前环节Id
String processDefinitionKey = response.getProcessDefinitionKey();
//当前任务Id
@ -54,25 +69,86 @@ public class TicketProcessServiceImpl implements TicketProcessService {
// variables.put("signUserIds", formData);
Map<String,Object> params = new HashMap<String, Object>(2) {{
put("taskId", "1644624168666353665");
put("signUserIds", "1377143375838359553");
if (key) {
Map<String, Object> params = new HashMap<String, Object>(2) {{
put("taskId", "4066d774-df2c-11ed-b33e-fa163ee12c20");
put("signUserIds", "1377143375838359553");
}};
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(
processDefinitionKey, "workTicket:task:" + 1377143375838359553L,
"开启工作的任务",
params);
if (processInstanceContainNameByKey.getCode() != 200) {
log.error("启动开票流程失败: {}", processInstanceContainNameByKey);
return;
}
BladeFlow bladeFlow = processInstanceContainNameByKey.getData();
log.info("bladeFlow: {}", bladeFlow);
map.put("key",false);
return;
}
// R<BladeFlow> tasks = flowClient.getTaskByProcessInstanceIdAndUserId(response.getProcessInstanceId(),
// "1377143375838359553");
//
//
// flowClient.getTaskByProcessInstanceIdAndUserId(response.getProcessInstanceId(),
// "1377143375838359553");
//
// if (tasks.getCode() != 200){
// return;
// }
//
// BladeFlow bladeFlow1 = tasks.getData();
//
// String curStep = bladeFlow1.getCurStep();
// System.out.println("curStep = " + curStep);
//
// String status = bladeFlow1.getStatus();
// System.out.println("status = " + status);
//
// // R<List<TaskList>> listR = flowClient.todoList(processDefinitionKey);
// // listR.getData().forEach(taskList -> {
// // System.out.println("任务名称:"+taskList);
// // System.out.println(taskList.getTaskName());
// // System.out.println(taskList.getStatus());
// // });
//
// R<Map<String, Object>> taskedVariables = flowClient.taskVariables(response.getTaskId());
//
// System.out.println(taskedVariables);
// R<List<TaskList>> listR = flowClient.todoList(response.getProcessDefinitionKey());
// for (TaskList datum : listR.getData()) {
// System.out.println(datum);
// }
ComleteTask comleteTask = new ComleteTask();
comleteTask.setPass(true);
comleteTask.setProcessInstanceId(response.getProcessInstanceId());
comleteTask.setTaksUserId(1377143375838359553L);
comleteTask.setTaskId(response.getTaskId());
comleteTask.setComment("同意");
FlowAttachment flowAttachment= new FlowAttachment();
flowAttachment.setProcessInstanceId(response.getProcessInstanceId());
flowAttachment.setTaskId(taskId);
flowAttachment.setAttachmentType("");
List<FlowAttachment> list = new ArrayList<>();
list.add(flowAttachment);
comleteTask.setAttachments(list);
Map<String, Object> params = new HashMap<String, Object>(2) {{
put("taskId",taskId);
put("principalUserIds", "1377143375838359553");
}};
flowClient.startProcessInstanceContainNameByKey(
processDefinitionKey,"workTicket:task:"+1,
"开启工作的任务",
params);
// R<List<TaskList>> listR = flowClient.todoList(processDefinitionKey);
// listR.getData().forEach(taskList -> {
// System.out.println("任务名称:"+taskList);
// System.out.println(taskList.getTaskName());
// System.out.println(taskList.getStatus());
// });
// flowClient.completeTask()
comleteTask.setVariables(params);
flowClient.completeTask(comleteTask);
}

Loading…
Cancel
Save