Compare commits

...

3 Commits
master ... show

Author SHA1 Message Date
wangliwen 259ac18110 ... 2022-11-03 15:13:35 +08:00
wangliwen f67410ddf3 投标演示上线能力流程 2022-11-03 15:09:31 +08:00
dinggang b33527cf6c Merge branch 'dev' of http://221.0.232.152:9393/ability-center/share-platform into show
# Conflicts:
#	renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java
2022-11-02 13:58:00 +08:00
8 changed files with 416 additions and 17 deletions

View File

@ -0,0 +1,167 @@
package io.renren.common.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.renren.common.annotation.LogOperation;
import io.renren.common.page.PageData;
import io.renren.common.utils.CodeGenerationUtils;
import io.renren.common.utils.Result;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
import io.renren.modules.activiti.dto.ProcessInstanceDTO;
import io.renren.modules.activiti.dto.ProcessStartDTO;
import io.renren.modules.activiti.service.ActProcessService;
import io.renren.modules.activiti.service.ActRunningService;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resourceMountApply.dto.TResourceBatchMountApplyDTO;
import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO;
import io.renren.modules.resourceMountApply.service.TResourceMountApplyService;
import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskQuery;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.stream.Collectors;
@Api(tags = "资源上架")
@RestController
@RequestMapping("/resource/center")
public class ResourceMountShowController {
private static final Logger logger = LoggerFactory.getLogger(ResourceMountShowController.class);
private static final ObjectMapper oMapper = new ObjectMapper();
@Autowired
private ActProcessService actProcessService;
@Autowired
private ActRunningService actRunningService;
@Autowired
private TResourceMountApplyService tResourceMountApplyService;
@Autowired
private ResourceService resourceService;
@Autowired
private SysUserService sysUserService;
private final CodeGenerationUtils codeGenerationUtils = CodeGenerationUtils.getInstance();
@Autowired
protected TaskService taskService;
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private SysDeptService sysDeptService;
@Value("${big_date.name}")
private String bigDateDeptName; // 大数据局名称
private static final String APPLY_KEY = "resourcemountapply_show"; // 资源上架
private static final String UNDERCARRIAGE_KEY = "resourcundercarriageapply"; // 资源下架
private static final Map<String, Object> apply_params = new HashMap<String, Object>() {
{
put("isLatestVersion", true); // 取最新版本
put("key", APPLY_KEY); // 限定 能力资源上架
}
};
private static final Map<String, Object> undercarriage_params = new HashMap<String, Object>() {
{
put("isLatestVersion", true); // 取最新版本
put("key", UNDERCARRIAGE_KEY); // 限定 资源下架
}
};
@PostMapping(value = "/apply_show")
@ApiOperation("批量进行能力上架申请")
@LogOperation("批量进行能力上架申请")
public Result<List<ProcessInstanceDTO>> apply(@RequestBody TResourceBatchMountApplyDTO tResourceBatchMountApplyDTO) {
// 仿照请求接口 /act/process/lastestPage
PageData<Map<String, Object>> page = actProcessService.page(apply_params);
if (page.getTotal() <= 0) { //
return new Result().error("联系管理员添加流程");
}
logger.info("---------------------------------------------------");
logger.info(JSONObject.toJSONString(tResourceBatchMountApplyDTO));
logger.info("####################################################");
return new Result().ok(tResourceBatchMountApplyDTO.getResourceDTO().stream().map(index -> {
TResourceMountApplyDTO tResourceMountApplyDTO = new TResourceMountApplyDTO();
tResourceMountApplyDTO.setPhone(tResourceBatchMountApplyDTO.getPhone());
tResourceMountApplyDTO.setDeptId(tResourceBatchMountApplyDTO.getDeptId());
tResourceMountApplyDTO.setUserId(tResourceBatchMountApplyDTO.getUserId());
tResourceMountApplyDTO.setUserName(tResourceBatchMountApplyDTO.getUserName());
tResourceMountApplyDTO.setParameterContent(JSON.toJSONString(index));
tResourceMountApplyDTO.setParameterContentMd5(SecureUtil.md5(JSON.toJSONString(index)));
tResourceMountApplyDTO.setResourceDTO(index);
tResourceMountApplyDTO.setEnclosure(index.getEnclosure());
tResourceMountApplyDTO.setFlowType("资源上架");
try {
tResourceMountApplyDTO.setResourceId(tResourceMountApplyDTO.getResourceDTO().getId());
} catch (Exception e) {
logger.error("资源上架异常", e);
}
if (StringUtils.isEmpty(tResourceBatchMountApplyDTO.getDeptId())) {
Optional<SysUserDTO> userDTO = Optional.ofNullable(sysUserService.get(Long.valueOf(tResourceBatchMountApplyDTO.getUserId())));
userDTO.ifPresent(user -> {
if (user.getSuperAdmin() == 1) {
SysDeptDTO deptDTO = sysDeptService.getByName(bigDateDeptName);
tResourceMountApplyDTO.setDeptId(deptDTO.getId().toString());
}
});
}
ValidatorUtils.validateEntity(tResourceMountApplyDTO, AddGroup.class, DefaultGroup.class);
tResourceMountApplyService.save(tResourceMountApplyDTO); // 保存单条资源申请记录
if (tResourceMountApplyDTO.getId() == null) {
return null;
}
codeGenerationUtils.setApplyNumber("NLSJ", Arrays.asList(tResourceMountApplyDTO.getId()), jdbcTemplate);
TaskQuery taskQuery = taskService.createTaskQuery();
Task task = taskQuery.active().processInstanceBusinessKey(tResourceMountApplyDTO.getId().toString()).singleResult();
if (task != null) {
logger.error("该资源已发起上架");
throw new RuntimeException("该资源已发起上架");
}
tResourceMountApplyDTO.setCompleteEntry(Boolean.TRUE);
logger.info("-------------------1.保存申请表单成功--------------------------");
// 仿照请求接口 /act/running/startOfBusinessKey
ProcessStartDTO processStartDTO = new ProcessStartDTO();
processStartDTO.setBusinessKey(tResourceMountApplyDTO.getId().toString());
processStartDTO.setProcessDefinitionKey(APPLY_KEY); // 限定资源上架
Map<String, Object> variables = oMapper.convertValue(tResourceMountApplyDTO, Map.class);
processStartDTO.setVariables(variables);
ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO);
logger.info("-------------------2.启动流程成功--------------------------");
logger.info("ProcessInstanceDTO.getBusinessKey:{}", dto.getBusinessKey());
if (Long.valueOf(dto.getBusinessKey()) != null) {
// 仿照请求接口 /processForm/tabilityapplication/updateInstanceId
tResourceMountApplyService.updateInstanceId(dto.getProcessInstanceId(), Long.valueOf(dto.getBusinessKey()));
logger.info("-------------------更新updateInstanceId.成功--------------------------");
logger.info("ProcessInstanceDTO.getProcessInstanceId:{}", dto.getProcessInstanceId());
}
return dto;
}).filter(ObjectUtil::isNotNull).collect(Collectors.toList()));
}
}

View File

@ -635,7 +635,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}).thenAccept(sum -> re.add(new HashMap<String, Object>() {
{
put("count", sum + "");
put("type", "基础设施");
put("type", "视频资源");//演示版本临时改名为视频资源
//put("type", "基础设施");
}
}));
Long total;
@ -678,7 +679,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
QueryWrapper<CameraChannel> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("check_status", 1).ne("gps_x", "").ne("gps_y", "").isNotNull("gps_x").isNotNull("gps_y");
put("count", cameraChannelMapper.selectCount(queryWrapper) + "");
put("type", "基础设施");
put("type", "视频资源");
//put("type", "基础设施");
}
});
@ -687,7 +689,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
default:
break;
}
List<String> temp = new ArrayList<>();
/*List<String> temp = new ArrayList<>();
re.forEach(map -> temp.add(map.get("type").toString()));
Arrays.stream(censusTypes).filter(index -> !temp.contains(index)).forEach(index -> { // 数据库内不存在的资源类型
Map<String, Object> nullMap = new HashMap<String, Object>() {
@ -697,7 +699,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
};
re.add(nullMap);
});
});*/
resultMap.put("total", re);
return resultMap;

View File

@ -0,0 +1,194 @@
package io.renren.modules.resourceMountApply.listener.show;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import io.renren.modules.processForm.service.ApiGateway;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.ResourceEntityDelFlag;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO;
import io.renren.modules.sys.dto.SysRoleDTO;
import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysRoleService;
import io.renren.modules.sys.service.SysUserService;
import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.*;
import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;
/**
* 资源所有者节点审批
*/
@Component
public class ResourceOwnerShowListener implements TaskListener, ExecutionListener, ActivitiEventListener, JavaDelegate {
private static Logger logger = LoggerFactory.getLogger(ResourceOwnerShowListener.class);
@Value("${big_date.name}")
private String bigDateDeptName; // 大数据局名称
@Value("${big_date.default_assignee_role_id}")
private String defaultAssigneeRoleId; // 当某部门未设置部门审批人时将使用该用户审批
@Value("${big_date.assignee_role_name}")
private String roleName; // 具备审批的角色名称
@Autowired
private SysRoleService sysRoleService;
@Autowired
private TaskService taskService;
@Autowired
private SysUserService sysUserService;
@Resource(name = "${hisense.gateway.name}")
private ApiGateway apiGateway;
@Autowired
private SysDeptService sysDeptService;
@Autowired
private ResourceService resourceService;
@Override
public void notify(DelegateExecution execution) throws Exception {
logger.error("----------------------进入审批通过节点---------------------------");
logger.error("事件类型:" + execution.getEventName());
final String eventName = execution.getEventName();
switch (eventName) {
case EVENTNAME_END: {
endTake(execution.getVariables());
}
break;
}
}
@Override
public void execute(DelegateExecution execution) throws Exception {
}
@Override
public void notify(DelegateTask delegateTask) {
logger.error("----------------------进入资源所有者节点---------------------------");
logger.error("事件类型:" + delegateTask.getEventName());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
final String eventName = delegateTask.getEventName();
switch (eventName) {
case EVENTNAME_CREATE: // 创建当前审批节点事件
create(delegateTask);
break;
case EVENTNAME_COMPLETE:
complete(delegateTask);
break;
default:
logger.error("未处理该事件:" + eventName);
}
logger.error("-----------------------结束资源所有者节点---------------------------");
}
/**
* Called when an event has been fired
*
* @param event the event
*/
@Override
public void onEvent(ActivitiEvent event) {
}
/**
* @return whether or not the current operation should fail when this listeners execution
* throws an exception.
*/
@Override
public boolean isFailOnException() {
return false;
}
/**
* 进入最后结束节点
*
* @param kv
*/
private void endTake(Map<String, Object> kv) { // 进入最后结束节点
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);
TResourceMountApplyDTO resourceMountApplyDTO = gson.fromJson(jsonElement, TResourceMountApplyDTO.class);
ResourceDTO re = resourceService.get(resourceMountApplyDTO.getResourceId());
if (resourceMountApplyDTO != null) {
if (resourceMountApplyDTO.getReject() != null && resourceMountApplyDTO.getReject() == Boolean.TRUE) { // 存在被拒绝的节点
if (re != null) {
re.setDelFlag(ResourceEntityDelFlag.REJECT_REVIEW.getFlag());
resourceService.update(re);
logger.error("审批未通过资源id:" + re.getId());
}
return;
}
if (resourceMountApplyDTO.getReject() == null || resourceMountApplyDTO.getReject() != Boolean.TRUE) { // 都是同意
if (re != null) {
re.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
resourceService.update(re);
logger.error("审批通过资源id:" + re.getId());
try {
apiGateway.registerApi2Gateway(String.valueOf(re.getId())); // 发布到应用网关
} catch (Exception exception) {
logger.error("发布到应用网关", exception);
}
}
}
} else {
logger.error("能力上架资源信息故障-->" + JSON.toJSONString(kv));
}
}
/**
* 流程结束推送
*
* @param delegateTask
*/
private void complete(DelegateTask delegateTask) {
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);
TResourceMountApplyDTO resourceMountApplyDTO = gson.fromJson(jsonElement, TResourceMountApplyDTO.class);
ResourceDTO re = resourceMountApplyDTO.getResourceDTO();
if (re != null) {
re.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
resourceService.update(re);
}
}
/**
* 节点创建时分配发起人为审核人
*
* @param delegateTask
*/
private void create(DelegateTask delegateTask) {
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);
TResourceMountApplyDTO resourceMountApplyDTO = gson.fromJson(jsonElement, TResourceMountApplyDTO.class);
logger.error(JSONObject.toJSONString(resourceMountApplyDTO));
taskService.setAssignee(delegateTask.getId(), resourceMountApplyDTO.getUserId());
}
}

View File

@ -6,9 +6,13 @@ spring:
#MySQL
driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://192.168.124.236:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
# url: jdbc:mysql://localhost:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
url: jdbc:mysql://192.168.124.46:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
username: root
# password: 123456
password: Liwen073898!
# password: Hisense2019
#Hisense2019
# #Oracle
# driver-class-name: oracle.jdbc.OracleDriver

View File

@ -5,7 +5,7 @@ spring:
druid:
#MySQL
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
url: jdbc:mysql://127.0.0.1:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: root
# driver-class-name: com.mysql.cj.jdbc.Driver

View File

@ -4,10 +4,16 @@ spring:
datasource:
druid:
#MySQL
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.124.236:3310/share_platform_show?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
url: jdbc:mysql://192.168.124.236:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
# url: jdbc:mysql://localhost:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
# url: jdbc:mysql://192.168.124.46:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
username: root
# password: 123456
# password: Liwen073898!
password: Hisense2019
#Hisense2019
# #Oracle
# driver-class-name: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@192.168.10.10:1521:xe
@ -23,14 +29,17 @@ spring:
# url: jdbc:postgresql://192.168.10.10:5432/postgres
# username: postgres
# password: 123456
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 10
initial-size: 50
max-active: 1000
min-idle: 100
max-wait: 100
removeAbandoned: true
removeAbandonedTimeout: 300
logAbandoned: false
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
min-evictable-idle-time-millis: 60000
#Oracle需要打开注释
validation-query: SELECT 1
test-while-idle: true
@ -49,24 +58,40 @@ spring:
wall:
config:
multi-statement-allow: true
flyway:
enabled: true
validate-on-migrate: false
# 允许乱序执行
out-of-order: true
#上传的静态资源配置
resource:
root_url: 192.168.124.236
pic-host: http://${resource.root_url}:${server.port}${server.servlet.context-path}
path: /home/yth/files/
devModelFilePath: /home/yth/files/devModelFile
# 大数据部门相关配置
# 大数据部门相关配置(平台部署部门)
big_date:
name: 青岛市大数据发展管理局
assignee_role_name: 部门审批人
assignee_district_role_name: 区审批人
assignee_city_role_name: 市审批人
# 平台部署级别 (PROVINCE:省 PREFECTURE:地级市 DISTRICT:区县 STREET:街道)
stage: PREFECTURE
hisense:
gateway:
name: 聚好看网关
url: http://devtest-security-app.hismarttv.com:8080
qdyjj:
ipAndPort: 15.2.21.238:9015
yawei:
enable: false
sso:
mode:
##多数据源的配置需要引用renren-dynamic-datasource
#dynamic:
@ -80,4 +105,11 @@ qdyjj:
# driver-class-name: org.postgresql.Driver
# url: jdbc:postgresql://123456:5432/security_enterprise
# username: postgres
# password: 123456
# password: 123456
#同步摄像头标签表t_channel_mtm_label需要链接的数据库配置
synchro:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://15.2.21.238:3310/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
username: root
password: Hisense2019

View File

@ -5,7 +5,7 @@ spring:
druid:
#MySQL
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.124.243:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
url: jdbc:mysql://192.168.124.46:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
username: root
password: Liwen073898!
initial-size: 10
@ -37,7 +37,7 @@ spring:
#上传的静态资源配置
resource:
root_url: 192.168.124.243
root_url: 192.168.124.46
path: /home/yth/files/
devModelFilePath: /home/yth/files/devModelFile
# 大数据部门相关配置

View File

@ -46,7 +46,7 @@ server:
spring:
# 环境 dev|test|prod|show
profiles:
active: dev
active: show
messages:
encoding: UTF-8
basename: i18n/messages