去掉额外的fk包

This commit is contained in:
xuetao.li
2023-04-19 16:19:18 +08:00
parent 2767e7e737
commit dbe999143a
32 changed files with 427 additions and 673 deletions
+12
View File
@@ -146,6 +146,18 @@
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>com.adc</groupId>
<artifactId>report-activity</artifactId>
<version>2.5.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.adc</groupId>-->
<!-- <artifactId>adc-da-price</artifactId>-->
@@ -1,12 +1,13 @@
package com.adc.da;
import org.activiti.spring.boot.SecurityAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
@ServletComponentScan
@ComponentScan("com.adc")
public class AdcDaApplication {
@@ -87,9 +87,9 @@ public class WebConfig {
return registration;
}
/**
/* *//**
* 防伪造jsessionid
*/
*//*
@Bean
public FilterRegistrationBean fakeJSessionIdFilter() {
FilterRegistrationBean registration = new FilterRegistrationBean();
@@ -98,6 +98,6 @@ public class WebConfig {
registration.setName("fakeJSessionIdFilter");
registration.setOrder(5);
return registration;
}
}*/
}
@@ -35,7 +35,7 @@
#spring.datasource.mysql.password = root
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://121.36.69.172:3307/report-library?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
spring.datasource.url = jdbc:mysql://121.36.69.172:3307/report-library?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
spring.datasource.username = root
spring.datasource.password = hzwlsoft.com
@@ -71,4 +71,8 @@ queue.capacity=8
mybatis-plus.configuration.map-underscore-to-camel-case=true
spring.activiti.database-schema-update=true
# ????????:true-???????false-??
spring.activiti.check-process-definitions=false
@@ -3,6 +3,8 @@ package com.adc.da.sys.vo;
import java.util.ArrayList;
import java.util.List;
import com.adc.da.sys.entity.OrgEO;
import com.adc.da.sys.entity.RoleEO;
import com.adc.da.sys.vo.iam.OrgsShortVoIAM;
import lombok.Data;
@@ -43,12 +45,11 @@ public class UserVO {
/**
* 角色ID列表
*/
private List<String> roleIdList = new ArrayList<>();
private List<RoleEO> roleEOList = new ArrayList<>();
/**
* 部门列表
*/
private List<OrgsShortVoIAM> orgList = new ArrayList();
private List<OrgEO> orgList = new ArrayList();
}
@@ -58,6 +58,27 @@
</collection>
</resultMap>
<!-- 包含用户基本数据,角色数据,组织机构数据等-->
<resultMap id="UserDetailMap" extends="BaseResultMap" type="com.adc.da.sys.entity.UserEO">
<result column="usid" property="usid"></result>
<result column="usname" property="usname"></result>
<result column="account" property="account"></result>
<collection property="roleEOList" ofType="com.adc.da.sys.entity.RoleEO" javaType="list">
<id column="r_id" property="id"/>
<result column="r_data_scope" property="dataScope"/>
<result column="r_delFlag" property="delFlag"/>
<result column="r_is_default" property="isDefault"/>
<result column="r_name" property="name"/>
</collection>
<collection property="orgEOList" ofType="com.adc.da.sys.entity.OrgEO" javaType="list">
<id column="o_id" property="id"/>
<result column="o_org_code" property="orgCode"/>
<result column="o_org_name" property="orgName"/>
<result column="o_sup_org_code" property="supOrgCode"/>
<result column="o_bmdm14" property="bmdm14"/>
</collection>
</resultMap>
<!---->
<sql id="User_Role_List">
u.*, r.id as id,
@@ -115,9 +136,26 @@
</select>
<select id="getUserByIdList" resultMap="com.adc.da.sys.vo.UserVO" parameterType="java.lang.String">
select users.usid, users.usname, users.account
<select id="getUserByIdList" resultMap="UserDetailMap" parameterType="java.lang.String">
select
users.usid,
users.usname,
users.account
r.id as r_id,
r.data_scope as r_data_scope,
r.del_flag as r_delFlag,
r.is_default as r_is_default,
r.name as r_name,
o.id as o_id,
o.org_code as o_org_code,
o.org_name as o_org_name,
o.sup_org_code as o_sup_org_code,
o.bmdm14 as o_bmdm14
from TS_USER users
left join TR_USER_ROLE ur on users.usid = ur.user_id
left join TS_ROLE r on ur.role_id = r.id
left join TS_USER_ORG uo on users.usid = uo.user_id
left join TS_ORG o on uo.org_id = o.id
where del_flag != 1
and users.usid in
<foreach collection="userIdList" item="id" open="(" separator="," close=")">
+5 -5
View File
@@ -235,11 +235,11 @@
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.slf4j</groupId>-->
<!-- <artifactId>slf4j-log4j12</artifactId>-->
<!-- <version>${slf4j.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.dom4j</groupId>
+5 -5
View File
@@ -35,11 +35,11 @@
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>com.tmsps.fk.common</groupId>
<artifactId>fk-util</artifactId>
<version>1.0.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.tmsps.fk.common</groupId>-->
<!-- <artifactId>fk-util</artifactId>-->
<!-- <version>1.0.0</version>-->
<!-- </dependency>-->
<!-- Activiti -->
<dependency>
<groupId>org.activiti</groupId>
@@ -1,15 +1,13 @@
package com.adc.da.wkflow.business_activiti.define;
import cn.hutool.core.util.StrUtil;
import com.adc.da.sys.entity.UserEO;
import com.adc.da.sys.service.iservice.IUserEoService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tmsps.fk.common.base.action.BaseAction;
import com.tmsps.fk.common.util.ChkUtil;
import com.tmsps.fk.common.wrapper.WrapMapper;
import com.tmsps.fk.common.wrapper.Wrapper;
import com.adc.da.wkflow.util.wrapper.WrapMapper;
import com.adc.da.wkflow.util.wrapper.Wrapper;
import com.adc.da.wkflow.business_main.entity.*;
import com.adc.da.wkflow.business_main.service.IBusProcessNameService;
import com.adc.da.wkflow.enums.SubmitStatusEnum;
@@ -19,6 +17,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.IdentityService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
@@ -32,6 +31,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
@@ -39,20 +39,21 @@ import java.util.regex.Pattern;
@Api(description = "流程定义管理")
@RestController
public class ActivitDefineController extends BaseAction {
@Slf4j
public class ActivitDefineController {
@Autowired
@Resource
private RuntimeService runtimeService;
@Autowired
@Resource
private RepositoryService repositoryService;
@Autowired
@Resource
private TaskService taskService;
@Autowired
@Resource
private IdentityService identityService;
@Autowired
@Resource
private IBusProcessNameService ibusprocessnameService;
@Autowired
@Resource
IUserEoService userEoService;
@ApiOperation(value = "流程定义列表-分页")
@@ -64,10 +65,10 @@ public class ActivitDefineController extends BaseAction {
// 创建查询对象
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
// 使用流程定义的名称模糊查询
if (ChkUtil.isNotNull(name)) {
if (StrUtil.isNotEmpty(name)) {
processDefinitionQuery.processDefinitionNameLike("%" + name + "%");
}
if (ChkUtil.isNotNull(category_id)) {
if (StrUtil.isNotEmpty(category_id)) {
processDefinitionQuery.processDefinitionCategory(category_id);
}
long total = processDefinitionQuery.count();
@@ -75,7 +76,7 @@ public class ActivitDefineController extends BaseAction {
List<Map<String, Object>> definitions = ActivitiTools.turnProcessDefinitions(list);
for (Map<String, Object> map : definitions) {
Model model = repositoryService.createModelQuery().deploymentId(map.get("deploymentId")+"").singleResult();
if(ChkUtil.isNotNull(model)) {
if(model != null) {
map.put("modelId", model.getId());
}else {
map.put("modelId", "");
@@ -100,7 +101,7 @@ public class ActivitDefineController extends BaseAction {
if (name == null) {
name = "";
}
if (ChkUtil.isNotNull(category_id)) {
if (StrUtil.isNotEmpty(category_id)) {
processDefinitionQuery.processDefinitionCategory(category_id);
}
processDefinitionQuery.orderByDeploymentId().desc();
@@ -198,7 +199,7 @@ public class ActivitDefineController extends BaseAction {
ibusprocessnameService.save(one);
}
logger.info("启动流程实例,获取id-->{},实例名称-->{}", pi.getId(), pd.getName());
log.info("启动流程实例,获取id-->{},实例名称-->{}", pi.getId(), pd.getName());
return WrapMapper.ok(task.getId());
}
@@ -213,7 +214,7 @@ public class ActivitDefineController extends BaseAction {
.deploymentId(modelData.getDeploymentId()).singleResult();
}
if (ChkUtil.isNotNull(pd) && pd.getKey().equals(key)) {
if (pd != null && pd.getKey().equals(key)) {
return WrapMapper.ok("TRUE");
}
@@ -1,22 +1,21 @@
package com.adc.da.wkflow.business_activiti.dto;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tmsps.fk.common.base.dto.BaseVueQuery;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "ModelQuery 对象", description = "")
public class ModelQuery<T> extends BaseVueQuery<T> {
private static final long serialVersionUID = 1L;
public Wrapper<T> makeQueryWrapper() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
return queryWrapper;
}
}
//package com.adc.da.wkflow.business_activiti.dto;
//
//import com.baomidou.mybatisplus.core.conditions.Wrapper;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import io.swagger.annotations.ApiModel;
//import lombok.Data;
//import lombok.EqualsAndHashCode;
//
//@Data
//@EqualsAndHashCode(callSuper = false)
//@ApiModel(value = "ModelQuery 对象", description = "")
//public class ModelQuery<T> extends BaseVueQuery<T> {
//
// private static final long serialVersionUID = 1L;
//
// public Wrapper<T> makeQueryWrapper() {
// QueryWrapper<T> queryWrapper = new QueryWrapper<>();
// return queryWrapper;
// }
//
//}
@@ -14,10 +14,11 @@ package com.adc.da.wkflow.business_activiti.editor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.tmsps.fk.common.base.action.BaseAction;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.activiti.editor.constants.ModelDataJsonConstants;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.RepositoryService;
@@ -29,18 +30,21 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @author Tijs Rademakers
*/
@Api(description = "工作流编辑器")
@RestController
@RequestMapping(value = "/service")
public class ModelEditorJsonRestResource extends BaseAction implements ModelDataJsonConstants {
@Slf4j
public class ModelEditorJsonRestResource implements ModelDataJsonConstants {
@Autowired
@Resource
private RepositoryService repositoryService;
@Autowired
@Resource
private ObjectMapper objectMapper;
@ApiOperation(value = "获取模型json数据")
@@ -66,7 +70,7 @@ public class ModelEditorJsonRestResource extends BaseAction implements ModelData
modelNode.put("model", editorJsonNode);
} catch (Exception e) {
logger.error("Error creating model JSON", e);
log.error("Error creating model JSON", e);
throw new ActivitiException("Error creating model JSON", e);
}
}
@@ -1,7 +1,7 @@
package com.adc.da.wkflow.business_activiti.instance;
import com.tmsps.fk.common.wrapper.WrapMapper;
import com.tmsps.fk.common.wrapper.Wrapper;
import com.adc.da.wkflow.util.wrapper.WrapMapper;
import com.adc.da.wkflow.util.wrapper.Wrapper;
import com.adc.da.wkflow.util.activiti.ActivitiTools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -23,20 +23,6 @@ public class InstanceImageController {
@Autowired
private IBusProcessNameService iBusProcessNameService;
// @ApiOperation(value = "获取图片")
// @ApiImplicitParam(name = "processInstanceId", value = "流程实例id")
// @GetMapping("/getImg")
// public void getImg(String processInstanceId, HttpServletResponse response) throws Exception {
// response.setContentType("image/jpg"); // 设置返回的文件类型
//
// byte[] bytes = instanceService.getProcessImage(processInstanceId);
//
// OutputStream os = response.getOutputStream();
// os.write(bytes);
// os.flush();
// os.close();
// }
@ApiOperation(value = "获取图片")
@ApiImplicitParam(name = "processInstanceId", value = "流程实例id")
@GetMapping("/getImg")
@@ -1,19 +1,20 @@
package com.adc.da.wkflow.business_activiti.model;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.tmsps.fk.common.base.action.BaseAction;
import com.tmsps.fk.common.util.ChkUtil;
import com.tmsps.fk.common.wrapper.WrapMapper;
import com.tmsps.fk.common.wrapper.Wrapper;
import com.adc.da.wkflow.util.wrapper.WrapMapper;
import com.adc.da.wkflow.util.wrapper.Wrapper;
import com.adc.da.wkflow.util.CommonConstant;
import com.adc.da.wkflow.util.CreatedTools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.activiti.bpmn.converter.BpmnXMLConverter;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.editor.constants.ModelDataJsonConstants;
@@ -30,6 +31,7 @@ import org.springframework.cglib.beans.BeanMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -41,11 +43,12 @@ import static org.activiti.editor.constants.ModelDataJsonConstants.*;
@Api(description = "工作流模板管理")
@RestController
public class ActivitiModelController extends BaseAction {
@Slf4j
public class ActivitiModelController {
@Autowired
@Resource
private RepositoryService repositoryService;
@Autowired
@Resource
private ObjectMapper objectMapper;
@ApiOperation(value = "新建模板")
@@ -83,7 +86,7 @@ public class ActivitiModelController extends BaseAction {
repositoryService.addModelEditorSource(model.getId(), editorNode.toString().getBytes("utf-8"));
return model;
} catch (UnsupportedEncodingException e) {
logger.error("UnsupportedEncodingException", e);
log.error("UnsupportedEncodingException", e);
}
return null;
}
@@ -111,7 +114,7 @@ public class ActivitiModelController extends BaseAction {
modelNode.set("model", editorJsonNode);
return modelNode;
} catch (Exception e) {
logger.error("Error creating model JSON", e);
log.error("Error creating model JSON", e);
throw new ActivitiException("Error creating model JSON", e);
}
}
@@ -147,7 +150,7 @@ public class ActivitiModelController extends BaseAction {
outStream.close();
} catch (Exception e) {
flag = false;
logger.error("Error saving model", e);
log.error("Error saving model", e);
throw new ActivitiException("Error saving model", e);
}
return flag;
@@ -160,7 +163,7 @@ public class ActivitiModelController extends BaseAction {
public Wrapper<List<Model>> modelList(String name, String category_id) {
String sql = "select distinct RES.* from ACT_RE_MODEL RES WHERE RES.TENANT_ID_ = '子系统1' and RES.NAME_<>'' and RES.CATEGORY_=#{category} order by RES.CREATE_TIME_ desc";
NativeModelQuery nativeModelQuery = repositoryService.createNativeModelQuery();
if (ChkUtil.isNull(category_id)) {
if (StrUtil.isEmpty(category_id)) {
sql = sql.replace("and RES.CATEGORY_=#{category}", "");
}else {
nativeModelQuery.parameter("category", category_id);
@@ -1,8 +1,8 @@
package com.adc.da.wkflow.business_activiti.model;
import com.tmsps.fk.common.util.ChkUtil;
import com.tmsps.fk.common.wrapper.WrapMapper;
import com.tmsps.fk.common.wrapper.Wrapper;
import cn.hutool.core.util.StrUtil;
import com.adc.da.wkflow.util.wrapper.WrapMapper;
import com.adc.da.wkflow.util.wrapper.Wrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@@ -47,7 +47,7 @@ public class ActivitiModelImageController {
byte[] bytes = repositoryService.getModelEditorSourceExtra(modelId);
OutputStream os = response.getOutputStream();
if(ChkUtil.isNotNull(bytes)) {
if(bytes != null) {
os.write(bytes);
os.flush();
os.close();
@@ -1,6 +1,6 @@
package com.adc.da.wkflow.business_activiti.service;
import com.tmsps.fk.common.util.ChkUtil;
import cn.hutool.core.util.StrUtil;
import com.adc.da.wkflow.business_activiti.dto.TaskCommonQuery;
import com.adc.da.wkflow.util.date.DateTools;
import org.activiti.engine.TaskService;
@@ -43,17 +43,17 @@ public class TaskTodoService {
sb.append(" left join t_delegate de on db.DELEGATE_ID=de.OBJECT_ID and de.USERD=#{userd} ");
sb.append(" WHERE ");
//任务名称
if (ChkUtil.isNotNull(taskCommonQuery.getName())) {
if (StrUtil.isNotEmpty(taskCommonQuery.getName())) {
sb.append(" RES.NAME_ LIKE #{taskName} and ");
nativeTaskQuery = nativeTaskQuery.parameter("taskName", taskCommonQuery.getName());
}
//日期查询
if (ChkUtil.isNotNull(taskCommonQuery.getStartTime())) {
if (StrUtil.isNotEmpty(taskCommonQuery.getStartTime())) {
sb.append(" RES.CREATE_TIME_ >= #{starttime} and ");
nativeTaskQuery = nativeTaskQuery.parameter("starttime", start);
}
if (ChkUtil.isNotNull(taskCommonQuery.getEndTime())) {
if (StrUtil.isNotEmpty(taskCommonQuery.getEndTime())) {
sb.append(" RES.CREATE_TIME_ <= #{endtime} and ");
nativeTaskQuery = nativeTaskQuery.parameter("endtime", end);
}
@@ -7,7 +7,6 @@ import com.adc.da.wkflow.business_main.service.IBusProcessApproveService;
import com.adc.da.wkflow.business_main.service.IBusProcessNewService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tmsps.fk.common.util.ChkUtil;
import com.adc.da.wkflow.business_main.entity.*;
import com.adc.da.wkflow.business_main.service.IBusProcessNameService;
import com.adc.da.wkflow.util.activiti.ActivitiTools;
@@ -77,7 +76,7 @@ public class TaskController {
List<Map<String,Object>> list = ActivitiTools.turnHistoricTaskInstance(list2);
for (Map<String, Object> historicTaskInstance : list) {
// 获取办理的历史信息
if(ChkUtil.isNull(historicTaskInstance.get("assignee"))) {
if(historicTaskInstance.get("assignee") == null) {
String taskId = historicTaskInstance.get("id").toString();
QueryWrapper processNewQueryWrapper = new QueryWrapper<BusProcessNew>();
processNewQueryWrapper.eq("TASK_ID",taskId);
@@ -0,0 +1,32 @@
package com.adc.da.wkflow.business_activiti.task;
import com.adc.da.sys.vo.UserVO;
import com.adc.da.wkflow.util.wrapper.WrapMapper;
import com.adc.da.wkflow.util.wrapper.Wrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
@Api(description = "临时测试接口")
@RestController
@RequestMapping("/api/temp")
public class TempTestController {
@Resource
TodoTaskController todoTaskController;
@ApiOperation(value = "传多个id,获取对应用户数据")
@GetMapping("/getUserInfoByIdList")
public Wrapper<List<UserVO>> run(String[] userIdArr) {
List<String> userIdList = Arrays.asList(userIdArr);
List<UserVO> userVOS = this.todoTaskController.getUserInfoByIdList(userIdList);
return WrapMapper.ok(userVOS);
}
}
@@ -1,5 +1,6 @@
package com.adc.da.wkflow.business_activiti.task;
import cn.hutool.core.util.StrUtil;
import com.adc.da.sys.service.iservice.IUserEoService;
import com.adc.da.sys.vo.UserVO;
import com.adc.da.util.exception.AdcDaBaseException;
@@ -9,11 +10,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tmsps.fk.common.base.action.BaseAction;
import com.tmsps.fk.common.util.ChkUtil;
import com.tmsps.fk.common.util.JsonUtil;
import com.tmsps.fk.common.wrapper.WrapMapper;
import com.tmsps.fk.common.wrapper.Wrapper;
import com.adc.da.wkflow.util.wrapper.WrapMapper;
import com.adc.da.wkflow.util.wrapper.Wrapper;
import com.adc.da.wkflow.business_activiti.dto.*;
import com.adc.da.wkflow.business_activiti.service.TaskTodoService;
import com.adc.da.wkflow.business_main.entity.*;
@@ -25,6 +24,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.*;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricIdentityLink;
@@ -43,6 +43,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -52,34 +53,35 @@ import static com.adc.da.wkflow.util.date.DateTools.*;
@Api(description = "待办任务管理")
@RestController
public class TodoTaskController extends BaseAction {
@Slf4j
public class TodoTaskController {
@Autowired
@Resource
private TaskService taskService;
@Autowired
@Resource
private RuntimeService runtimeService;
@Autowired
@Resource
private RepositoryService repositoryService;
@Autowired
@Resource
private TaskTodoService taskTodoService;
@Autowired
@Resource
private IBusProcessNewService iBusProcessNewService;
@Autowired
@Resource
private IBusProcessNameService iBusProcessNameService;
@Autowired
@Resource
private HistoryService historyService;
@Autowired
@Resource
private IBusProcessEntrustService iBusProcessEntrustService;
@Autowired
@Resource
private IBusProcessApproveService iBusProcessApproveService;
@Autowired
@Resource
private IUserEoService userEoService;
@@ -163,7 +165,7 @@ public class TodoTaskController extends BaseAction {
public Wrapper<String> run(String taskId, String assignee) {
this.taskService.setAssignee(taskId, assignee);
logger.info("task {} find " + taskId);
log.info("task {} find " + taskId);
return WrapMapper.ok("改派成功");
}
@@ -205,7 +207,7 @@ public class TodoTaskController extends BaseAction {
}
}
logger.info("task {} find " + taskId);
log.info("task {} find " + taskId);
return WrapMapper.ok("改派成功");
}
@@ -214,11 +216,11 @@ public class TodoTaskController extends BaseAction {
@ApiImplicitParam(name = "userId", value = "完成任务用户Id")})
@PostMapping("/completeTask")
public Wrapper<String> completeTaskByUserId(@RequestBody ApproveDataVO busMes) {
logger.info("!!!!!!!!!!!!!TaskId!!!!!!!!!!!!!!!"+busMes.getTaskId());
log.info("!!!!!!!!!!!!!TaskId!!!!!!!!!!!!!!!"+busMes.getTaskId());
if (busMes.getTaskId() != null && !busMes.getTaskId().equals("")) {
Task task = taskService.createTaskQuery().taskId(busMes.getTaskId()).singleResult();
if(task!=null){
if (ChkUtil.isNull(task.getAssignee())) {
if (StrUtil.isEmpty(task.getAssignee())) {
taskService.claim(busMes.getTaskId(), busMes.getUserId());
}
@@ -274,13 +276,13 @@ public class TodoTaskController extends BaseAction {
@GetMapping("/run")
public Wrapper<String> runByUserId(String processInstanceId, String userId) {
Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
if (ChkUtil.isNull(task.getAssignee())) {
if (StrUtil.isEmpty(task.getAssignee())) {
taskService.claim(task.getId(), userId);
}
// 设置扩展json属性
task.getDescription();
logger.info("task {} find " + task.getId());
log.info("task {} find " + task.getId());
taskService.complete(task.getId());
return WrapMapper.ok("提交成功");
}
@@ -294,7 +296,7 @@ public class TodoTaskController extends BaseAction {
// 创建查询对象
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
String pid = task.getProcessInstanceId();
if (ChkUtil.isNull(task.getAssignee())) {
if (StrUtil.isEmpty(task.getAssignee())) {
taskService.claim(taskId, userId);
}
taskService.complete(taskId);
@@ -645,7 +647,7 @@ public class TodoTaskController extends BaseAction {
}
} catch (ParseException e) {
e.printStackTrace();
logger.error("已发流程列表查询,转换创建时间、结束时间异常:" + e.getMessage());
log.error("已发流程列表查询,转换创建时间、结束时间异常:" + e.getMessage());
}
if(endTime!=null){
long approvalTime = DateTools.timeDifference(createTime, endTime);
@@ -819,7 +821,7 @@ public class TodoTaskController extends BaseAction {
}
} catch (ParseException e) {
e.printStackTrace();
logger.error("已办流程列表查询,转换创建时间、结束时间异常:" + e.getMessage());
log.error("已办流程列表查询,转换创建时间、结束时间异常:" + e.getMessage());
}
long approvalTime = disposeApprovalTime(createTime,endTime);
busProcessName.setApprovalTime(approvalTime + "");
@@ -969,7 +971,7 @@ public class TodoTaskController extends BaseAction {
}
} catch (ParseException e) {
e.printStackTrace();
logger.error("监控流程列表查询,转换创建时间、结束时间异常:" + e.getMessage());
log.error("监控流程列表查询,转换创建时间、结束时间异常:" + e.getMessage());
}
long approvalTime = disposeApprovalTime(createTime,endTime);
busProcessName.setApprovalTime(approvalTime + "");
@@ -1,20 +0,0 @@
package com.adc.da.wkflow.util;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class StringUtils {
/**
* 使用逗号拼接的字符串数据去重。
* @return
*/
public static String StringDisposeDistinct(String value){
String[] valueArr = value.split(",");
List<String> valueArrList = Arrays.stream(valueArr).distinct().collect(Collectors.toList());
String values = valueArrList.stream().collect(Collectors.joining(","));
return values;
}
}
@@ -1,112 +0,0 @@
package com.adc.da.wkflow.util;
import com.tmsps.fk.common.util.ChkUtil;
import java.text.SimpleDateFormat;
import java.util.*;
public class TjTools {
// 获取统计数据
public static Map<String, Integer> groupBy(List<Map<String, Object>> list, String key) {
Map<String, Integer> result = new HashMap<>();
if (ChkUtil.isNull(list)) {
return result;
}
for (Map<String, Object> map : list) {
String val = (String) map.get(key);
if (val == null) {
continue;
}
Integer cnt = result.get(val);
if (cnt == null) {
cnt = 1;
} else {
cnt++;
}
result.put(val, cnt);
}
return result;
}
// 分组保存每年12个月的数据
public static List<Map<String, Object>> groupByAddTimes(List<Map<String, Object>> list,
List<Map<String, Object>> type) {
if (list.size() == 0 || type.size() == 0) {
return null;
}
List<Map<String, Object>> list2 = new ArrayList<Map<String, Object>>();
// 遍历type中的数据
type.forEach(t -> {
// 创建map用来保存数据
Map<String, Object> map = new HashMap<String, Object>();
// 创建int[] 用来保存12个月的数据
int[] data = new int[12];
// 遍历list中的数据
if (t.get("type") != null) {
list.forEach(l -> {
long num = (long) l.get("num");
String times = (String) l.get("times");
if (l.get("type") != null && l.get("type").equals(t.get("type"))) {
data[ChkUtil.getInteger(times.substring(times.indexOf("-") + 1)) - 1] = (int) num;
}
});
map.put("name", t.get("type"));
map.put("data", data);
list2.add(map);
}
});
return list2;
}
// 保存每年12个月的数据
public static Map<String, Object> addTimes(Map<String, Integer> map) {
Map<String, Object> map1 = new HashMap<String, Object>();
int[] a = new int[12];
Set<String> timeKey = map.keySet();
for (String s : timeKey) {
a[ChkUtil.getInteger(s.substring(s.indexOf("-") + 1)) - 1] = map.get(s);
}
map1.put("time", a);
return map1;
}
// 保存每年每天的数据
public static Map<String, Object> addYearTimes(List<Map<String, Object>> list, int date) {
Map<String, Object> map = new LinkedHashMap<String, Object>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, date);
cal.set(Calendar.MONTH, 1);
cal.set(Calendar.DAY_OF_YEAR, 1);
Calendar cal1 = Calendar.getInstance();
cal1.set(Calendar.YEAR, date + 1);
cal1.set(Calendar.MONTH, 1);
cal1.set(Calendar.DAY_OF_YEAR, 1);
cal1.set(Calendar.HOUR_OF_DAY, 0);
cal1.set(Calendar.MINUTE, 0);
cal1.set(Calendar.SECOND, 0);
while (cal.compareTo(cal1) < 0) {
map.put(sdf.format(cal.getTime()), 0);
cal.add(Calendar.DAY_OF_YEAR, 1);
}
list.forEach(l -> {
map.put((String) l.get("times"), l.get("num"));
});
return map;
}
public static void main(String[] args) {
addYearTimes(null, 2017);
}
}
@@ -1,37 +0,0 @@
package com.adc.da.wkflow.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import java.util.Map;
/**
* @author: super_liu
* @date: 2021年03月04日 17:13
*/
public class Utils {
public static Map<String, JSONArray> jsonArrGroup(JSONArray arr, String groupName, String sGroupName) {
Map<String, JSONArray> map = new HashMap<>();
String tempIdStr = "";
JSONArray list;
for(Object obj : arr){
JSONObject jsonObject = (JSONObject) obj;
tempIdStr = jsonObject.getString(groupName);
if(tempIdStr.equals("")){
continue;
}
if(map.containsKey(tempIdStr)){
list = map.get(tempIdStr);
list.add(obj);
}else{
list = new JSONArray();
list.add(obj);
map.put(tempIdStr, list);
}
}
return map;
}
}
@@ -1,152 +0,0 @@
/**
*
*/
package com.adc.da.wkflow.util.coder;
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
* 代码生成 - mybatis-plus
* 官方示例
* @author 冯晓东
*
*/
public class CodeGenerator {
private static final String parent = "com.adc.da.wkflow.business_main";
private static final String jdbcUrl = "jdbc:mysql://106.2.13.59:8037/bat-wkflow?nullCatalogMeansCurrent=true&serverTimezone=Asia/Shanghai&useSSL=false&characterEncoding=utf-8";
private static final String driver = "com.mysql.cj.jdbc.Driver";
private static final String uname = "rczbuser";
private static final String password = "91isoft@PT";
/**
* <p>
* 读取控制台内容
* </p>
*/
public static String scanner(String tip) {
@SuppressWarnings("resource")
Scanner scanner = new Scanner(System.in);
StringBuilder help = new StringBuilder();
help.append("请输入" + tip + "");
System.out.println(help.toString());
if (scanner.hasNext()) {
String ipt = scanner.next();
if (StringUtils.isNotEmpty(ipt)) {
return ipt;
}
}
throw new MybatisPlusException("请输入正确的" + tip + "");
}
public static void main(String[] args) {
// 代码生成器
AutoGenerator mpg = new AutoGenerator();
// 全局配置
GlobalConfig gc = new GlobalConfig();
String projectPath = System.getProperty("user.dir");
gc.setOutputDir(projectPath + "/src/main/java");
gc.setAuthor("冯晓东");
gc.setOpen(false);
//实体属性 Swagger2 注解
gc.setSwagger2(true);
mpg.setGlobalConfig(gc);
// 数据源配置
DataSourceConfig dsc = new DataSourceConfig();
dsc.setUrl(jdbcUrl);
// dsc.setSchemaName("public");
dsc.setDriverName(driver);
dsc.setUsername(uname);
dsc.setPassword(password);
mpg.setDataSource(dsc);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setModuleName(scanner("模块名"));
pc.setParent(parent);
mpg.setPackageInfo(pc);
// 自定义配置
InjectionConfig cfg = new InjectionConfig() {
@Override
public void initMap() {
// to do nothing
}
};
// 如果模板引擎是 freemarker
//String templatePath = "/templates/mapper.xml.ftl";
// 如果模板引擎是 velocity
String templatePath = "/templates/mapper.xml.vm";
// 自定义输出配置
List<FileOutConfig> focList = new ArrayList<>();
// 自定义配置会被优先输出
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
+ "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
}
});
/*
cfg.setFileCreate(new IFileCreate() {
@Override
public boolean isCreate(ConfigBuilder configBuilder, FileType fileType, String filePath) {
// 判断自定义文件夹是否需要创建
checkDir("调用默认方法创建的目录");
return false;
}
});
*/
cfg.setFileOutConfigList(focList);
mpg.setCfg(cfg);
// 配置模板
TemplateConfig templateConfig = new TemplateConfig();
// 配置自定义输出模板
//指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
// templateConfig.setEntity("templates/entity2.java");
// templateConfig.setService();
// templateConfig.setController();
templateConfig.setXml(null);
mpg.setTemplate(templateConfig);
// 策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
// strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!");
strategy.setEntityLombokModel(true);
strategy.setRestControllerStyle(true);
// 公共父类
// strategy.setSuperControllerClass("你自己的父类控制器,没有就不用设置!");
// 写于父类中的公共字段
strategy.setSuperEntityColumns("id");
strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));
strategy.setControllerMappingHyphenStyle(true);
strategy.setTablePrefix("t_");
mpg.setStrategy(strategy);
mpg.setTemplateEngine(new VelocityTemplateEngine());
mpg.execute();
}
}
@@ -1,6 +1,6 @@
package com.adc.da.wkflow.util.date;
import com.tmsps.fk.common.util.ChkUtil;
import cn.hutool.core.util.StrUtil;
import java.sql.Timestamp;
import java.text.ParseException;
@@ -200,7 +200,7 @@ public class DateTools {
/**
* 字符串转 Timestamp对象
*
* @param date
* @param datetime
*/
public static Timestamp strToDatestamp(String datetime) {
String pattern = "yyyy-MM-dd HH:mm:ss";
@@ -241,7 +241,7 @@ public class DateTools {
}
public static java.sql.Date strToDate(String date, String pattern) {
if (ChkUtil.isNull(date)) {
if (StrUtil.isEmpty(date)) {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
@@ -255,7 +255,7 @@ public class DateTools {
}
public static java.sql.Date strToDate2(String date) {
if (ChkUtil.isNull(date)) {
if (StrUtil.isEmpty(date)) {
return null;
}
date = date.replace("Z", " UTC");
@@ -270,7 +270,7 @@ public class DateTools {
}
public static java.sql.Date strToDate(String date, String pattern, boolean ifNullToNow) {
if (ChkUtil.isNull(date)) {
if (StrUtil.isEmpty(date)) {
if (ifNullToNow) {
return new java.sql.Date(System.currentTimeMillis());
} else {
@@ -342,7 +342,7 @@ public class DateTools {
}
public static String format(java.sql.Date date) {
if (ChkUtil.isNull(date)) {
if (date == null) {
return "";
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
@@ -384,7 +384,7 @@ public class DateTools {
}
public static String formatDateTime(Timestamp date) {
if (ChkUtil.isNull(date)) {
if (date == null) {
return "";
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -392,7 +392,7 @@ public class DateTools {
}
public static String formatDateTime(Date date) {
if (ChkUtil.isNull(date)) {
if (date == null) {
return "";
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -400,7 +400,7 @@ public class DateTools {
}
public static String formatDate(Timestamp date) {
if (ChkUtil.isNull(date)) {
if (date == null) {
return "";
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
@@ -408,7 +408,7 @@ public class DateTools {
}
public static String formatDate(Timestamp date, String patten) {
if (ChkUtil.isNull(date)) {
if (date == null) {
return "";
}
SimpleDateFormat df = new SimpleDateFormat(patten);
@@ -416,7 +416,7 @@ public class DateTools {
}
public static String formatDate(Date date) {
if (ChkUtil.isNull(date)) {
if (date == null) {
return "";
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
@@ -1,7 +1,6 @@
package com.adc.da.wkflow.util.file;
import com.tmsps.fk.common.util.ChkUtil;
import com.tmsps.fk.common.util.JsonUtil;
import cn.hutool.core.util.StrUtil;
import java.io.*;
import java.nio.ByteBuffer;
@@ -11,23 +10,6 @@ import java.util.Map;
public class FileTools {
// 解析propertis中的字符串
public static String parseStr(String str) {
str = str.replace("{", "").replace("}", "");
System.err.println(JsonUtil.toJson(str));
String[] split = str.split(",");
System.err.println(JsonUtil.toJson(split));
Map<String, Object> map = new HashMap<String, Object>();
for (int i = 0; i < split.length; i++) {
String[] split2 = split[i].split("=");
map.put(split2[0].trim(), split2[1].trim());
}
return map.get("bidPrice").toString();
}
// 解析propertis中的字符串
public static Map<String, Object> parseStrToMap(String str) {
@@ -44,7 +26,7 @@ public class FileTools {
}
public static String getSuffix(String filename) {
if (ChkUtil.isNull(filename)) {
if (StrUtil.isEmpty(filename)) {
return "";
}
if (!filename.contains(".")) {
@@ -230,11 +212,10 @@ public class FileTools {
* 文件写入数据
*
* @param content
* @param write_url
* @return
*/
public static boolean writeFile(String content, String url) {
if (ChkUtil.isNull(url)) {
if (StrUtil.isEmpty(url)) {
return false;
}
BufferedWriter writer = null;
@@ -266,36 +247,6 @@ public class FileTools {
return true;
}
public static void main(String[] args) {
// String s = "x.ds"; System.err.println(FileTools.getSuffix(s));
// boolean fileName =
// checkFileName("C:\\tmp\\74f926b3-26cb-4d36-8f86-634b49323d33");
// System.err.println(fileName);
// File file = new
// File("C:\\data\\data\\bid\\6Yyfh6wZxyBJkYDzn5M95T\\key.txt");
// System.out.println(getKey(file));
// File folder = new
// File("C:\\data\\data\\bid\\KTugyHVuGAvFrkCngLBXnc");// 默认目录
// String keyword = ".bid";
// if (!folder.exists()) {// 如果文件夹不存在
// System.out.println("目录不存在:" + folder.getAbsolutePath());
// return;
// }
// File result = searchFile(folder, keyword);// 调用方法获得文件数组
// System.out.println("在 " + folder + " 以及所有子文件时查找对象" + keyword);
// System.out.println(result.getAbsolutePath() + " ");// 显示文件绝对路径
String unzip_dir_url = "C:/data/data/bid/8rGZfcqDHbc9W7WTKUUrZe/ceshi";
File attachmentFileFolder = FileTools.searchFile(new File(unzip_dir_url), ".docx");
System.err.println(JsonUtil.toJson(attachmentFileFolder));
// File[] attachmentFiles = attachmentFileFolder.listFiles();
// System.err.println(JsonUtil.toJson(attachmentFiles));
}
public static String readFileToString(String file) {
String content = "";
// 2、建立数据通道
@@ -1,6 +1,6 @@
package com.adc.da.wkflow.util.form;
import com.tmsps.fk.common.util.ChkUtil;
import cn.hutool.core.util.StrUtil;
import java.io.BufferedReader;
import java.io.IOException;
@@ -49,7 +49,7 @@ public class FormReadTools {
}
public static String replaceSubmitModel(String json) {
if (ChkUtil.isNull(json)) {
if (StrUtil.isEmpty(json)) {
return null;
}
// var formData = '@loadFormData()';
@@ -57,7 +57,7 @@ public class FormReadTools {
}
public static String replaceReadModel(String json) {
if (ChkUtil.isNull(json)) {
if (StrUtil.isEmpty(json)) {
return null;
}
// var formData = '@loadFormData()';
@@ -1,49 +0,0 @@
package com.adc.da.wkflow.util.token;
import com.tmsps.fk.common.base.exception.BusinessException;
import com.adc.da.wkflow.util.WebUtil;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
* 重复提交aop
*
* @author 冯晓东
*/
@Aspect
@Component
public class TokenAspect {
private static final Logger logger = LoggerFactory.getLogger(TokenAspect.class);
/**
* @param jp
*
* 经测试,会按照单个浏览器,并行执行. 无需担心同步问题.
*/
@Before("@annotation(com.tmsps.fk.common.token.TokenCheck)")
public void before(JoinPoint jp) throws Throwable {
String token = WebUtil.getRequest().getParameter("token");
logger.info("token --> {}", token);
if (token == null || "".equals(token.trim())) {
throw new BusinessException("500:Parameter <token> can not be null.");
}
if (!token.contains("@@")) {
throw new BusinessException("500:Parameter <token> is invalid key.");
}
String key = token.split("@@")[0];
String snToken = WebUtil.getAsyncToken("token@@" + key);
logger.info("session token --> {}", snToken);
if (!token.equals(snToken)) {
throw new BusinessException("500:Token is invalid.");
}
}
}
@@ -1,29 +0,0 @@
package com.adc.da.wkflow.util.token;
import com.adc.da.wkflow.util.WebUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.UUID;
@RestController
public class TokenController {
/**
*
* @param key
* @return
*/
@GetMapping("/getToken")
public String getToken(String key) {
if (key == null || "".equals(key.trim())) {
throw new RuntimeException("500:Parameter <key> can not be null.");
}
// 设置token值
String token = key + "@@" + UUID.randomUUID();
WebUtil.getSession().setAttribute("token@@" + key, token);
return token;
}
}
@@ -1,79 +0,0 @@
package com.adc.da.wkflow.util.tree;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
*
* @author 冯晓东 398479251@qq.com
*
*/
public class AuthTreeTools {
/**
* 预处理树节点
*
* @param menuList
* @param isChecked
* @return
*/
private static JSONArray handleTree(JSONArray menuList, boolean isChecked) {
for (int i = 0; i < menuList.size(); i++) {
JSONObject map = menuList.getJSONObject(i);
map.put("key", map.getString("code"));
map.put("value", map.getString("code"));
map.put("title", map.getString("name"));
if (isChecked) {
map.put("checked", false);
}
}
return menuList;
}
public static List<Map<String, Object>> turnListToTree(JSONArray menuList) {
// 转换List为树形结构
return turnListToTree(menuList, false);
}
@SuppressWarnings("unchecked")
public static List<Map<String, Object>> turnListToTree(JSONArray menuList, boolean isChecked) {
// 转换List为树形结构
menuList = handleTree(menuList, isChecked);
List<Map<String, Object>> nodeList = new ArrayList<Map<String, Object>>();
for (int i = 0; i < menuList.size(); i++) {
JSONObject node1 = menuList.getJSONObject(i);
String node1_code = (String) node1.get("code");
String node1_parent_code = node1_code.substring(0, node1_code.length() - 3);
boolean mark = false;
for (int j = 0; j < menuList.size(); j++) {
Map<String, Object> node2 = menuList.getJSONObject(j);
String node2_code = (String) node2.get("code");
if (node1_parent_code != null && node1_parent_code.equals(node2_code)) {
mark = true;
if (node2.get("children") == null) {
node2.put("children", new ArrayList<Map<String, Object>>());
}
((List<Map<String, Object>>) node2.get("children")).add(node1);
node2.put("leaf", false);
if (!isChecked) {
node2.put("expanded", false);
}
break;
}
}
if (!mark) {
nodeList.add(node1);
}
}
return nodeList;
}
}
@@ -0,0 +1,52 @@
package com.adc.da.wkflow.util.wrapper;
import org.apache.commons.lang3.StringUtils;
public class WrapMapper {
private WrapMapper() {
}
public static <E> Wrapper<E> wrap(int code, String message, E o) {
return new Wrapper(code, message, o);
}
public static <E> Wrapper<E> wrap(int code, String message) {
return wrap(code, message, null);
}
public static <E> Wrapper<E> wrap(int code) {
return wrap(code, (String)null);
}
public static <E> Wrapper<E> wrap(Exception e) {
return new Wrapper(500, e.getMessage());
}
public static <E> E unWrap(Wrapper<E> wrapper) {
return wrapper.getResult();
}
public static <E> Wrapper<E> illegalArgument() {
return wrap(100, "参数非法");
}
public static <E> Wrapper<E> error() {
return wrap(500, "内部异常");
}
public static <E> Wrapper<E> error(String message) {
return wrap(500, StringUtils.isBlank(message) ? "内部异常" : message);
}
public static <E> Wrapper<E> ok() {
return new Wrapper();
}
public static <E> Wrapper<E> ok(E o) {
return new Wrapper(200, "操作成功", o);
}
public static <E> Wrapper<E> ok(String message, E o) {
return new Wrapper(200, message, o);
}
}
@@ -0,0 +1,147 @@
package com.adc.da.wkflow.util.wrapper;
import java.io.Serializable;
public class Wrapper<T> implements Serializable {
private static final long serialVersionUID = 1L;
public static final int SUCCESS_CODE = 200;
public static final String SUCCESS_MESSAGE = "操作成功";
public static final int ERROR_CODE = 500;
public static final String ERROR_MESSAGE = "内部异常";
public static final int ILLEGAL_ARGUMENT_CODE_ = 100;
public static final String ILLEGAL_ARGUMENT_MESSAGE = "参数非法";
private boolean success;
private int code;
private String message;
private T result;
Wrapper() {
this(200, "操作成功");
}
Wrapper(int code, String message) {
this(code, message, null);
}
Wrapper(int code, String message, T result) {
this.success = true;
this.code(code).message(message).result(result);
}
private Wrapper<T> code(int code) {
this.setCode(code);
return this;
}
private Wrapper<T> message(String message) {
this.setMessage(message);
return this;
}
public Wrapper<T> result(T result) {
this.setResult(result);
return this;
}
public boolean success() {
return 200 == this.code;
}
public boolean error() {
return !this.success();
}
public boolean isSuccess() {
return this.success;
}
public int getCode() {
return this.code;
}
public String getMessage() {
return this.message;
}
public T getResult() {
return this.result;
}
public void setSuccess(boolean success) {
this.success = success;
}
public void setCode(int code) {
this.code = code;
}
public void setMessage(String message) {
this.message = message;
}
public void setResult(T result) {
this.result = result;
}
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (!(o instanceof Wrapper)) {
return false;
} else {
Wrapper<?> other = (Wrapper)o;
if (!other.canEqual(this)) {
return false;
} else if (this.isSuccess() != other.isSuccess()) {
return false;
} else if (this.getCode() != other.getCode()) {
return false;
} else {
label40: {
Object this$message = this.getMessage();
Object other$message = other.getMessage();
if (this$message == null) {
if (other$message == null) {
break label40;
}
} else if (this$message.equals(other$message)) {
break label40;
}
return false;
}
Object this$result = this.getResult();
Object other$result = other.getResult();
if (this$result == null) {
if (other$result != null) {
return false;
}
} else if (!this$result.equals(other$result)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(Object other) {
return other instanceof Wrapper;
}
public int hashCode() {
int result = 1;
result = result * 59 + (this.isSuccess() ? 79 : 97);
result = result * 59 + this.getCode();
Object $message = this.getMessage();
result = result * 59 + ($message == null ? 43 : $message.hashCode());
Object $result = this.getResult();
result = result * 59 + ($result == null ? 43 : $result.hashCode());
return result;
}
public String toString() {
return "Wrapper(success=" + this.isSuccess() + ", code=" + this.getCode() + ", message=" + this.getMessage() + ", result=" + this.getResult() + ")";
}
}