diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/enumutil/WorkingStatusEnum.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/enumutil/WorkingStatusEnum.java new file mode 100644 index 0000000..0a2184c --- /dev/null +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/enumutil/WorkingStatusEnum.java @@ -0,0 +1,34 @@ +package org.springblade.plugin.homepage.enumutil; + +/** + * @Description 工作流运行状态, + *   { + *     name: "进行中", + *     itemStyle: {color: "#4CA3FB"} + *   }, + *    { + *     name: "审批中", + *     itemStyle: {color: "#FF9130"} + *   }, + *    { + *     name: "已完成", + *     itemStyle: {color: "#2EE27C"} + *   } + * @Author ytl + * @Date 2023/2/24 0024 17:18 + */ +public enum WorkingStatusEnum { + 进行中("#4CA3FB"), + 审批中("#FF9130"), + 已完成("#2EE27C"); + + private String colorCode; + + WorkingStatusEnum(String colorCode){ + this.colorCode = colorCode; + } + + public String getColorCode(){ + return colorCode; + } +} diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/service/impl/HomePageServiceImpl.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/service/impl/HomePageServiceImpl.java index 676f059..e09274a 100644 --- a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/service/impl/HomePageServiceImpl.java +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/service/impl/HomePageServiceImpl.java @@ -2,6 +2,7 @@ package org.springblade.plugin.homepage.service.impl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.alibaba.nacos.shaded.com.google.gson.JsonObject; import liquibase.pro.packaged.E; import lombok.AllArgsConstructor; import org.apache.commons.lang.StringUtils; @@ -20,6 +21,7 @@ import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springblade.plugin.homepage.enumutil.TaskTypeColorEnum; +import org.springblade.plugin.homepage.enumutil.WorkingStatusEnum; import org.springblade.plugin.homepage.service.IHomePageService; import org.springblade.plugin.workflow.core.utils.WfTaskUtil; import org.springblade.system.cache.DictBizCache; @@ -303,9 +305,9 @@ public class HomePageServiceImpl implements IHomePageService { List historicProcessInstanceStartList = historyService.createHistoricProcessInstanceQuery().processInstanceTenantId(WfTaskUtil.getTenantId()) .startedAfter(DateUtil.plusYears(DateUtil.now(), -1)) .startedBefore(DateUtil.now()).orderByProcessInstanceStartTime().asc().list(); - +System.out.println("上一年1-" +DateUtil.plusYears(DateUtil.now(), -1)); //过滤出发起人所在部门与当前用户所在部门一致的工单 - historicProcessInstanceStartList.stream().filter(process -> { + List collect1 = historicProcessInstanceStartList.stream().filter(process -> { String startUserId = process.getStartUserId(); User user = UserCache.getUser(Long.parseLong(startUserId)); String userDept = user.getDeptId(); @@ -316,7 +318,9 @@ public class HomePageServiceImpl implements IHomePageService { } } return false; - }).forEach(his ->{ + }).collect(Collectors.toList()); + + collect1.forEach(his ->{ Date startTime = his.getStartTime(); String format = DateUtil.format(startTime, "yyyy-MM"); @@ -332,7 +336,7 @@ public class HomePageServiceImpl implements IHomePageService { .finishedBefore(DateUtil.now()).orderByProcessInstanceStartTime().asc().list(); //过滤出发起人所在部门与当前用户所在部门一致的工单 - historicProcessInstanceEndList.stream().filter(process -> { + List collect2 = historicProcessInstanceEndList.stream().filter(process -> { String startUserId = process.getStartUserId(); User user = UserCache.getUser(Long.parseLong(startUserId)); String userDept = user.getDeptId(); @@ -343,7 +347,8 @@ public class HomePageServiceImpl implements IHomePageService { } } return false; - }).forEach(his ->{ + }).collect(Collectors.toList()); + collect2.forEach(his ->{ Date startTime = his.getStartTime(); String format = DateUtil.format(startTime, "yyyy-MM"); if (mapMonthFinish.containsKey(format)) { @@ -490,6 +495,9 @@ public class HomePageServiceImpl implements IHomePageService { JSONObject jsonObject = new JSONObject(); jsonObject.put("name",next.getKey()); jsonObject.put("value",next.getValue()); + JSONObject itemStyle = new JSONObject(); + itemStyle.put("color", WorkingStatusEnum.valueOf(next.getKey()).getColorCode()); + jsonObject.put("itemStyle",itemStyle); result.add(jsonObject); } return R.data(result); diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/controller/AutoStartModelController.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/controller/AutoStartModelController.java index 6beec9a..3654c1a 100644 --- a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/controller/AutoStartModelController.java +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/controller/AutoStartModelController.java @@ -1,5 +1,7 @@ package org.springblade.plugin.workbench.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; @@ -17,12 +19,12 @@ import org.springblade.core.tool.utils.Func; import org.springblade.plugin.workbench.entity.AutoStartModel; import org.springblade.plugin.workbench.service.IAutoStartModelService; import org.springblade.plugin.workbench.vo.AutoStartModelVO; +import org.springblade.system.entity.Post; import org.springframework.web.bind.annotation.*; import java.util.List; import static org.springblade.core.cache.constant.CacheConstant.FLOW_CACHE; -import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; /** * @Description 自动启动的工作流的原型信息 @@ -45,7 +47,14 @@ public class AutoStartModelController extends BladeController { @ApiOperationSupport(order = 1) @ApiOperation(value = "分页", notes = "传入autoStartModel") public R> list(AutoStartModel model, Query query) { - IPage page = autoStartModelService.page(Condition.getPage(query), Condition.getQueryWrapper(model)); + QueryWrapper queryWrapper = Condition.getQueryWrapper(model); + LambdaQueryWrapper lambda = queryWrapper.lambda(); + lambda.orderByDesc(AutoStartModel::getCreateTime); + if(Func.isNotEmpty(model.getStartTime()) && Func.isNotEmpty(model.getEndTime())){ + lambda.between(AutoStartModel::getCreateTime,model.getStartTime(),model.getEndTime()); + } + + IPage page = autoStartModelService.page(Condition.getPage(query), queryWrapper); List records = page.getRecords(); List autoStartModelVOS = autoStartModelService.setInfo(records); IPage newPage = new IPage() { diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/entity/AutoStartModel.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/entity/AutoStartModel.java index 8a9ca05..c87a061 100644 --- a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/entity/AutoStartModel.java +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/entity/AutoStartModel.java @@ -1,5 +1,6 @@ package org.springblade.plugin.workbench.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.EqualsAndHashCode; @@ -62,4 +63,16 @@ public class AutoStartModel extends TenantEntity { //结束时间 private Date breakTime; + + /** + * 开始时间 + */ + @TableField(exist = false) + private Date startTime; + + /** + * 结束时间 + */ + @TableField(exist = false) + private Date endTime; } diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/service/impl/AutoStartModelServiceImpl.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/service/impl/AutoStartModelServiceImpl.java index 8079032..bbbe282 100644 --- a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/service/impl/AutoStartModelServiceImpl.java +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/service/impl/AutoStartModelServiceImpl.java @@ -9,6 +9,7 @@ import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.task.api.history.HistoricTaskInstanceQuery; import org.flowable.variable.api.history.HistoricVariableInstance; +import org.springblade.core.cache.utils.CacheUtil; import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseServiceImpl; @@ -28,11 +29,14 @@ import org.springblade.plugin.operation.system.service.IModuleInfoService; import org.springblade.plugin.operation.system.service.IProjectInfoService; import org.springblade.plugin.operation.task.entity.TaskInfo; import org.springblade.plugin.operation.task.service.ITaskInfoService; +import org.springblade.plugin.workbench.cache.FlowCache; import org.springblade.plugin.workbench.entity.AutoStartModel; import org.springblade.plugin.workbench.mapper.BladeManMadeMapper; import org.springblade.plugin.workbench.service.IAutoStartModelService; import org.springblade.plugin.workbench.vo.AutoStartModelVO; import org.springblade.system.cache.DictBizCache; +import org.springblade.system.cache.SysCache; +import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.cache.UserCache; import org.springframework.stereotype.Service; @@ -71,7 +75,8 @@ public class AutoStartModelServiceImpl extends BaseServiceImpl> bladeManMadeVariabList() { LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); - queryWrapper.eq(AutoStartModel::getIsBreak, 0); + // status = 10 isBreak = 0才是可以自动任务,status = 1,isBreak = 0刚建立,status=1 ,isBreak = 1删除,不自动执行了 + queryWrapper.ne(AutoStartModel::getIsBreak, 1); List autoStartModels = baseMapper.selectList(queryWrapper); List> maps = new ArrayList<>(); if(autoStartModels.size() > 0){ @@ -106,6 +111,8 @@ public class AutoStartModelServiceImpl extends BaseServiceImpl strings = Func.toStrList(ids); - List modelList = new ArrayList<>(); + for(String s : strings){ AutoStartModel autoStartModel = baseMapper.selectById(Long.valueOf(s)); if(Func.isNotEmpty(autoStartModel)){ autoStartModel.setIsBreak(1); + autoStartModel.setStatus(1); autoStartModel.setBreakTime(DateUtil.now()); baseMapper.updateById(autoStartModel); } } - + FlowCache.clearBladeManMadeCache(); return true; } diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/vo/AutoStartModelVO.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/vo/AutoStartModelVO.java index 85b20c3..13382e2 100644 --- a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/vo/AutoStartModelVO.java +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workbench/vo/AutoStartModelVO.java @@ -36,4 +36,5 @@ public class AutoStartModelVO implements Serializable { private Date breakTime; + } diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workflow/process/service/impl/WfProcessService.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workflow/process/service/impl/WfProcessService.java index 43ae339..635293d 100644 --- a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workflow/process/service/impl/WfProcessService.java +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workflow/process/service/impl/WfProcessService.java @@ -200,7 +200,7 @@ public class WfProcessService implements IWfProcessService { ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefId, definition.getKey(), variables); - //将新增的流程实例id保存到blade_flow_man_made + //将新增的流程实例id保存到blade_flow_autostart_model AutoStartModel autoStartModel = new AutoStartModel(); autoStartModel.setProcessInstanceId(processInstance.getId()); Date startTime = processInstance.getStartTime(); @@ -229,23 +229,25 @@ public class WfProcessService implements IWfProcessService { //判断该类型的流程是否已经发起过,false:有重复的,true:没重复 private boolean isNewProcess(Map variables){ - variables.remove("forcestart"); - variables.remove("isauto"); boolean b = false; - if(autoStartModelService.list().size() ==0){ + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); + queryWrapper.eq(AutoStartModel::getIsBreak,0); + if(autoStartModelService.list(queryWrapper).size() ==0){ b = false; return b; } - List> processInstanceVariable = FlowCache.getProcessInstanceVariable(); + if(FlowCache.getProcessInstanceVariable() != null && Func.isNotEmpty(FlowCache.getProcessInstanceVariable())){ + List> processInstanceVariable = FlowCache.getProcessInstanceVariable(); - if (processInstanceVariable.size() > 0) { - for(Map hi : processInstanceVariable){ - boolean noEqual = this.isNoEqual(variables, hi); - if(noEqual){//有不相等的,直接下一次循环判断 - continue; - }else{//没有不相等的,说明有重复的,结束循环,返回b=true - b = true; - break; + if (processInstanceVariable.size() > 0) { + for(Map hi : processInstanceVariable){ + boolean noEqual = this.isNoEqual(variables, hi); + if(noEqual){//有不相等的,直接下一次循环判断 + continue; + }else{//没有不相等的,说明有重复的,结束循环,返回b=true + b = true; + break; + } } } } @@ -258,9 +260,10 @@ public class WfProcessService implements IWfProcessService { Iterator> iterator = entries.iterator(); while(iterator.hasNext()){ Map.Entry next = iterator.next(); - if(StringUtils.equals(next.getKey(),"qiwangwanchengshijian")){ + if(StringUtils.equals(next.getKey(),"qiwangwanchengshijian") || StringUtils.equals(next.getKey(),"forcestart") || StringUtils.equals(next.getKey(),"isauto")){ continue; } + if(!Func.equals(next.getValue(),map2.get(next.getKey()))){ return true; }