* 'dev' of http://221.0.232.152:9393/ability-center/share-platform:
  同步知识库问题
  。。。
  user表新增字段
  融合服务修改
  修改获从金宏网获取用户信息,但是还是获取不到guid
  同步知识库的优化
  能力申请v3-bug fix
  ...
  ...
  调整跨区判断
  更新能力申请模型v3
  接口开启gzip压缩
  区、市监听器:修改表单字段获取逻辑
  applyState 字段返回值不一致的问题fix
  npe fix

# Conflicts:
#	renren-admin/src/main/java/io/renren/modules/sys/entity/SysUserEntity.java
This commit is contained in:
huangweixiong 2022-08-26 13:47:12 +08:00
commit 951923b551
15 changed files with 335 additions and 211 deletions

View File

@ -239,9 +239,14 @@ public class AbilityCenterControllerV3 {
return;
}
List<TAbilityApplicationDTO> dtoList = temp.get(deptId);
dtoList = dtoList.stream().map(index -> {
index.setResourceOwnerDept(sysDeptDTO);
return index;
}).collect(Collectors.toList());
List<TAbilityApplicationDTO> finalDtoList = dtoList;
CompletableFuture.runAsync(() -> {
String[] sqls = dtoList.stream().map(index -> String.format("UPDATE t_ability_application SET resource_owner_dept = '%s' WHERE id = %s", JSON.toJSONString(sysDeptDTO), index.getId())).collect(Collectors.toList()).toArray(new String[dtoList.size()]);
String[] sqls = finalDtoList.stream().map(index -> String.format("UPDATE t_ability_application SET resource_owner_dept = '%s' WHERE id = %s", JSON.toJSONString(sysDeptDTO), index.getId())).collect(Collectors.toList()).toArray(new String[finalDtoList.size()]);
jdbcTemplate.batchUpdate(sqls); // 批量更新资源所属部门信息
logger.info("批量更新申请的资源的部门信息完成");
}, executor);
@ -280,10 +285,11 @@ public class AbilityCenterControllerV3 {
if (applyUserDeptType == 2) {
cityApply = Boolean.TRUE; // 市级部门发起申请
}
if (cityApply && resourceDeptType == 2) {
if (resourceDeptType == 2) {
cityApplyCity = Boolean.TRUE; // 市区申请市区
}
if (!cityApply && (user.getDeptId() != sysDeptDTO.getId())) { // 非市申请且发起人与资源所属部门不一致
SysDeptDTO userDept = sysDeptService.get(user.getDeptId());
if (!cityApply && !userDept.getDistrict().equals(sysDeptDTO.getDistrict())) { // 非市申请且发起人与资源所属区县不一致
crossRegion = Boolean.TRUE; // 跨区
}
}
@ -292,9 +298,10 @@ public class AbilityCenterControllerV3 {
Boolean finalCityApply = cityApply;
Boolean finalCityApplyCity = cityApplyCity;
Boolean finalCrossRegion = crossRegion;
List<TAbilityApplicationDTO> finalDtoList1 = dtoList;
variables.putAll(new HashMap<String, Object>() { // 流程内携带属性值
{
put("tAbilityApplicationDTOList", dtoList); // 归属该部门的申请
put("tAbilityApplicationDTOList", finalDtoList1); // 归属该部门的申请
put("key", processStartDTO.getBusinessKey()); // 归属该部门申请的表单id
put("deptId", deptId); // 归属部门
put("_id", applyFlag); //申请id
@ -306,6 +313,7 @@ public class AbilityCenterControllerV3 {
put("city_apply", finalCityApply); // 是否为市级部门发起申请
put("cross_region", finalCrossRegion); // 是否跨区
put("city_apply_city", finalCityApplyCity); // 是否为市区申请市区
put("resource_dept", sysDeptDTO); // 同一审核单内部门信息
}
});
@ -313,10 +321,11 @@ public class AbilityCenterControllerV3 {
ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO);
// 仿照请求接口 /processForm/tabilityapplication/updateInstanceId
List<TAbilityApplicationDTO> finalDtoList2 = dtoList;
CompletableFuture.runAsync(() -> {
if (dto.getBusinessKey() != null) {
String[] sqls = dtoList.stream().map(i -> String.format("UPDATE t_ability_application SET instance_id = %s WHERE id = %s", dto.getProcessInstanceId(), i.getId()))
.collect(Collectors.toList()).toArray(new String[dtoList.size()]);
String[] sqls = finalDtoList2.stream().map(i -> String.format("UPDATE t_ability_application SET instance_id = %s WHERE id = %s", dto.getProcessInstanceId(), i.getId()))
.collect(Collectors.toList()).toArray(new String[finalDtoList2.size()]);
jdbcTemplate.batchUpdate(sqls);
}
}, executor);

View File

@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
@ -61,6 +62,13 @@ public class FuseController {
return new Result<TbFuseDTO>().ok(tbFuseService.getFuseById(id));
}
@GetMapping("getDataResource")
@ApiOperation("获取资源数据")
@LogOperation("获取资源数据")
public Result<List<Map>> getDataResource() {
return new Result().ok(tbFuseService.getDataResource());
}
@PostMapping
@ApiOperation("保存")
@LogOperation("保存")

View File

@ -4,6 +4,7 @@ import io.renren.common.service.CrudService;
import io.renren.modules.fuse.dto.TbFuseDTO;
import io.renren.modules.fuse.entity.TbFuseEntity;
import java.util.List;
import java.util.Map;
/**
@ -15,6 +16,8 @@ public interface TbFuseService extends CrudService<TbFuseEntity, TbFuseDTO> {
TbFuseDTO getFuseById(Long id);
List<Map> getDataResource();
Integer addFuse(TbFuseDTO dto);
Integer updateFuse(TbFuseDTO dto);

View File

@ -154,35 +154,52 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
}).collect(Collectors.toList());
}
private Map<String, Map<String, Object>> getDataResource() {
Map<String, Map<String, Object>> result = new HashMap<>();
public List<Map> getDataResource() {
int pageNum=0;
int pageSize=getDataResourceCount();
List<Map> result = new ArrayList<>();
Optional<AbstractDataResourceService> factory = DataResourceFactory.build();
if (factory.isPresent()) {
GetDataResourceListDto dto = new GetDataResourceListDto().setPageNum(0).setPageSize(30);
GetDataResourceListDto dto = new GetDataResourceListDto().setPageNum(pageNum).setPageSize(pageSize);
Map<String, Object> dataMap = (Map<String, Object>) factory.get().getDataResource(dto);
if (dataMap != null) {
List<Map<String, Object>> list = (List<Map<String, Object>>) dataMap.get("data");
list.forEach(map -> {
list.forEach(map -> result.add(new HashMap() {{
if (map.containsKey("zyname")) {
result.put(map.get("guid").toString(), map);
put("id", map.get("guid"));
put("name", map.get("zyname"));
} else {
result.put(map.get("serviceId").toString(), map);
put("id", map.get("serviceId"));
put("name", map.get("serviceName"));
}
});
}}));
}
}
return result;
}
private int getDataResourceCount() {
int count=30;
Optional<AbstractDataResourceService> factory = DataResourceFactory.build();
if (factory.isPresent()) {
GetDataResourceListDto dto = new GetDataResourceListDto().setPageNum(0).setPageSize(30);
Map<String, Object> dataMap = (Map<String, Object>) factory.get().getDataResource(dto);
if (dataMap != null) {
count=Integer.parseInt(dataMap.get("rows").toString());
}
}
return count;
}
private List<TbFuseResourceDTO> getFuseResourceByFuseId(Long fuseId) {
Map<String, Map<String, Object>> dataResourceMap = new HashMap<>();
List<Map> dataResourceMap = new ArrayList<>();
List<TbFuseResourceDTO> result = new ArrayList();
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("fuse_id", fuseId);
List<TbFuseResourceEntity> list = fuseResourceDao.selectList(wrapper);
Map<String, List<TbFuseResourceEntity>> resourceMap = list.stream().filter(index -> index.getType() != null).collect(Collectors.groupingBy(TbFuseResourceEntity::getType));
if (resourceMap.containsKey("数据资源")) {
dataResourceMap.putAll(getDataResource());
dataResourceMap.addAll(getDataResource());
}
resourceMap.forEach((type, value) -> {
if ("组件服务".equals(type)) {
@ -198,7 +215,7 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
result.addAll(value.stream().map(attr -> {
TbFuseResourceDTO dto = new TbFuseResourceDTO();
BeanUtils.copyProperties(attr, dto);
dto.setResource(dataResourceMap.get(dto.getResourceId()));
dto.setResource(dataResourceMap.stream().filter(it->it.get("id").equals(dto.getResourceId())).findFirst());
return dto;
}).collect(Collectors.toList()));
} else if ("基础设施".equals(type)) {

View File

@ -1,8 +1,6 @@
package io.renren.modules.gateway.controller;
import cn.hutool.core.net.URLEncoder;
import cn.hutool.core.util.URLUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.modules.gateway.service.MonitorServiceV2;
@ -15,19 +13,16 @@ import io.renren.modules.sys.dao.SysDeptDao;
import io.renren.modules.sys.entity.SysDeptEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.stereotype.Controller;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.HttpMessageConverterExtractor;
import org.springframework.web.client.RequestCallback;
import org.springframework.web.client.RestTemplate;
import javax.servlet.ServletOutputStream;
@ -66,14 +61,14 @@ public class MonitorController {
@Autowired
private MonitorServiceV2 monitorServiceV2;
// @RequestMapping("/metrics/**")
// @RequestMapping("/metrics/**")
void forward(HttpServletRequest request, HttpServletResponse response) throws IOException {
//类似nginx匹配前缀
String location = "/juapi";
String requestURI = request.getRequestURI();
requestURI = requestURI.replace( context_path,"");
String url = gatewayDomain + location + requestURI ;
requestURI = requestURI.replace(context_path, "");
String url = gatewayDomain + location + requestURI;
if (StringUtils.isNotBlank(request.getQueryString())) {
url = url + "?" + request.getQueryString();
}
@ -81,7 +76,7 @@ public class MonitorController {
HttpHeaders headers = new HttpHeaders();
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()){
while (headerNames.hasMoreElements()) {
String element = headerNames.nextElement();
headers.add(element, request.getHeader(element));
}
@ -89,17 +84,17 @@ public class MonitorController {
InputStream in = request.getInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int len = 1024;
byte tmp [] = new byte[len];
int i ;
while((i=in.read(tmp, 0, len))>0){
byte tmp[] = new byte[len];
int i;
while ((i = in.read(tmp, 0, len)) > 0) {
baos.write(tmp, 0, i);
}
HttpEntity<byte[]> httpEntity = null;
if (baos.size() > 0){
if (baos.size() > 0) {
httpEntity = new HttpEntity(baos.toByteArray(), headers);
}else {
} else {
httpEntity = new HttpEntity(headers);
}
@ -118,13 +113,13 @@ public class MonitorController {
@GetMapping("/metrics/**")
@ApiOperation("前端访问图片请求转发")
public void ford(HttpServletRequest request, HttpServletResponse response){
public void ford(HttpServletRequest request, HttpServletResponse response) {
String location = "/juapi";
String requestURI = request.getRequestURI();
requestURI = requestURI.replace( context_path,"");
String fordUrl = gatewayDomain + location + requestURI ;
requestURI = requestURI.replace(context_path, "");
String fordUrl = gatewayDomain + location + requestURI;
if (StringUtils.isNotBlank(request.getQueryString())) {
fordUrl = fordUrl + "?" + request.getQueryString();
}
@ -157,34 +152,34 @@ public class MonitorController {
len = inputStream.read(buffer);
}
inputStream.close();
}catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@GetMapping("/gateway-monitor/queryGroupByAbility")
@ApiOperation("统计数据按能力归集")
public Result queryGroupByAbility(String query, String time){
public Result queryGroupByAbility(String query, String time) {
String url = gatewayDomain + "/juapi/metrics/api/v1/query?query={query}" + "&time=" + time;
ResponseEntity<HashMap> entity = restTemplate.getForEntity(url, HashMap.class, query);
HashMap body = entity.getBody();
HashMap data = (HashMap) body.get("data");
if (data != null){
if (data != null) {
List<HashMap> result = (List) data.get("result");
ArrayList<Map> results = new ArrayList<>();
ArrayList<Long> abilityIds = new ArrayList<>();
for (HashMap hashMap : result) {
Map metric = (Map) hashMap.get("metric");
if (metric != null && metric.get("groupInfo") != null){
if (metric != null && metric.get("groupInfo") != null) {
List value = (List) hashMap.get("value");
if (value.size() == 2){
if (value.size() == 2) {
metric.put("count", value.get(1));
try{
try {
Long groupInfo = Long.valueOf((String) metric.get("groupInfo"));
abilityIds.add(groupInfo);
metric.put("groupInfo", groupInfo);
results.add(metric);
}catch (Exception e) {
} catch (Exception e) {
//忽略
}
@ -211,9 +206,9 @@ public class MonitorController {
map.put("type", resourceEntity.getType());
map.put("apiUrl", resourceEntity.getApiUrl());
LambdaQueryWrapper<AttrEntity> attrQueryWrapper = new LambdaQueryWrapper<>();
attrQueryWrapper.select(AttrEntity::getAttrType,AttrEntity::getAttrValue)
.eq(AttrEntity::getDataResourceId,groupInfo)
.eq(AttrEntity::getAttrType,"服务商名")
attrQueryWrapper.select(AttrEntity::getAttrType, AttrEntity::getAttrValue)
.eq(AttrEntity::getDataResourceId, groupInfo)
.eq(AttrEntity::getAttrType, "服务商名")
.eq(AttrEntity::getDelFlag, 0);
AttrEntity attrEntity = attrDao.selectOne(attrQueryWrapper);
if (attrEntity.getAttrValue() != null) {
@ -234,27 +229,27 @@ public class MonitorController {
@GetMapping("/gateway-monitor/queryGroupByDepartment")
@ApiOperation("统计数据按部门归集")
public Result queryGroupByDepartment(String query, String time){
public Result queryGroupByDepartment(String query, String time) {
String url = gatewayDomain + "/juapi/metrics/api/v1/query?query={query}" + "&time=" + time;
ResponseEntity<HashMap> entity = restTemplate.getForEntity(url, HashMap.class, query);
HashMap body = entity.getBody();
HashMap data = (HashMap) body.get("data");
if (data != null){
if (data != null) {
List<HashMap> result = (List) data.get("result");
ArrayList<Map> results = new ArrayList<>();
ArrayList<Long> abilityIds = new ArrayList<>();
for (HashMap hashMap : result) {
Map metric = (Map) hashMap.get("metric");
if (metric != null && metric.get("deptInfo") != null){
if (metric != null && metric.get("deptInfo") != null) {
List value = (List) hashMap.get("value");
if (value.size() == 2){
if (value.size() == 2) {
metric.put("count", value.get(1));
try {
Long groupInfo = Long.valueOf((String) metric.get("deptInfo"));
abilityIds.add(groupInfo);
metric.put("deptInfo", groupInfo);
results.add(metric);
}catch (Exception e) {
} catch (Exception e) {
//忽略
}
@ -264,7 +259,7 @@ public class MonitorController {
if (!results.isEmpty()) {
LambdaQueryWrapper<SysDeptEntity> queryWrapper = new QueryWrapper<SysDeptEntity>().lambda();
queryWrapper.select(SysDeptEntity::getName,SysDeptEntity::getId)
queryWrapper.select(SysDeptEntity::getName, SysDeptEntity::getId)
.in(SysDeptEntity::getId, abilityIds);
List<SysDeptEntity> entities = sysDeptDao.selectList(queryWrapper);
for (Map map : results) {
@ -287,7 +282,7 @@ public class MonitorController {
@GetMapping("/gateway-monitor/queryGroupByDeptInRange")
@ApiOperation("统计数据按部门显示趋势")
public Result queryGroupByDeptInRange(String query, String start, String end, String step){
public Result queryGroupByDeptInRange(String query, String start, String end, String step) {
String url = gatewayDomain + "/juapi/metrics/api/v1/query_range?query={query}" +
"&start=" + start +
"&end=" + end +
@ -296,34 +291,32 @@ public class MonitorController {
ResponseEntity<HashMap> entity = restTemplate.getForEntity(url, HashMap.class, query);
HashMap body = entity.getBody();
HashMap data = (HashMap) body.get("data");
if (data != null){
if (data != null) {
List<HashMap> result = (List) data.get("result");
ArrayList<HashMap> results = new ArrayList<>(result.size());
for (HashMap hashMap : result) {
Map metric = (Map) hashMap.get("metric");
if (metric != null && metric.get("deptInfo") != null){
try{
if (metric != null && metric.get("deptInfo") != null) {
try {
Long filterId = Long.valueOf((String) metric.get("deptInfo"));
SysDeptEntity sysDeptEntity = sysDeptDao.selectById(filterId);
if (sysDeptEntity != null && StringUtils.isNotBlank(sysDeptEntity.getName())){
if (sysDeptEntity != null && StringUtils.isNotBlank(sysDeptEntity.getName())) {
metric.put("name", sysDeptEntity.getName());
results.add(hashMap);
}
}catch (Exception e){
log.warn("数据异常忽略", e);
} catch (Exception e) {
log.warn("数据异常忽略:{}", e.getMessage());
}
}
}
return Result.success(results);
}
return Result.success(Collections.emptyList());
}
@GetMapping("/gateway-monitor/queryGroupCount")
@ApiOperation("查询总api数量")
public Result queryGroupCount(){
public Result queryGroupCount() {
LambdaQueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<ResourceEntity>().lambda();
queryWrapper.isNotNull(ResourceEntity::getGroupId).eq(ResourceEntity::getDelFlag, 0);
Integer selectCount = resourceDao.selectCount(queryWrapper);
@ -332,23 +325,23 @@ public class MonitorController {
@GetMapping("/gateway-monitor/getCallCount")
@ApiOperation("查询总api调用总量")
public Result getCallCount(){
public Result getCallCount() {
Long callCount = monitorServiceV2.getCallCount();
return Result.success(callCount);
}
@GetMapping("/gateway-monitor/test/get")
public Result testGet(){
public Result testGet() {
return Result.success(null);
}
@GetMapping("/gateway-monitor/test/404")
public void test404(HttpServletResponse response){
public void test404(HttpServletResponse response) {
response.setStatus(404);
}
@GetMapping("/gateway-monitor/test/500")
public void test500(HttpServletResponse response){
public void test500(HttpServletResponse response) {
response.setStatus(500);
}

View File

@ -1,12 +1,8 @@
package io.renren.modules.processForm.listener.v3;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import io.renren.common.annotation.ActivitiNoticeOperation;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.sys.dao.SysUserDao;
import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysRoleDTO;
@ -75,34 +71,41 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A
private void create(DelegateTask delegateTask) {
String assignee;
Map<String, Object> kv = delegateTask.getVariables();
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
if (kv.containsKey("userId")) {
Long applyUserId = Long.valueOf(kv.get("userId").toString());
SysDeptDTO deptDTO = sysDeptService.get(sysUserService.get(applyUserId).getDeptId());
Gson gson = builder.create();
JsonElement jsonElement = gson.toJsonTree(kv);
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
String userId = null;
if (deptDTO.getDistrict() != null) {
SysRegionEntity regionEntity = sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.THREE);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
SysDeptDTO deptDTO = sysDeptService.get(sysUserService.get(Long.parseLong(abilityApplicationDTO.getUserId())).getDeptId());
SysRegionEntity regionEntity = sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.THREE);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId()));
Optional<SysUserEntity> userEntityOptional = userList.stream()
.filter(user -> Objects.equals(regionEntity.getId(), sysRegionService.getByLevel(sysDeptService.get(user.getDeptId()).getDistrict(), RegionLevelEnum.THREE).getId())).findFirst();
if (userEntityOptional.isPresent()) {
logger.error("审批人id:" + userEntityOptional.get().getId());
taskService.setAssignee(delegateTask.getId(), userEntityOptional.get().getId().toString());
assignee = userEntityOptional.get().getId().toString();
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId()));
Optional<SysUserEntity> userEntityOptional = userList.stream()
.filter(user -> Objects.equals(regionEntity.getId(), sysRegionService.getByLevel(sysDeptService.get(user.getDeptId()).getDistrict(), RegionLevelEnum.THREE).getId())).findFirst();
if (userEntityOptional.isPresent()) {
userId = userEntityOptional.get().getId().toString();
}
}
if (userId != null) {
logger.error("审批人id:" + userId);
taskService.setAssignee(delegateTask.getId(), userId);
assignee = userId;
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
}
logger.error("分配的用户id为:{}", assignee);
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
try {
logger.error("流程参数异常" + JSON.toJSONString(kv));
} catch (Exception exception) {
logger.error("流程参数异常", exception);
}
}
logger.error("分配的用户id为:{}", assignee);
}
@Override

View File

@ -1,12 +1,8 @@
package io.renren.modules.processForm.listener.v3;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import io.renren.common.annotation.ActivitiNoticeOperation;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.sys.dao.SysUserDao;
import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysRoleDTO;
@ -75,34 +71,42 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv
private void create(DelegateTask delegateTask) {
String assignee;
Map<String, Object> kv = delegateTask.getVariables();
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
Gson gson = builder.create();
JsonElement jsonElement = gson.toJsonTree(kv);
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
if (kv.containsKey("userId")) {
Long applyUserId = Long.valueOf(kv.get("userId").toString());
SysDeptDTO deptDTO = sysDeptService.get(sysUserService.get(applyUserId).getDeptId());
SysDeptDTO deptDTO = sysDeptService.get(sysUserService.get(Long.parseLong(abilityApplicationDTO.getUserId())).getDeptId());
String userId = null;
if (deptDTO.getDistrict() != null) {
SysRegionEntity regionEntity = sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.TWO);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
SysRegionEntity regionEntity = sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.TWO);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId()));
Optional<SysUserEntity> userEntityOptional = userList.stream()
.filter(user -> Objects.equals(regionEntity.getId(), sysRegionService.getByLevel(sysDeptService.get(user.getDeptId()).getDistrict(), RegionLevelEnum.TWO).getId())).findFirst();
if (userEntityOptional.isPresent()) {
logger.error("审批人id:" + userEntityOptional.get().getId());
taskService.setAssignee(delegateTask.getId(), userEntityOptional.get().getId().toString());
assignee = userEntityOptional.get().getId().toString();
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId()));
Optional<SysUserEntity> userEntityOptional = userList.stream()
.filter(user -> Objects.equals(regionEntity.getId(), sysRegionService.getByLevel(sysDeptService.get(user.getDeptId()).getDistrict(), RegionLevelEnum.TWO).getId())).findFirst();
if (userEntityOptional.isPresent()) {
userId = userEntityOptional.get().getId().toString();
}
}
if (userId != null) {
logger.error("审批人id:" + userId);
taskService.setAssignee(delegateTask.getId(), userId);
assignee = userId;
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
}
logger.error("分配的用户id为:{}", assignee);
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
try {
logger.error("流程参数异常" + JSON.toJSONString(kv));
} catch (Exception exception) {
logger.error("流程参数异常", exception);
}
}
logger.error("分配的用户id为:{}", assignee);
}
@Override

View File

@ -1,12 +1,8 @@
package io.renren.modules.processForm.listener.v3;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import io.renren.common.annotation.ActivitiNoticeOperation;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.sys.dao.SysUserDao;
import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysRoleDTO;
@ -72,34 +68,41 @@ public class OwnerDistrictListener implements TaskListener, ExecutionListener, A
private void create(DelegateTask delegateTask) {
String assignee;
Map<String, Object> kv = delegateTask.getVariables();
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
Gson gson = builder.create();
JsonElement jsonElement = gson.toJsonTree(kv);
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
if (kv.containsKey("deptId")) { // 存在部门id
Long deptId = Long.valueOf(kv.get("deptId").toString());
SysDeptDTO deptDTO = sysDeptService.get(deptId);
SysDeptDTO deptDTO = abilityApplicationDTO.getResourceOwnerDept();
SysRegionEntity regionEntity = sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.THREE);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId()));
Optional<SysUserEntity> userEntityOptional = userList.stream()
.filter(user -> Objects.equals(regionEntity.getId(), sysRegionService.getByLevel(sysDeptService.get(user.getDeptId()).getDistrict(), RegionLevelEnum.THREE).getId())).findFirst();
if (userEntityOptional.isPresent()) {
logger.error("审批人id:" + userEntityOptional.get().getId());
taskService.setAssignee(delegateTask.getId(), userEntityOptional.get().getId().toString());
assignee = userEntityOptional.get().getId().toString();
String userId = null;
if (deptDTO.getDistrict() != null) {
SysRegionEntity regionEntity = sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.THREE);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId()));
Optional<SysUserEntity> userEntityOptional = userList.stream()
.filter(user -> Objects.equals(regionEntity.getId(), sysRegionService.getByLevel(sysDeptService.get(user.getDeptId()).getDistrict(), RegionLevelEnum.THREE).getId())).findFirst();
if (userEntityOptional.isPresent()) {
userId = userEntityOptional.get().getId().toString();
}
}
if (userId != null) {
logger.error("审批人id:" + userId);
taskService.setAssignee(delegateTask.getId(), userId);
assignee = userId;
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
}
logger.error("分配的用户id为:{}", assignee);
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
try {
logger.error("流程参数异常" + JSON.toJSONString(kv));
} catch (Exception exception) {
logger.error("流程参数异常", exception);
}
}
logger.error("分配的用户id为:{}", assignee);
}
@Override

View File

@ -1224,64 +1224,64 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
if (list.isEmpty() || list.size() < pageSize) {
end.set(false);
}
customThreadPool.submit(() -> {
list.parallelStream().filter(resource -> {
Map<String, Object> map = (Map<String, Object>) resource;
return !knowledgeUUID.contains(map.get("uuid").toString());
}).forEach(resource -> {
Map<String, Object> map = (Map<String, Object>) resource;
ResourceDTO dto = new ResourceDTO();
dto.setName(map.get("title").toString());
dto.setType("知识库");
dto.setVisits(0L);
//所属部门暂时设为青岛市政府办公厅
dto.setDeptId(1517116100113850370L);
dto.setNote1(map.get("uuid").toString());
dto.setDelFlag(0);
ArrayList<AttrEntity> infoList = new ArrayList<>();
map.forEach((key, value) -> {
switch (key) {
case "title":
dto.setName(value.toString());
break;
case "url":
dto.setLink(value.toString());
break;
case "createtime":
Date createDate = new Date(Long.parseLong(value.toString()));
dto.setCreateDate(createDate);
break;
default:
AttrEntity attrEntity = new AttrEntity();
attrEntity.setDelFlag(0);
attrEntity.setAttrType(key);
attrEntity.setAttrValue(value.toString());
infoList.add(attrEntity);
break;
}
});
AttrEntity attrEntity = new AttrEntity();
attrEntity.setDelFlag(0);
attrEntity.setAttrType("文件类型");
if ("f49561afc7204f008c4bb3cd821eb6ba".equals(index)) {
attrEntity.setAttrValue("政府公报");
} else {
attrEntity.setAttrValue("政策解读");
customThreadPool.submit(() -> list.parallelStream().filter(resource -> {
Map<String, Object> map = (Map<String, Object>) resource;
return !knowledgeUUID.contains(map.get("uuid").toString());
}).forEach(resource -> {
Map<String, Object> map = (Map<String, Object>) resource;
ResourceDTO dto = new ResourceDTO();
dto.setName(map.get("title").toString());
dto.setType("知识库");
dto.setVisits(0L);
//所属部门暂时设为青岛市政府办公厅
dto.setDeptId(1517116100113850370L);
dto.setNote1(map.get("uuid").toString());
dto.setDelFlag(0);
ArrayList<AttrEntity> infoList = new ArrayList<>();
map.forEach((key, value) -> {
switch (key) {
case "title":
dto.setName(value.toString());
break;
case "url":
dto.setLink(value.toString());
break;
case "createtime":
Date createDate = new Date(Long.parseLong(value.toString()));
dto.setCreateDate(createDate);
break;
default:
AttrEntity attrEntity = new AttrEntity();
attrEntity.setDelFlag(0);
attrEntity.setAttrType(key);
attrEntity.setAttrValue(value.toString());
infoList.add(attrEntity);
break;
}
infoList.add(attrEntity);
dto.setInfoList(infoList);
this.insertWithAttrs(dto);
logger.info("插入:{}", dto.getName());
});
}).join();
AttrEntity attrEntity = new AttrEntity();
attrEntity.setDelFlag(0);
attrEntity.setAttrType("文件类型");
if ("f49561afc7204f008c4bb3cd821eb6ba".equals(index)) {
attrEntity.setAttrValue("政府公报");
} else {
attrEntity.setAttrValue("政策解读");
}
infoList.add(attrEntity);
dto.setInfoList(infoList);
this.insertWithAttrs(dto);
logger.info("插入:{}", dto.getName());
})).join();
customThreadPool.shutdown();
}, executor));
try {
Thread.sleep(100L); // 防止任务运行过快无法跳出循环
Thread.sleep(100); // 防止任务运行过快无法跳出循环
} catch (InterruptedException e) {
logger.info("知识库同步异常", e);
// throw new RuntimeException(e);
}
} while (end.get() || pageIndex.get() < maxPage.get());
return task;
}).collect(Collectors.toList());
@ -1867,6 +1867,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
if (abilityApplicationDTO != null && org.apache.commons.lang3.StringUtils.isNotEmpty(abilityApplicationDTO.getSystem()) && org.apache.commons.lang3.StringUtils.isEmpty(his.getName())) {
resourceIds.add(Long.parseLong(abilityApplicationDTO.getResourceId()));
} else {
// TODO 有问题
if (his.getBusinessKey().startsWith("[") && his.getBusinessKey().endsWith("]")) {
continue;
}
TAbilityApplicationDTO abilityApplicationDTO1 = tAbilityApplicationService.getByBusinessKey(his.getBusinessKey());
if (abilityApplicationDTO1 != null) {
resourceIds.add(Long.parseLong(abilityApplicationDTO1.getResourceId()));

View File

@ -381,7 +381,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
if (m.get(("username")) != null) {
String userName = m.get("username").toString();
SysUserEntity user = sysUserDao.getUserByName(userName);
if (user == null) {//用户表中没有该用户插入
SysUserEntity userById = sysUserDao.getById(Long.valueOf(m.get("id").toString()));
if (user == null && userById == null) {//用户表中没有该用户插入
SysUserEntity newUser = new SysUserEntity();
newUser.setUsername(userName);
newUser.setSuperAdmin(0);
@ -390,6 +391,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
newUser.setRealName(m.get("real_name") == null ? "" : m.get("real_name").toString());
newUser.setEmail(m.get("email") == null ? "" : m.get("email").toString());
newUser.setMobile(m.get("mobile") == null ? "" : m.get("mobile").toString());
newUser.setYwMobile(m.get("ywMobile") == null ? "" : m.get("ywMobile").toString());
newUser.setStatus(1);//账号状态 1正常 0停用
//给dept_id赋值
String deptNames = m.get("distinguishedName") == null ? "" : m.get("distinguishedName").toString();

View File

@ -37,7 +37,9 @@ server:
session:
cookie:
http-only: true
compression:
enabled: true
mime-types: application/json
spring:
# 环境 dev|test|prod|show
profiles:

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
alter table sys_user add column yw_mobile varchar(100);

View File

@ -116,7 +116,7 @@
sd.type AS "deptType",
sd.sort AS "deptSort",
sr.sort AS "regionSort",
IFNULL(taa2.approve_status, '未申请') AS "applyState",
IF( IFNULL(taa2.approve_status, 0) &lt; 1, '未申请', '已申请' ) AS "applyState",
IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount",
@ -412,7 +412,7 @@
sd.sort AS "deptSort",
sr.sort AS "regionSort",
IFNULL(trc2.isCollect, 'false') AS "isCollect",
IFNULL(taa2.approve_status, '未申请') AS "applyState",
IF( IFNULL(taa2.approve_status, 0) &lt; 1, '未申请', '已申请' ) AS "applyState",
IF ( IFNULL( trcar.car, 0 ) &gt; 0, TRUE, FALSE ) AS "isInShoppingCart",
IF( IFNULL(taa3.approve_status, 0) &lt; 1, '未通过', '通过' ) AS "approveStatus"
FROM

View File

@ -100,14 +100,18 @@ public class JhlDAPTool {
user.put("email",next.get().toString());
}else if("telephoneNumber".equals(next.getID())){
user.put("mobile",next.get().toString());
}else if("mobile".equals(next.getID())){
user.put("ywMobile",next.get().toString());
}else if("distinguishedName".equals(next.getID())){
user.put("distinguishedName",next.get().toString());
}else if("objectGUID".equals(next.getID())){
String guidStr = next.getID().toString();
user.put("id",SingleID.getSingleID(guidStr));
String guid = guidStr.substring(1,guidStr.length()-1);
user.put("guid",guid);
String guidStr = next.get().toString();
//Object o = next.get(0);
String guid = guidObject2String((byte[]) next.get(0));
user.put("id",SingleID.getSingleID(guid));
user.put("guid",guid);
}
}
lm.add(user);
@ -125,6 +129,72 @@ public class JhlDAPTool {
return lm;
}
private String guidObject2String(byte[] b){
StringBuilder builder = new StringBuilder();
for (int i = 3; i >=0; i--)
{
String hex = Integer.toHexString(b[i] & 0xFF);
if (hex.length() == 1)
{
hex = '0' + hex;
}
builder.append(hex);
}
builder.append('-');
for (int i = 5; i >=4; i--)
{
String hex = Integer.toHexString(b[i] & 0xFF);
if (hex.length() == 1)
{
hex = '0' + hex;
}
builder.append(hex);
}
builder.append('-');
for (int i = 7; i >=6; i--)
{
String hex = Integer.toHexString(b[i] & 0xFF);
if (hex.length() == 1)
{
hex = '0' + hex;
}
builder.append(hex);
}
builder.append('-');
// for (int i = 8; i <9; i++)
// {
// String hex = Integer.toHexString(b[i] & 0xFF);
// if (hex.length() == 1)
// {
// hex = '0' + hex;
// }
// builder.append(hex);
// }
// builder.append('-');
for (int i = 8; i <10; i++)
{
String hex = Integer.toHexString(b[i] & 0xFF);
if (hex.length() == 1)
{
hex = '0' + hex;
}
builder.append(hex);
}
builder.append('-');
for (int i = 10; i <16; i++)
{
String hex = Integer.toHexString(b[i] & 0xFF);
if (hex.length() == 1)
{
hex = '0' + hex;
}
builder.append(hex);
}
return builder.toString().toUpperCase();
}
/**
* 获取管理部门信息
* @param ctx