* 'master' of http://221.0.232.152:9393/ability-center/share-platform: (82 commits)
  需求接口出评论数目
  ...
  兼容已经重复提交过下架的资源
  ...
  资源重复下线错误提示
  资源重复下架
  ....
  被覆盖?
  。。。
  ...
  该资源已发起下架,重复发起下架时 抛出异常
  ...
  ...
  统计资源访问量
  ...
  我的待办查出流转状态
  资源下架申请中状态仍然为正常
  指定编译目标为jdk1.8
  能力申请若为大数据负责人申请,大数据级别申请默认通过;若申请者为资源所属部门审批人,默认通过;
  我的待办只出仍然在运行的任务
  ...

# Conflicts:
#	renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java
This commit is contained in:
huangweixiong 2022-05-24 15:33:26 +08:00
commit 042ed549f5
68 changed files with 2302 additions and 218 deletions

View File

@ -32,6 +32,7 @@
<renren.version>2.9.0</renren.version>
<groovy-all.version>2.4.17</groovy-all.version>
<pinyin4j.version>2.5.1</pinyin4j.version>
<java.version>1.8</java.version>
</properties>
<dependencies>
@ -259,7 +260,7 @@
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
<Class-Path>. lib/yawei-pso-2.0.2.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
@ -286,6 +287,13 @@
<descriptors>
<descriptor>src/main/resources/assembly/assembly.xml</descriptor>
</descriptors>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>libs/</classpathPrefix>
</manifest>
</archive>
</configuration>
</execution>
</executions>

View File

@ -90,6 +90,7 @@ public class AbilityCenterController {
if (tAbilityApplicationDTO.getId() == null) {
return null;
}
tAbilityApplicationDTO.setCompleteEntry(Boolean.TRUE);
// 仿照请求接口 /act/running/startOfBusinessKey
ProcessStartDTO processStartDTO = new ProcessStartDTO();

View File

@ -1,8 +1,11 @@
package io.renren.common.controller;
import com.alibaba.fastjson.JSONObject;
import io.renren.common.annotation.LogOperation;
import io.renren.common.utils.Result;
import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -10,9 +13,7 @@ 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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.concurrent.CompletableFuture;
@ -32,9 +33,13 @@ public class CensusController {
private ResourceService resourceService;
@Autowired
private SysUserService sysUserService;
@Autowired
private TAbilityApplicationService tAbilityApplicationService;
@Autowired
private ResourceBrowseService resourceBrowseService;
@Value("${census.type}")
private String[] censusTypes; // 大数据局名称
private String[] censusTypes; // 需要进行统计的资源类型
/**
@ -70,18 +75,107 @@ public class CensusController {
@GetMapping(value = "/whole_amount")
@ApiOperation("平台整体情况")
public Result<List<Map<String, Object>>> wholeAmount() {
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
CompletableFuture<Long> resourceAmount = CompletableFuture.supplyAsync(() -> { // 获取资源汇聚总量
List<Map<String, Object>> result = Collections.synchronizedList(new ArrayList<>());
CompletableFuture<Void> resourceAmount = CompletableFuture.supplyAsync(() -> { // 获取资源汇聚总量
List<Map<String, Object>> dbAmount = resourceService.getAmountGroupByType();
Long sum = dbAmount.stream().mapToLong(index -> Long.valueOf(index.get("amount").toString())).sum();
return sum;
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "资源汇聚总量");
}
});
CompletableFuture<Long> userAmount = CompletableFuture.supplyAsync(() -> { // 获取平台用户总数
});
CompletableFuture<Void> userAmount = CompletableFuture.supplyAsync(() -> { // 获取平台用户总数
return sysUserService.countAllUser();
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "用户量");
}
});
});
CompletableFuture<Void> all = CompletableFuture.allOf(resourceAmount, userAmount);
all.join();
CompletableFuture<Void> applyAmount = CompletableFuture.supplyAsync(() -> { // 资源申请量
return tAbilityApplicationService.countApplyAll();
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "资源申请量");
}
});
});
CompletableFuture<Void> deptAmount = CompletableFuture.supplyAsync(() -> { // 覆盖部门量
return resourceService.countAllDept();
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "覆盖部门量");
}
});
});
CompletableFuture<Void> pvAmount = CompletableFuture.supplyAsync(() -> { // 平台访问量
return resourceService.countAllVisits();
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "平台访问量");
}
});
});
CompletableFuture<Void> all = CompletableFuture.allOf(resourceAmount, userAmount, applyAmount, deptAmount, pvAmount);
all.join();
result.sort(Comparator.comparing(x -> x.get("type").toString()));
return new Result<List<Map<String, Object>>>().ok(result);
}
@GetMapping(value = "/apply_amount")
@ApiOperation("各类资源申请成功数目")
public Result<List<Map<String, Object>>> applyAmount() {
List<Map<String, Object>> dbAmount = tAbilityApplicationService.getAmountGroupByType();
List<String> temp = dbAmount.stream().map(index -> index.get("type").toString()).collect(Collectors.toList());
Arrays.stream(censusTypes).filter(index -> !temp.contains(index)).forEach(index -> { // 数据库内不存在的资源类型
Map<String, Object> nullMap = new HashMap<String, Object>() {
{
put("amount", 0);
put("type", index);
}
};
dbAmount.add(nullMap);
});
return new Result<List<Map<String, Object>>>().ok(dbAmount);
}
@PostMapping("/trafficStatistics")
@ApiOperation("浏览量统计")
@LogOperation("浏览量统计")
public Result trafficStatistics(@RequestBody JSONObject jsonObject) {
HashMap<String, Object> resultMap = new HashMap<>();
String startDate = jsonObject.getString("startDate");
String endDate = jsonObject.getString("endDate");
resultMap.put("browseAvg", resourceBrowseService.selectDayAvg());
resultMap.put("browseMax", resourceBrowseService.selectDayMax());
resultMap.put("browseDayList", resourceBrowseService.selectDayList(startDate, endDate));
return new Result().ok(resultMap);
}
@GetMapping("/sourceDepartmentStatistics")
@ApiOperation("来源部门统计")
@LogOperation("来源部门统计")
public Result sourceDepartmentStatistics() {
return new Result().ok(resourceService.selectSourceDepartmentStatistics());
}
}

View File

@ -12,6 +12,7 @@ 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.demanData.dto.TDemandDataDTO;
import io.renren.modules.demanData.entity.TDemandDataEntityFlag;
import io.renren.modules.demanData.service.TDemandDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -60,14 +61,14 @@ public class DemandDataController {
logger.info("---------------------------------------------------");
logger.info(JSONObject.toJSONString(tDemandDataDTO));
logger.info("####################################################");
tDemandDataDTO.setFlag(1);
tDemandDataDTO.setFlag(TDemandDataEntityFlag.UNDER_REVIEW.getFlag());
ValidatorUtils.validateEntity(tDemandDataDTO, AddGroup.class, DefaultGroup.class);
tDemandDataService.save(tDemandDataDTO);
if (tDemandDataDTO.getId() == null) {
return null;
}
tDemandDataDTO.setCompleteEntry(Boolean.TRUE);
logger.info("-------------------1.保存申请表单成功--------------------------");
// 仿照请求接口 /act/running/startOfBusinessKey
ProcessStartDTO processStartDTO = new ProcessStartDTO();

View File

@ -0,0 +1,71 @@
package io.renren.common.controller;
import com.alibaba.fastjson.JSON;
import io.renren.common.utils.Result;
import io.renren.modules.activiti.service.ActTaskService;
import io.renren.modules.sys.dto.SysUserDTO;
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.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
@Api(tags = "前台流程驳回")
@RestController
@RequestMapping("/reject/center")
public class RejectController {
private static Logger logger = LoggerFactory.getLogger(RejectController.class);
@Autowired
protected TaskService taskService;
@Autowired
private ActTaskService actTaskService;
@Autowired
private SysUserService sysUserService;
@PostMapping("relaunch/{taskId}")
@ApiOperation("携带更新后的表单重新发起流程")
public Result relaunch(@PathVariable("taskId") String taskId, @RequestBody Map<String, Object> params) {
if (StringUtils.isEmpty(taskId)) {
return new Result().error("流程taskId未传参");
}
AtomicReference<Result> result = new AtomicReference<>(new Result().error("重新发起流程失败"));
Optional<Task> taskOptional = Optional.ofNullable(taskService.createTaskQuery().taskId(taskId).includeProcessVariables().singleResult());
taskOptional.ifPresent(task -> {
Map<String, Object> combineResultMap = new LinkedHashMap<>();
// combineResultMap.putAll(task.getProcessVariables());
combineResultMap.putAll(params);
if (combineResultMap.containsKey("parameterContent")) { // 上架申请特殊处理
combineResultMap.remove("parameterContent");
combineResultMap.remove("resourceDTO");
combineResultMap.put("parameterContent", JSON.toJSONString(combineResultMap));
}
taskService.removeVariable(task.getId(), "parameterContent");
taskService.removeVariable(task.getId(), "resourceDTO");
taskService.setVariables(task.getId(), combineResultMap); // 更新
logger.error("-----------" + JSON.toJSONString(combineResultMap));
taskService.setVariable(task.getId(), "backToFirst", Boolean.FALSE); // 标识驳回标签false
taskService.setVariable(task.getId(), "completeEntry", Boolean.FALSE); // 标志为非首次录入
taskService.setVariable(task.getId(), "reject", Boolean.FALSE); // 标识流程中是否存在拒绝false
taskService.setVariable(task.getId(), "termination", Boolean.FALSE); // 流程直接被终止 false
taskService.setVariable(task.getId(), "backPreviousTask", Boolean.FALSE); // 回退任务到上一节点 false
Optional<SysUserDTO> userDTOOptional = Optional.ofNullable(sysUserService.get(Long.valueOf(task.getAssignee())));
String name = userDTOOptional.isPresent() ? userDTOOptional.get().getRealName() : "";
actTaskService.completeTask(task.getId(), name + "重新发起审核");
result.set(new Result().ok(name + "重新发起审核成功"));
logger.error(name + "重新发起审核成功");
});
return result.get();
}
}

View File

@ -25,6 +25,9 @@ import io.renren.modules.sys.dto.SysUserDTO;
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.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -34,10 +37,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
@Api(tags = "资源上架")
@ -57,6 +57,9 @@ public class ResourceMountController {
@Autowired
private SysUserService sysUserService;
@Autowired
protected TaskService taskService;
private static String apply_key = "resourcemountapply"; // 资源上架
private static String undercarriage_key = "resourcundercarriageapply"; // 资源下架
@ -97,12 +100,25 @@ public class ResourceMountController {
tResourceMountApplyDTO.setParameterContentMd5(SecureUtil.md5(JSONObject.toJSONString(index)));
tResourceMountApplyDTO.setResourceDTO(index);
tResourceMountApplyDTO.setEnclosure(index.getEnclosure());
try {
tResourceMountApplyDTO.setResourceId(tResourceMountApplyDTO.getResourceDTO().getId());
} catch (Exception e) {
logger.error("资源上架异常", e);
}
ValidatorUtils.validateEntity(tResourceMountApplyDTO, AddGroup.class, DefaultGroup.class);
tResourceMountApplyService.save(tResourceMountApplyDTO); // 保存单条资源申请记录
if (tResourceMountApplyDTO.getId() == null) {
return null;
}
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();
@ -121,7 +137,6 @@ public class ResourceMountController {
logger.info("-------------------更新updateInstanceId.成功--------------------------");
logger.info("ProcessInstanceDTO.getProcessInstanceId:" + dto.getProcessInstanceId());
}
return dto;
}).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList()));
}
@ -137,13 +152,35 @@ public class ResourceMountController {
logger.info("---------------------------------------------------");
logger.info(JSONObject.toJSONString(tResourceUndercarriageApplyDTO));
logger.info("####################################################");
return new Result().ok(tResourceUndercarriageApplyDTO.getResource().stream().map(index -> {
Optional<Boolean> undercarriage =
tResourceUndercarriageApplyDTO.getResource().stream().map(index -> {
Long resourceId = Long.valueOf(index.get("resourceId"));
String resourceName = index.get("resourceName");
Optional<ResourceDTO> resourceDTO = Optional.ofNullable(resourceService.get(resourceId));
if (resourceDTO.isPresent()) {
TaskQuery taskQuery = taskService.createTaskQuery();
long task = taskQuery.active().processDefinitionKey(undercarriage_key).processInstanceBusinessKey(resourceId.toString()).count();
return task > 0;
} else {
return true;
}
}).filter(index -> index).findAny();
if (undercarriage.isPresent()) {
return new Result<List<ProcessInstanceDTO>>().error("该资源已发起下架");
}
return new Result().ok(tResourceUndercarriageApplyDTO.getResource().stream().map(index -> {
List<ProcessInstanceDTO> dtoList = new ArrayList<>();
Long resourceId = Long.valueOf(index.get("resourceId"));
// String resourceName = index.get("resourceName");
Optional<ResourceDTO> resourceDTO = Optional.ofNullable(resourceService.get(resourceId));
resourceDTO.ifPresent(dto -> {
TaskQuery taskQuery = taskService.createTaskQuery();
long task = taskQuery.active().processDefinitionKey(undercarriage_key).processInstanceBusinessKey(resourceId.toString()).count();
if (task > 0) {
logger.error("该资源已发起下架");
throw new RuntimeException("该资源已发起下架");
}
dto.setUndercarriageReason(tResourceUndercarriageApplyDTO.getReason());
dto.setDelFlag(ResourceEntityDelFlag.UNDERCARRIAGE_REVIEW.getFlag()); // 设置为下架审核中
dto.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag()); // 设置为正常
String userId = SecurityUser.getUserId().toString();
Optional<SysUserDTO> userDTO = Optional.ofNullable(sysUserService.get(Long.valueOf(userId)));
userDTO.ifPresent(user -> {
@ -152,7 +189,7 @@ public class ResourceMountController {
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
resourceService.update(dto);
logger.error(resourceDTO.get().toString());
});
dto.setCompleteEntry(Boolean.TRUE);
logger.info("-------------------1.保存申请表单成功--------------------------");
// 仿照请求接口 /act/running/startOfBusinessKey
@ -160,13 +197,14 @@ public class ResourceMountController {
processStartDTO.setBusinessKey(resourceId.toString());
processStartDTO.setProcessDefinitionKey(undercarriage_key); // 限定资源下架
ObjectMapper oMapper = new ObjectMapper();
Map<String, Object> variables = oMapper.convertValue(resourceDTO.get(), Map.class);
Map<String, Object> variables = oMapper.convertValue(dto, Map.class);
processStartDTO.setVariables(variables);
ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO);
ProcessInstanceDTO index_ = actRunningService.startOfBusinessKey(processStartDTO);
logger.info("-------------------2.启动流程成功--------------------------");
logger.info("ProcessInstanceDTO.getBusinessKey:" + dto.getBusinessKey());
return dto;
}).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList()));
logger.info("ProcessInstanceDTO.getBusinessKey:" + index_.getBusinessKey());
dtoList.add(index_);
});
return dtoList.stream().findAny().orElse(null);
}).filter(ObjectUtil::isNotNull).collect(Collectors.toList()));
}
}

View File

@ -0,0 +1,38 @@
package io.renren.common.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 审核流程各数据类 基础DTO
*/
@Data
public class AuditingBaseDTO implements Serializable {
/**
* 流程中是否存在拒绝
*/
private Boolean reject = null;
/**
* 流程直接被终止
*/
private Boolean termination = null;
/**
* 流程被驳回到第一个用户任务
*/
private Boolean backToFirst = null;
/**
* 流程完成表单录入?
*/
private Boolean completeEntry = null;
/**
* 回退任务到上一节点
*/
private Boolean backPreviousTask = null;
}

View File

@ -0,0 +1,68 @@
package io.renren.common.listener;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import io.renren.common.dto.AuditingBaseDTO;
import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
/**
* 流程发起人录入表单
*/
@Component
public class InitiatorDataEntryListener implements TaskListener {
private static Logger logger = LoggerFactory.getLogger(InitiatorDataEntryListener.class);
@Autowired
private TaskService taskService;
@Override
public void notify(DelegateTask delegateTask) {
logger.error("----------------------流程发起人录入表单节点---------------------------");
logger.error("事件类型:" + delegateTask.getEventName());
final String eventName = delegateTask.getEventName();
switch (eventName) {
case EVENTNAME_CREATE:
create(delegateTask);
break;
}
}
private void create(DelegateTask delegateTask) {
Map<String, Object> kv = delegateTask.getVariables();
logger.error("录入表单:" + kv.toString());
if (kv.containsKey("creator")) { // 表单存在创建者
taskService.setAssignee(delegateTask.getId(), kv.get("creator").toString());
} else if (kv.containsKey("userId")) {
taskService.setAssignee(delegateTask.getId(), kv.get("userId").toString());
}
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);
AuditingBaseDTO auditingBaseDTO = gson.fromJson(jsonElement, AuditingBaseDTO.class);
if (auditingBaseDTO.getBackToFirst() != null && auditingBaseDTO.getBackToFirst()) {
logger.error("被驳回,需修改后重新提交");
} else {
if (auditingBaseDTO.getCompleteEntry()) {
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "完成申请提交");
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
logger.error("首次录入,自动审核通过!");
}
}
logger.error("----------完成录入表单-----------");
return;
}
}

View File

@ -159,7 +159,7 @@ public class ActTaskController {
* 任务委托
*/
@PostMapping("entrust")
@ApiOperation("任务委托")
@ApiOperation("任务委托(更改审批人)")
@ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "assignee", value = "受理人", paramType = "query", dataType = "String")
@ -261,7 +261,7 @@ public class ActTaskController {
* 终止流程
*/
@PostMapping("endProcess")
@ApiOperation("终止流程")
@ApiOperation("终止流程(直接全拒绝)")
@ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "comment", value = "终止审核意见", paramType = "query", dataType = "String")
@ -276,7 +276,7 @@ public class ActTaskController {
* 驳回
*/
@PostMapping("backToFirst")
@ApiOperation("驳回,回退至第一个用户任务")
@ApiOperation("驳回,回退至第一个用户任务(重新录入表单)")
@ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "任务ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "comment", value = "驳回审核意见", paramType = "query", dataType = "String")

View File

@ -88,6 +88,7 @@ public class HistoryController {
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "name", value = "能力名称", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "processInstanceId", value = "实例ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "businessKey", value = "业务KEY", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "processDefinitionId", value = "流程定义ID", paramType = "query", dataType = "String"),

View File

@ -63,5 +63,11 @@ public class ProcessInstanceDTO {
@ApiModelProperty(value = "当前任务")
private List<TaskDTO> currentTaskList;
@ApiModelProperty(value = "资源情况")
private int resourceStatus;
@ApiModelProperty(value = "资源情况")
private String resourceStatusTip;
@ApiModelProperty(value = "流程被驳回到第一个用户任务?")
private Boolean backToFirst = Boolean.FALSE;
}

View File

@ -4,7 +4,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -77,4 +76,7 @@ public class TaskDTO {
@ApiModelProperty(value = "流程发起时间")
private Date startTime;
@ApiModelProperty(value = "流程被驳回到第一个用户任务?")
private Boolean backToFirst = null;
}

View File

@ -37,10 +37,7 @@ import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 工作流
@ -254,9 +251,12 @@ public class ActHistoryService {
public PageData<ProcessInstanceDTO> getMyProcessInstancePage(Map<String, Object> params) {
params.put("startBy", SecurityUser.getUserId().toString());
PageData<ProcessInstanceDTO> pageData = this.getHistoryProcessInstancePage(params);
if (params.containsKey("name") && StringUtils.isNotBlank(params.get("name").toString())) {
params.put("limit", String.valueOf(pageData.getTotal()));
pageData = this.getHistoryProcessInstancePage(params);
}
List<ProcessInstanceDTO> list = pageData.getList();
for (ProcessInstanceDTO dto : list) {
logger.info(dto.toString());
TAbilityApplicationDTO abilityApplicationDTO = tAbilityApplicationService.getByInstanceId(dto.getProcessInstanceId()); // 获取申请表单
if (abilityApplicationDTO != null && StringUtils.isNotEmpty(abilityApplicationDTO.getSystem()) && StringUtils.isEmpty(dto.getName())) {
dto.setName(abilityApplicationDTO.getSystem());
@ -268,9 +268,17 @@ public class ActHistoryService {
dto.setResourceId(abilityApplicationDTO.getResourceId());
} else {
TResourceMountApplyDTO resourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(dto.getBusinessKey()));
if (resourceMountApplyDTO != null) {
if (resourceMountApplyDTO != null && resourceMountApplyDTO.getResourceDTO() != null
&& resourceMountApplyDTO.getResourceDTO().getId() != null) {
dto.setName(resourceMountApplyDTO.getResourceDTO().getName());
dto.setResourceId(resourceMountApplyDTO.getResourceDTO().getId().toString());
if (resourceMountApplyDTO.getResourceId() != null) {
ResourceDTO resourceDTO = resourceService.get(resourceMountApplyDTO.getResourceId());
if (resourceDTO != null) {
dto.setName(resourceDTO.getName());
dto.setResourceId(resourceDTO.getId().toString());
}
}
} else {
ResourceDTO resourceDTO = resourceService.get(Long.valueOf(dto.getBusinessKey()));
if (resourceDTO != null) {
@ -280,10 +288,17 @@ public class ActHistoryService {
}
}
}
if (dto.getResourceId() != null) {
ResourceDTO resourceDTO = resourceService.get(Long.valueOf(dto.getResourceId()));
if (resourceDTO != null) {
dto.setResourceStatus(resourceDTO.getDelFlag());
dto.setResourceStatusTip(resourceDTO.getDelFlagTip());
}
}
if (dto.isEnded()) { // 已结束
continue;
}
List<Task> listTask = taskService.createTaskQuery().processInstanceId(dto.getProcessInstanceId()).list();
List<Task> listTask = taskService.createTaskQuery().processInstanceId(dto.getProcessInstanceId()).includeProcessVariables().list();
List<TaskDTO> taskDTOList = new ArrayList<>();
for (Task task : listTask) {
TaskDTO taskDTO = new TaskDTO();
@ -293,9 +308,24 @@ public class ActHistoryService {
taskDTO.setAssigneeName(userDTO.getRealName());
}
taskDTOList.add(taskDTO);
dto.setBackToFirst(taskDTO.getBackToFirst());
}
dto.setCurrentTaskList(taskDTOList);
}
List<ProcessInstanceDTO> list1 = new ArrayList<>();
if (params.containsKey("name") && StringUtils.isNotBlank(params.get("name").toString())) {
pageData.getList().stream()
.filter(Objects::nonNull)
.filter(index -> null != index.getName() && index.getName().contains(params.get("name").toString()))
.forEach(list1::add);
ArrayList<ProcessInstanceDTO> list2 = new ArrayList<>();
int j = Math.min(Integer.parseInt(params.get("page").toString()) * Integer.parseInt(params.get("limit").toString()), list1.size());
for (int i = (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()); i < j; i++) {
list2.add(list1.get(i));
}
pageData.setTotal(list1.size());
pageData.setList(list2);
}
return pageData;
}
@ -314,6 +344,10 @@ public class ActHistoryService {
dto.setProcessInstanceId(task.getProcessInstanceId());
dto.setOwner(task.getOwner());
dto.setCreateTime(task.getCreateTime());
dto.setParams(task.getProcessVariables());
if (dto.getParams() != null && dto.getParams().containsKey("backToFirst") && dto.getParams().get("backToFirst") != null) {
dto.setBackToFirst(Boolean.valueOf(dto.getParams().get("backToFirst").toString()));
}
}
public ProcessInstanceDTO getHistoryProcessInstanceByBusinessKey(String procDefKey, String businessKey) {

View File

@ -121,39 +121,48 @@ public class ActTaskService extends BaseServiceImpl {
}
}
taskQuery.orderByTaskCreateTime().desc();
List<Task> list = taskQuery.listPage((curPage - 1) * limit, limit);
List<Task> list = taskQuery.active().includeProcessVariables().listPage((curPage - 1) * limit, limit);
List<TaskDTO> listDto = new ArrayList<>();
for (Task task : list) {
TaskDTO dto = new TaskDTO();
this.convertTaskInfo(task, dto);
ObjectMapper oMapper = new ObjectMapper();
Map<String, Object> processVariable = new LinkedHashMap<>();
TAbilityApplicationDTO abilityApplicationDTO =
tAbilityApplicationService.get(Long.valueOf(dto.getBusinessKey()));
if (abilityApplicationDTO != null) {
Map<String, Object> variables = oMapper.convertValue(abilityApplicationDTO, Map.class);
dto.setParams(variables);
processVariable.putAll(variables);
processVariable.putAll(task.getProcessVariables());
dto.setParams(processVariable);
listDto.add(dto);
continue;
}
TResourceMountApplyDTO resourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(dto.getBusinessKey()));
if (resourceMountApplyDTO != null) {
Map<String, Object> variables = oMapper.convertValue(resourceMountApplyDTO, Map.class);
dto.setParams(variables);
processVariable.putAll(variables);
processVariable.putAll(task.getProcessVariables());
dto.setParams(processVariable);
listDto.add(dto);
continue;
}
TDemandDataDTO tDemandDataDTO = tDemandDataService.get(Long.valueOf(dto.getBusinessKey()));
if (tDemandDataDTO != null) {
Map<String, Object> variables = oMapper.convertValue(tDemandDataDTO, Map.class);
dto.setParams(variables);
processVariable.putAll(variables);
processVariable.putAll(task.getProcessVariables());
dto.setParams(processVariable);
listDto.add(dto);
continue;
}
ResourceDTO resourceDTO = resourceService.get(Long.valueOf(dto.getBusinessKey()));
if (resourceDTO != null) {
Map<String, Object> variables = oMapper.convertValue(resourceDTO, Map.class);
dto.setParams(variables);
processVariable.putAll(variables);
processVariable.putAll(task.getProcessVariables());
dto.setParams(processVariable);
listDto.add(dto);
continue;
}
@ -234,6 +243,7 @@ public class ActTaskService extends BaseServiceImpl {
taskService.addComment(taskId, task.getProcessInstanceId(), comment);
}
taskService.setVariable(taskId, Task_HANDLE_STATE, Task_HANDLE_STATE_AGREE);
taskService.setVariable(taskId, "backToFirst", Boolean.FALSE);
taskService.complete(taskId);
}
@ -399,6 +409,7 @@ public class ActTaskService extends BaseServiceImpl {
commentMode += "[" + comment + "]";
}
taskService.setVariable(task.getId(), Task_HANDLE_STATE, Task_HANDLE_STATE_BACK);
taskService.setVariable(task.getId(), "backPreviousTask", Boolean.TRUE);
taskService.addComment(task.getId(), task.getProcessInstanceId(), commentMode);
taskService.complete(task.getId(), variables);
}
@ -487,6 +498,7 @@ public class ActTaskService extends BaseServiceImpl {
comment = message + "[" + comment + "]";
taskService.addComment(task.getId(), task.getProcessInstanceId(), comment);
taskService.setVariable(task.getId(), Task_HANDLE_STATE, Task_HANDLE_STATE_STOP);
taskService.setVariable(task.getId(), "reject", Boolean.TRUE); // 存在被拒绝的批示
taskService.complete(taskId);
pointActivity.getIncomingTransitions().remove(newTransition);
List<PvmTransition> pvmTransitionListC = currActivity.getOutgoingTransitions();
@ -592,6 +604,7 @@ public class ActTaskService extends BaseServiceImpl {
throw new RenException(ErrorCode.SUPERIOR_NOT_EXIST);
}
variables = processInstance.getProcessVariables();
variables.put("backToFirst", Boolean.TRUE); // 标识驳回到第一个任务节点
for (Task task : tasks) {
String commentMode = MessageUtils.getMessage(ErrorCode.REJECT_MESSAGE);
if (StringUtils.isNotEmpty(comment)) {
@ -617,6 +630,7 @@ public class ActTaskService extends BaseServiceImpl {
}
}
taskService.setVariable(taskDTO.getTaskId(), Task_HANDLE_STATE, Task_HANDLE_STATE_REJECTED);
taskService.setVariable(taskDTO.getTaskId(), "backToFirst", Boolean.FALSE);
this.completeTask(taskDTO.getTaskId(), taskDTO.getComment());
}

View File

@ -13,6 +13,7 @@ import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.demanData.dto.TDemandDataDTO;
import io.renren.modules.demanData.excel.TDemandDataExcel;
import io.renren.modules.demanData.service.TDemandDataService;
import io.renren.modules.demandComment.service.TDemandCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -24,6 +25,7 @@ import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -38,6 +40,8 @@ import java.util.Map;
public class TDemandDataController {
@Autowired
private TDemandDataService tDemandDataService;
@Autowired
private TDemandCommentService tDemandCommentService;
@GetMapping("/page")
@ApiOperation("分页")
@ -54,7 +58,10 @@ public class TDemandDataController {
// @RequiresPermissions("demanData:tdemanddata:page")
public Result<PageData<TDemandDataDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
PageData<TDemandDataDTO> page = tDemandDataService.page(params);
page.setList(page.getList().stream().map(index -> {
index.setCommentCount(tDemandCommentService.commentCount(index.getId()));
return index;
}).collect(Collectors.toList()));
return new Result<PageData<TDemandDataDTO>>().ok(page);
}
@ -63,7 +70,7 @@ public class TDemandDataController {
// @RequiresPermissions("demanData:tdemanddata:info")
public Result<TDemandDataDTO> get(@PathVariable("id") Long id) {
TDemandDataDTO data = tDemandDataService.get(id);
data.setCommentCount(tDemandCommentService.commentCount(id));
return new Result<TDemandDataDTO>().ok(data);
}

View File

@ -1,11 +1,14 @@
package io.renren.modules.demanData.dto;
import io.renren.common.dto.AuditingBaseDTO;
import io.renren.modules.demanData.entity.TDemandDataEntityFlag;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.Optional;
/**
* 能力需求评审主体
@ -15,7 +18,7 @@ import java.util.Date;
*/
@Data
@ApiModel(value = "能力需求评审主体")
public class TDemandDataDTO implements Serializable {
public class TDemandDataDTO extends AuditingBaseDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
@ -44,6 +47,8 @@ public class TDemandDataDTO implements Serializable {
private String enclosure;
@ApiModelProperty(value = "业务标志0:初始化 1:审批中 2:审批拒绝 3:审批通过)")
private Integer flag;
@ApiModelProperty(value = "业务标志提示0:初始化 1:审批中 2:审批拒绝 3:审批通过)")
private String flagTip;
@ApiModelProperty(value = "审批意见")
private String approvalOpinions;
@ApiModelProperty(value = "审批人姓名")
@ -56,8 +61,21 @@ public class TDemandDataDTO implements Serializable {
@ApiModelProperty(value = "实例ID")
private String instanceId;
@ApiModelProperty(value = "评论数目")
private Long commentCount = 0l;
public TDemandDataDTO() {
this.flag = 0;
this.flag = TDemandDataEntityFlag.INIT.getFlag();
this.visits = 0l;
}
public String getFlagTip() {
if (this.flag != null) {
Optional<TDemandDataEntityFlag> tDemandDataEntityFlag = Optional.ofNullable(TDemandDataEntityFlag.getByFlag(this.flag));
if (tDemandDataEntityFlag.isPresent()) {
return tDemandDataEntityFlag.get().getTip();
}
}
return "";
}
}

View File

@ -0,0 +1,59 @@
package io.renren.modules.demanData.entity;
import java.util.Arrays;
/**
* 业务标志0:初始化 1:审批中 2:审批拒绝 3:审批通过
*/
public enum TDemandDataEntityFlag {
/**
* 0:初始化
*/
INIT(0, "初始化"),
/**
* 1:审批中
*/
UNDER_REVIEW(1, "审批中"),
/**
* 2审批拒绝
*/
REJECT(2, "审批拒绝"),
/**
* 3:审批通过
*/
APPROVE(3, "审批通过"),
/**
* 4:未知
*/
UNKNOWN(4, "未知");
private int flag;
private String tip;
TDemandDataEntityFlag(int i, String s) {
this.flag = i;
this.tip = s;
}
public static TDemandDataEntityFlag getByFlag(int flag) {
TDemandDataEntityFlag[] index = TDemandDataEntityFlag.values();
return Arrays.asList(index).stream().filter(index_ -> index_.flag == flag).findAny().orElse(TDemandDataEntityFlag.UNKNOWN);
}
public int getFlag() {
return flag;
}
public void setFlag(int flag) {
this.flag = flag;
}
public String getTip() {
return tip;
}
public void setTip(String tip) {
this.tip = tip;
}
}

View File

@ -1,8 +1,13 @@
package io.renren.modules.demanData.listener;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.*;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import io.renren.modules.activiti.service.ActTaskService;
import io.renren.modules.demanData.dto.TDemandDataDTO;
import io.renren.modules.demanData.entity.TDemandDataEntityFlag;
import io.renren.modules.demanData.service.TDemandDataService;
import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysRoleDTO;
@ -15,14 +20,15 @@ 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.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.stereotype.Component;
import java.lang.reflect.Type;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
@ -42,6 +48,8 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti
@Autowired
private TaskService taskService;
@Autowired
private ActTaskService actTaskService;
@Autowired
private SysUserService sysUserService;
@Autowired
private SysRoleUserService sysRoleUserService;
@ -108,14 +116,9 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti
private void create(DelegateTask delegateTask, final SysRoleDTO roleDTO) {
Map<String, Object> kv = delegateTask.getVariables();
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
return new Date(json.getAsJsonPrimitive().getAsLong());
}
});
builder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
Gson gson = builder.create();
// Gson gson = new Gson();
JsonElement jsonElement = gson.toJsonTree(kv);
TDemandDataDTO demandDataDTO = gson.fromJson(jsonElement, TDemandDataDTO.class);
@ -155,11 +158,7 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti
logger.error("---------------------------流程节点完成---------------------------------");
Map<String, Object> kv = delegateTask.getVariables();
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
return new Date(json.getAsJsonPrimitive().getAsLong());
}
});
builder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
Gson gson = builder.create();
JsonElement jsonElement = gson.toJsonTree(kv);
@ -168,14 +167,39 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti
if (demandDataDTO != null) {
logger.error(JSONObject.toJSONString(demandDataDTO));
SysUserDTO userDTO = sysUserService.get(Long.valueOf(delegateTask.getAssignee()));
taskService.getTaskComments(delegateTask.getId());
// tDemandDataService.updateFlag(3, demandDataDTO.getId());// 更新状态为已审批通过
demandDataDTO.setFlag(3);
if (demandDataDTO.getReject() != null && demandDataDTO.getReject() == Boolean.TRUE) { // 拒绝
demandDataDTO.setFlag(TDemandDataEntityFlag.REJECT.getFlag());
demandDataDTO.setApprovalUserDeptName(userDTO != null ? userDTO.getDeptName() : null);
demandDataDTO.setApprovalUserName(userDTO != null ? userDTO.getRealName() : null);
demandDataDTO.setApprovalOpinions(taskService.getTaskComments(delegateTask.getId()).stream().findFirst().get().getFullMessage());
logger.error("---------------------------更新状态为已审批通过---------------------------------");
logger.error("---------------------------更新状态为审批未通过---------------------------------");
} else if (demandDataDTO.getBackToFirst() != null && demandDataDTO.getBackToFirst()) { // 驳回
demandDataDTO.setFlag(TDemandDataEntityFlag.UNDER_REVIEW.getFlag());
demandDataDTO.setApprovalUserDeptName(userDTO != null ? userDTO.getDeptName() : null);
demandDataDTO.setApprovalUserName(userDTO != null ? userDTO.getRealName() : null);
demandDataDTO.setApprovalOpinions(taskService.getTaskComments(delegateTask.getId()).stream().findFirst().get().getFullMessage());
logger.error("---------------------------更新状态为已审批中---------------------------------");
} else if (demandDataDTO.getTermination() != null && demandDataDTO.getTermination()) { // 直接终止
demandDataDTO.setFlag(TDemandDataEntityFlag.REJECT.getFlag());
demandDataDTO.setApprovalUserDeptName(userDTO != null ? userDTO.getDeptName() : null);
demandDataDTO.setApprovalUserName(userDTO != null ? userDTO.getRealName() : null);
demandDataDTO.setApprovalOpinions(taskService.getTaskComments(delegateTask.getId()).stream().findFirst().get().getFullMessage());
logger.error("---------------------------更新状态为已拒绝---------------------------------");
} else {
demandDataDTO.setFlag(TDemandDataEntityFlag.APPROVE.getFlag());
demandDataDTO.setApprovalUserDeptName(userDTO != null ? userDTO.getDeptName() : null);
demandDataDTO.setApprovalUserName(userDTO != null ? userDTO.getRealName() : null);
demandDataDTO.setApprovalOpinions(taskService.getTaskComments(delegateTask.getId()).stream().findFirst().get().getFullMessage());
logger.error("---------------------------更新状态为已通过---------------------------------");
}
logger.error("demandDataDTO:" + demandDataDTO);
Map<String, Object> combineResultMap = new HashMap<>();
ObjectMapper oMapper = new ObjectMapper();
Map<String, Object> variables = oMapper.convertValue(demandDataDTO, Map.class);
combineResultMap.putAll(delegateTask.getVariables());
combineResultMap.putAll(variables);
taskService.setVariables(delegateTask.getId(), combineResultMap);
tDemandDataService.update(demandDataDTO);
}
}

View File

@ -13,4 +13,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface TDemandCommentDao extends BaseDao<TDemandCommentEntity> {
Long commentCount(Long dataId);
}

View File

@ -11,5 +11,6 @@ import io.renren.modules.demandComment.entity.TDemandCommentEntity;
* @since 1.0 2022-04-26
*/
public interface TDemandCommentService extends CrudService<TDemandCommentEntity, TDemandCommentDTO> {
Long commentCount(Long dataId);
}

View File

@ -55,4 +55,8 @@ public class TDemandCommentServiceImpl extends CrudServiceImpl<TDemandCommentDao
}
@Override
public Long commentCount(Long dataId) {
return baseDao.commentCount(dataId);
}
}

View File

@ -4,6 +4,9 @@ import io.renren.common.dao.BaseDao;
import io.renren.modules.processForm.entity.TAbilityApplicationEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
/**
* 能力申请表单
*
@ -17,4 +20,8 @@ public interface TAbilityApplicationDao extends BaseDao<TAbilityApplicationEntit
TAbilityApplicationEntity getByInstanceId(String instanceId);
TAbilityApplicationEntity getByBusinessKey(String businessKey);
Long countApplyAll();
List<Map<String, Object>> getAmountGroupByType();
}

View File

@ -1,5 +1,6 @@
package io.renren.modules.processForm.dto;
import io.renren.common.dto.AuditingBaseDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -14,7 +15,7 @@ import java.io.Serializable;
*/
@Data
@ApiModel(value = "能力申请表单")
public class TAbilityApplicationDTO implements Serializable {
public class TAbilityApplicationDTO extends AuditingBaseDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;

View File

@ -1,5 +1,6 @@
package io.renren.modules.processForm.dto;
import io.renren.common.dto.AuditingBaseDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -11,7 +12,7 @@ import java.util.Map;
@Data
@ApiModel(value = "批量能力申请表单")
public class TAbilityBatchApplicationDTO implements Serializable {
public class TAbilityBatchApplicationDTO extends AuditingBaseDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;

View File

@ -1,10 +1,15 @@
package io.renren.modules.processForm.listener;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import io.renren.modules.activiti.service.ActTaskService;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.service.ApiGatewayService;
import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.ResourceEntity;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysRoleDTO;
@ -13,24 +18,21 @@ import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysRoleService;
import io.renren.modules.sys.service.SysRoleUserService;
import io.renren.modules.sys.service.SysUserService;
import org.activiti.engine.HistoryService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
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.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskQuery;
import org.apache.commons.lang.StringUtils;
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 java.util.*;
import java.util.Date;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
/**
* 部门动态审批人
@ -54,6 +56,8 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
private SysRoleUserService sysRoleUserService;
@Autowired
private SysDeptService sysDeptService;
@Autowired
private ApiGatewayService apiGatewayService;
@Autowired
private ResourceService resourceService;
@ -68,6 +72,9 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
case EVENTNAME_CREATE:
create(delegateTask);
break;
case EVENTNAME_COMPLETE:
complete(delegateTask);
break;
default:
}
logger.error("-------------------------结束部门动态审批人流程-------------------------------");
@ -108,16 +115,26 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
* @param kv
*/
private void endTake(Map<String, Object> kv) { // 进入最后结束节点
Gson gson = new Gson();
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 (abilityApplicationDTO != null) {
if (abilityApplicationDTO.getReject() != null && abilityApplicationDTO.getReject() == Boolean.TRUE) { // 存在被拒绝的节点
abilityApplicationDTO.setDelFlag(0);
abilityApplicationDTO.setApproveStatus("不通过");
tAbilityApplicationService.update(abilityApplicationDTO);
logger.error("审批不通过申请id:" + abilityApplicationDTO.getId());
} else {
abilityApplicationDTO.setDelFlag(0);
abilityApplicationDTO.setApproveStatus("通过");
tAbilityApplicationService.update(abilityApplicationDTO);
logger.error("审批通过申请id:" + abilityApplicationDTO.getId());
}
}
}
/**
* 节点创建时动态分配资源部门审核人
@ -126,7 +143,10 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
*/
private void create(DelegateTask delegateTask) {
Map<String, Object> kv = delegateTask.getVariables();
Gson gson = new Gson();
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);
@ -144,8 +164,13 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
sysDeptService.get(resourceEntityDto.getDeptId());
if (deptDTO != null && deptDTO.getName().equals(bigDateDeptName)) {
logger.error("第二级别审批仍然为 " + bigDateDeptName);
SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptId, roleDTO.getId()); // 搜出审批人
if (userDTO != null) {
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
}
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "默认通过");
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
return;
}
} else {
logger.error("表单内单位名称:" + abilityApplicationDTO.getUnit());
@ -167,5 +192,71 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
logger.error("未查到该部门对应的 " + roleName);
taskService.setAssignee(delegateTask.getId(), "1516728698224427010");
}
mpComplete(abilityApplicationDTO, delegateTask);
}
private void mpComplete(TAbilityApplicationDTO abilityApplicationDTO, DelegateTask delegateTask) {
Optional<ResourceDTO> resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(abilityApplicationDTO.getResourceId())));
resourceDTOOptional.ifPresent(resource -> {
if ("免批申请".equals(resource.getShareCondition())) { // 针对免批资源申请
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "免批资源申请默认通过");
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
return;
}
if (abilityApplicationDTO.getUserId().equals(delegateTask.getAssignee())) {
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "申请人为资源提供方部门审批人,默认通过");
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
return;
}
});
}
private void complete(DelegateTask delegateTask) {
Map<String, Object> kv = delegateTask.getVariables();
//如果有code说明已经注册过了,以及只有通过的流程申请
if (kv.get("gatewayCode") != null ||
!ActTaskService.Task_HANDLE_STATE_AGREE.equals(kv.get(ActTaskService.Task_HANDLE_STATE))) return;
try {
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);
applyCode(delegateTask, abilityApplicationDTO);
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
}
}
/**
* 审批通过申请code
*
* @param delegateTask
* @param abilityApplicationDTO
*/
private void applyCode(DelegateTask delegateTask, TAbilityApplicationDTO abilityApplicationDTO) {
logger.info("-------能力申请code-------");
ResourceEntity resourceEntity = resourceService.selectById(abilityApplicationDTO.getResourceId());
//没有groupid当做没有接口直接跳过
if (resourceEntity.getGroupId() == null)
return;
String code = UUID.randomUUID().toString();
apiGatewayService.subscribeCode(String.valueOf(abilityApplicationDTO.getId()), code);
delegateTask.setVariable("gatewayCode", code);
String apiPrefix = "/juapi/" + abilityApplicationDTO.getResourceId();
TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
String msg = String.format("您的能力申请已通过接口认证code为%s, 接口公共前缀为:%s", code, apiPrefix);
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), msg);
}
}

View File

@ -1,6 +1,8 @@
package io.renren.modules.processForm.listener;
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.dto.TAbilityApplicationDTO;
import io.renren.modules.resource.dto.ResourceDTO;
@ -22,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
import java.util.Optional;
@ -62,7 +65,7 @@ public class DataCenterListener implements TaskListener, ExecutionListener, Acti
@Override
public void notify(DelegateTask delegateTask) {
logger.info("事件类型:" + delegateTask.getEventName());
logger.error("事件类型:" + delegateTask.getEventName());
final String eventName = delegateTask.getEventName();
switch (eventName) {
case EVENTNAME_CREATE:
@ -72,7 +75,7 @@ public class DataCenterListener implements TaskListener, ExecutionListener, Acti
logger.error("----------------------大数据审批通过-complete------------------------------");
break;
default:
logger.info("未处理该事件:" + eventName);
logger.error("未处理该事件:" + eventName);
}
}
@ -92,23 +95,26 @@ public class DataCenterListener implements TaskListener, ExecutionListener, Acti
* @param delegateTask
*/
private void createEvent(DelegateTask delegateTask) {
logger.info("大数据局名称:" + bigDateDeptName);
logger.error("大数据局名称:" + bigDateDeptName);
SysDeptDTO deptDTO = sysDeptService.getByName(bigDateDeptName);
logger.info("deptDTOId:" + deptDTO.getId());
logger.error("deptDTOId:" + deptDTO.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.info("roleDTOId:" + roleDTO.getId());
logger.error("roleDTOId:" + roleDTO.getId());
SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId());
if (userDTO != null) {
logger.info("审批人id:" + userDTO.getId());
logger.error("审批人id:" + userDTO.getId());
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
} else {
delegateTask.setAssignee("1516728698224427010");
logger.info("未查到该部门对应 " + roleName);
logger.error("未查到该部门对应 " + roleName);
}
Map<String, Object> kv = delegateTask.getVariables();
Gson gson = new Gson();
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);
Optional<ResourceDTO> resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(abilityApplicationDTO.getResourceId())));
@ -116,6 +122,12 @@ public class DataCenterListener implements TaskListener, ExecutionListener, Acti
if ("免批申请".equals(resource.getShareCondition())) { // 针对免批资源申请
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "免批资源申请默认通过");
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
return;
}
if (userDTO != null && abilityApplicationDTO.getUserId().equals(userDTO.getId().toString())) {
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "申请人为大数据部门审批人,默认通过");
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
return;
}
});

View File

@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.HashMap;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -60,7 +61,7 @@ public class ApiGatewayService {
throw new IllegalArgumentException(String.format("未找到对应的资源id:%s", resourceId));
}
String apiUrl = resourceEntity.getApiUrl();
String methods = resourceEntity.getApiMethodType().toUpperCase();
String methods = resourceEntity.getApiMethodType();
if (StringUtils.isBlank(apiUrl) || StringUtils.isBlank(methods)){
String msg = String.format("注册api参数为空跳过 apiUrl:%s, methods:%s, resourceId:%s", apiUrl, methods, resourceId);
@ -68,7 +69,7 @@ public class ApiGatewayService {
log.info(msg);
return;
}
methods = methods.toUpperCase(Locale.ROOT);
//建group
String domain = getIP(apiUrl);
String uris = apiUrl.substring(apiUrl.indexOf(domain) + domain.length());

View File

@ -4,6 +4,9 @@ import io.renren.common.service.CrudService;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.entity.TAbilityApplicationEntity;
import java.util.List;
import java.util.Map;
/**
* 能力申请表单
*
@ -14,10 +17,17 @@ public interface TAbilityApplicationService extends CrudService<TAbilityApplicat
void updateInstanceId(String instanceId, Long id);
/** 根据instanceId 获取申请内容
/**
* 根据instanceId 获取申请内容
*
* @param instanceId
* @return
*/
TAbilityApplicationDTO getByInstanceId(String instanceId);
TAbilityApplicationDTO getByBusinessKey(String businessKey);
Long countApplyAll();
List<Map<String, Object>> getAmountGroupByType();
}

View File

@ -10,6 +10,7 @@ import io.renren.modules.processForm.service.TAbilityApplicationService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
@ -52,5 +53,15 @@ public class TAbilityApplicationServiceImpl extends CrudServiceImpl<TAbilityAppl
return ConvertUtils.sourceToTarget(entity, TAbilityApplicationDTO.class);
}
@Override
public Long countApplyAll() {
return baseDao.countApplyAll();
}
@Override
public List<Map<String, Object>> getAmountGroupByType() {
return baseDao.getAmountGroupByType();
}
}

View File

@ -53,12 +53,10 @@ public class ResourceController {
@ApiImplicitParam(name = "name", value = "资源名称", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "creator", value = "创建者用户id", paramType = "query", dataType = "String")
@ApiImplicitParam(name = "creator", value = "创建者用户id", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "delFlag", value = "创建者用户id", paramType = "query", dataType = "String")
})
public Result<PageData<ResourceDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
if (!params.containsKey("del_flag")) {
params.put("del_flag", 0);
}
PageData<ResourceDTO> page = resourceService.page(params);
page.getList().forEach(item -> {
item.setInfoList(resourceService.selectAttrsByResourceId(item.getId()));
@ -117,6 +115,13 @@ public class ResourceController {
return new Result<>().ok(resourceService.selectRecommend());
}
@PostMapping("/selectDeptList")
@ApiOperation("查询部门企业列表及汇聚能力数量")
@LogOperation("查询部门企业列表及汇聚能力数量")
public Result selectDeptList(@RequestBody JSONObject jsonObject) {
return new Result().ok(resourceService.selectDeptList(jsonObject));
}
@GetMapping("/updateVisits")
@ApiOperation("更新能力访问量")
@LogOperation("更新能力访问量")
@ -139,6 +144,7 @@ public class ResourceController {
if ("f".equals(source)) {
dto.setDelFlag(2); // 来自前端页面 走审批流程
}
logger.info(dto.toString());
resourceService.insertWithAttrs(dto);
return new Result().ok(dto.getId() == null ? "" : dto.getId());
@ -162,9 +168,7 @@ public class ResourceController {
@LogOperation("删除")
//@RequiresPermissions("resource:resource:delete")
public Result delete(@RequestBody JSONObject jsonObject) {
resourceService.deleteWithAttrs(jsonObject);
return new Result();
}
@ -188,6 +192,19 @@ public class ResourceController {
return new Result().ok(map);
}
@GetMapping("algorithmPage")
@ApiOperation("算法仓分页查询")
@LogOperation("算法仓分页查询")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "name", value = "资源名称", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
})
public Result algorithmPage(@ApiIgnore@RequestParam Map<String, Object> params) {
return new Result().ok(resourceService.algorithmPage(params));
}
/*
@GetMapping("export")
@ApiOperation("导出")

View File

@ -46,4 +46,26 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
*/
@MapKey("type")
List<Map<String, Object>> getAmountGroupByType();
/**
* 介入部门数目
* @return
*/
Long countAllDept();
List<Map<String, Object>> selectGroupByDeptId(@Param("type") String type);
Integer selectTypeCountByDept(@Param("deptType") String deptType, @Param("resourceType") String resourceType);
List<ResourceDTO> selectAlgorithmPage(Map<String, Object> params);
Integer selectTypeCountByDist(@Param(("districtName")) String districtName, @Param("resourceType") String resourceType);
Long countAllVisits();
Integer selectDeptCount();
List<Map> selectDeptTypeCount();
List<Map> selectDeptTotalCount();
}

View File

@ -1,5 +1,6 @@
package io.renren.modules.resource.dto;
import io.renren.common.dto.AuditingBaseDTO;
import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.entity.ResourceEntityDelFlag;
import io.swagger.annotations.ApiModel;
@ -19,7 +20,7 @@ import java.util.Optional;
*/
@Data
@ApiModel(value = "资源表")
public class ResourceDTO implements Serializable {
public class ResourceDTO extends AuditingBaseDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
@ -89,6 +90,8 @@ public class ResourceDTO implements Serializable {
private String applyState;
@ApiModelProperty(value = "申请量")
private String applyCount;
@ApiModelProperty(value = "部门ID集合")
private List<Long> deptIds;
@ApiModelProperty(value = "属性信息")
@ -107,7 +110,6 @@ public class ResourceDTO implements Serializable {
if (resourceEntityDelFlagOptional.isPresent()) {
return resourceEntityDelFlagOptional.get().getTip();
}
return "";
}
return "";
}

View File

@ -1,6 +1,9 @@
package io.renren.modules.resource.listener;
import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.ResourceEntityDelFlag;
@ -22,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
@ -87,16 +91,25 @@ public class ResourceUndercarriageListener implements TaskListener, ExecutionLis
* @param kv
*/
private void endTake(Map<String, Object> kv) { // 进入最后结束节点
Gson gson = new Gson();
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);
ResourceDTO re = gson.fromJson(jsonElement, ResourceDTO.class);
if (re != null) {
logger.error(kv.toString());
if (re.getReject() != null && re.getReject() == Boolean.TRUE) { // 下架被拒绝 重新上线
re.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
resourceService.update(re);
logger.error("下架审批未通过 资源id:" + re.getId());
} else { // 下架成功
re.setDelFlag(ResourceEntityDelFlag.UNDERCARRIAGE.getFlag());
resourceService.update(re);
logger.error("下架审批通过 资源id:" + re.getId());
}
}
}
/**
* 节点创建时动态分配资源部门审核人
@ -106,9 +119,8 @@ public class ResourceUndercarriageListener implements TaskListener, ExecutionLis
*/
private void create(DelegateTask delegateTask, final SysRoleDTO roleDTO) {
Map<String, Object> kv = delegateTask.getVariables();
Gson gson = new Gson();
JsonElement jsonElement = gson.toJsonTree(kv);
ResourceDTO re = gson.fromJson(jsonElement, ResourceDTO.class);
ResourceDTO re = JSON.parseObject(JSON.toJSONString(kv), ResourceDTO.class);
if (re.getDeptId() != null) {
SysDeptDTO deptDTO =
sysDeptService.get(re.getDeptId());

View File

@ -39,5 +39,16 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
Object selectRecommend();
Object selectDeptList(JSONObject jsonObject);
List<Map<String, Object>> getAmountGroupByType();
Long countAllDept();
Object algorithmPage(Map<String, Object> params);
Long countAllVisits();
Object selectSourceDepartmentStatistics();
}

View File

@ -17,6 +17,8 @@ import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.entity.ResourceEntity;
import io.renren.modules.resource.entity.ResourceEntityDelFlag;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
import io.renren.modules.resourceCar.dao.ResourceCarDao;
import io.renren.modules.resourceCollection.dao.ResourceCollectionDao;
import io.renren.modules.resourceScore.dao.ResourceScoreDao;
@ -31,6 +33,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 资源表
@ -56,6 +59,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Autowired
private AttrDao attrDao;
@Autowired
private ResourceBrowseDao resourceBrowseDao;
@Override
public QueryWrapper<ResourceEntity> getWrapper(Map<String, Object> params) {
QueryWrapper<ResourceEntity> wrapper = new QueryWrapper<>();
@ -72,11 +78,17 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
break;
}
});
wrapper.orderByDesc("create_date");
if (!params.containsKey("creator")) { // 创建者查询时
wrapper.eq("del_flag", params.get("del_flag") == null ? 0 : Integer.valueOf(params.get("del_flag").toString()));
if (params.containsKey("selectType") && "1".equals(params.get("selectType").toString())) { // 创建者查询时
wrapper.ne("del_flag", 1);
} else if (params.containsKey("selectType") && "0".equals(params.get("selectType").toString())) {
if (params.containsKey("delFlag") && !"".equals(params.get("delFlag").toString())) {
wrapper.eq("del_flag", params.get("delFlag"));
} else {
wrapper.in(true, "del_flag", 0, 5);
}
}
wrapper.orderByAsc("del_flag")
.orderByDesc("create_date");
return wrapper;
}
@ -95,12 +107,14 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
BeanUtils.copyProperties(resourceEntity, dto);
List<AttrEntity> attrEntities = dto.getInfoList();
if (attrEntities != null) {
attrEntities.forEach(item -> {
item.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
item.setDataResourceId(resourceID);
attrDao.insert(item);
});
}
}
@Override
@Transactional
@ -126,6 +140,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
attrDao.delete4Resource(list);
List<AttrEntity> attrEntities = dto.getInfoList();
attrEntities.forEach(item -> {
item.setId(null);
item.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
attrDao.insert(item);
});
@ -221,13 +236,15 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<ResourceDTO> resourceDTOS = resourceDao.selectMostPopular(selectMap);
page.setRecords(resourceDTOS);
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).eq("type", jsonObject.getString("type"));
queryWrapper.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag())
.eq("type", jsonObject.getString("type"));
Integer count = resourceDao.selectCount(queryWrapper);
page.setTotal(count);
return page;
}
@Override
@Transactional
public void updateVisits(Long id) {
ResourceEntity resourceEntity = resourceDao.selectById(id);
ResourceEntity entity = new ResourceEntity();
@ -237,6 +254,12 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
.eq(ResourceEntity::getId, resourceEntity.getId())
.eq(ResourceEntity::getDelFlag, ResourceEntityDelFlag.NORMAL.getFlag());
resourceDao.update(entity, updateWrapper);
ResourceBrowseEntity browseEntity = new ResourceBrowseEntity();
browseEntity.setResourceId(id);
browseEntity.setUserId(SecurityUser.getUserId());
browseEntity.setState(0);
resourceBrowseDao.insert(browseEntity);
}
@Override
@ -245,11 +268,42 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
Long userId = SecurityUser.getUser().getId();
//根据用户收藏和申请数据查出应用领域排名在根据应用领域查询热门能力推荐给用户
List<Map> applyAreaList = resourceDao.selectApplyArea(userId);
//1.没有收藏和申请过按最热能力选取
if (applyAreaList.isEmpty()) {
//没有收藏和申请过按最热能力选取,否则根据应用领域最多类型推荐
JSONObject object = new JSONObject();
object.put("pageNum", 0);
object.put("pageSize", 9);
object.put("orderFiled", "total");
object.put("orderType", "DESC");
Page<ResourceDTO> resultPage = (Page<ResourceDTO>) this.selectMostPopular(object);
if (!applyAreaList.isEmpty()) {
ResourceDTO resourceDTO = new ResourceDTO();
ArrayList<AttrEntity> list = new ArrayList<>();
AttrEntity attrEntity = new AttrEntity();
attrEntity.setAttrType("应用领域");
attrEntity.setAttrValue(applyAreaList.get(0).get("attr_value").toString());
list.add(attrEntity);
resourceDTO.setInfoList(list);
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(resourceDTO));
jsonObject.put("pageNum", 1);
jsonObject.put("pageSize", 9);
jsonObject.put("orderField", "total");
jsonObject.put("orderType", "DESC");
Page<ResourceDTO> Page = (Page<ResourceDTO>) this.pageWithAttrs(jsonObject);
//若查出数据不足9条则在热门能力补充缺少的数量
if (Page.getRecords().size() < 9) {
for (int i = 0; Page.getRecords().size() < 9; i++) {
for (int j = 0; j < Page.getRecords().size(); j++) {
if (!Page.getRecords().get(j).getId().equals(resultPage.getRecords().get(i).getId())) {
Page.getRecords().add(resultPage.getRecords().get(i));
break;
}
}
}
}
return Page;
} else {
return resultPage;
}
return null;
}
@Override
@ -257,4 +311,110 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<Map<String, Object>> amountInfo = resourceDao.getAmountGroupByType();
return amountInfo;
}
@Override
public Long countAllDept() {
return baseDao.countAllDept();
}
@Override
public Object selectDeptList(JSONObject jsonObject) {
ArrayList<Map> resultList = new ArrayList<>();
HashMap<String, Object> resourceMap = new HashMap<>();
resourceMap.put("type", "全部能力目录");
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.in(true, "del_flag", 0, 5)
.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type"));
resourceMap.put("total", resourceDao.selectCount(queryWrapper));
resultList.add(resourceMap);
List<Map<String, Object>> typeMapList = resourceDao.selectGroupByDeptId(jsonObject.getString("type"));
Map<String, List<Map<String, Object>>> listMap = typeMapList.stream()
.collect(Collectors.groupingBy(m -> m.get("type").toString()));
//区级要根据行政区划多加一层结构
listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).forEach(item -> {
HashMap<String, Object> map = new HashMap<>();
map.put("type", item.getKey());
map.put("total", resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type")));
item.getValue().forEach(item1 -> {
item1.remove("type");
});
map.put("dataList", item.getValue());
resultList.add(map);
});
List<Map<String, Object>> areaList = listMap.get("区级");
Map<String, List<Map<String, Object>>> areaTypeList = areaList.stream()
.collect(Collectors.groupingBy(m -> m.get("districtName").toString()));
HashMap<Object, Object> areaMap = new HashMap<>();
areaMap.put("type", "区级");
areaMap.put("total", resourceDao.selectTypeCountByDept("区级", jsonObject.getString("type")));
ArrayList<Map> areaListTemp = new ArrayList<>();
areaTypeList.entrySet().stream().forEach(item -> {
HashMap<String, Object> map = new HashMap<>();
map.put("type", item.getKey());
map.put("total", resourceDao.selectTypeCountByDist(item.getKey(), jsonObject.getString("type")));
item.getValue().forEach(item1 -> {
item1.remove("type");
});
map.put("dataList", item.getValue());
areaListTemp.add(map);
});
areaMap.put("dataList", areaListTemp);
resultList.add(areaMap);
return resultList;
}
@Override
public Object algorithmPage(Map<String, Object> params) {
params.put("pageNum", (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()));
params.put("pageSize", params.get("limit"));
return resourceDao.selectAlgorithmPage(params);
}
@Override
public Long countAllVisits() {
return baseDao.countAllVisits();
}
@Override
public Object selectSourceDepartmentStatistics() {
HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("deptCount", resourceDao.selectDeptCount());
HashMap<String, Object> map = new HashMap() {
{
put("省级", "0");
put("市级", "0");
put("区级", "0");
put("企业", "0");
put("其他", "0");
}
};
List<Map> deptTypeCount = resourceDao.selectDeptTypeCount();
map.entrySet().forEach(item -> {
deptTypeCount.forEach(index -> {
if (index.get("type").equals(item.getKey())) {
item.setValue(index.get("count"));
}
});
});
resultMap.put("deptTypeCount", map);
List<Map> deptTotalCount = resourceDao.selectDeptTotalCount();
HashMap<String, Object> map1 = new HashMap() {
{
put("0", 0);
put("5", 0);
put("10", 0);
put("15", 0);
put("20", 0);
}
};
map1.entrySet().forEach(item -> {
deptTotalCount.forEach(index -> {
if (index.get("type").equals(item.getKey())) {
item.setValue(index.get("total"));
}
});
});
resultMap.put("deptTotalCount", map1);
return resultMap;
}
}

View File

@ -0,0 +1,115 @@
package io.renren.modules.resourceBrowse.controller;
import io.renren.common.annotation.LogOperation;
import io.renren.common.constant.Constant;
import io.renren.common.page.PageData;
import io.renren.common.utils.ExcelUtils;
import io.renren.common.utils.Result;
import io.renren.common.validator.AssertUtils;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
import io.renren.modules.resourceBrowse.excel.ResourceBrowseExcel;
import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
@RestController
@RequestMapping("/resourceBrowse")
@Api(tags="浏览记录")
public class ResourceBrowseController {
@Autowired
private ResourceBrowseService resourceBrowseService;
@GetMapping("/page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
})
//@RequiresPermissions("resourceBrowse:resourcebrowse:page")
public Result<PageData<ResourceBrowseDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<ResourceBrowseDTO> page = resourceBrowseService.page(params);
return new Result<PageData<ResourceBrowseDTO>>().ok(page);
}
@GetMapping("/select/{id}")
@ApiOperation("信息")
//@RequiresPermissions("resourceBrowse:resourcebrowse:info")
public Result<ResourceBrowseDTO> get(@PathVariable("id") Long id){
ResourceBrowseDTO data = resourceBrowseService.get(id);
return new Result<ResourceBrowseDTO>().ok(data);
}
@PostMapping("/insert")
@ApiOperation("保存")
@LogOperation("保存")
//@RequiresPermissions("resourceBrowse:resourcebrowse:save")
public Result save(@RequestBody ResourceBrowseDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
resourceBrowseService.save(dto);
return new Result();
}
//@PutMapping("/update")
//@ApiOperation("修改")
//@LogOperation("修改")
////@RequiresPermissions("resourceBrowse:resourcebrowse:update")
//public Result update(@RequestBody ResourceBrowseDTO dto){
// //效验数据
// ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
//
// resourceBrowseService.update(dto);
//
// return new Result();
//}
@DeleteMapping("/delete")
@ApiOperation("删除")
@LogOperation("删除")
//@RequiresPermissions("resourceBrowse:resourcebrowse:delete")
public Result delete(@RequestBody Long[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
resourceBrowseService.delete(ids);
return new Result();
}
@GetMapping("/export")
@ApiOperation("导出")
@LogOperation("导出")
//@RequiresPermissions("resourceBrowse:resourcebrowse:export")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<ResourceBrowseDTO> list = resourceBrowseService.list(params);
ExcelUtils.exportExcelToTarget(response, null, "浏览记录", list, ResourceBrowseExcel.class);
}
}

View File

@ -0,0 +1,25 @@
package io.renren.modules.resourceBrowse.dao;
import io.renren.common.dao.BaseDao;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
@Mapper
public interface ResourceBrowseDao extends BaseDao<ResourceBrowseEntity> {
Integer selectDayAvg(@Param("days") Long days);
Integer selectDayMax();
List<Map> selectDayList(@Param("startDate") String startDate,@Param("endDate") String endDate);
}

View File

@ -0,0 +1,44 @@
package io.renren.modules.resourceBrowse.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
@Data
@ApiModel(value = "浏览记录")
public class ResourceBrowseDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "用户ID")
private Long userId;
@ApiModelProperty(value = "能力ID")
private Long resourceId;
@ApiModelProperty(value = "状态0:正常,")
private Integer state;
@ApiModelProperty(value = "创建人")
private Long creator;
@ApiModelProperty(value = "创建时间")
private Date createDate;
@ApiModelProperty(value = "修改人")
private Long updater;
@ApiModelProperty(value = "修改时间")
private Date updateDate;
@ApiModelProperty(value = "备用字段1")
private String note1;
@ApiModelProperty(value = "备用字段2")
private String note2;
@ApiModelProperty(value = "备用字段3")
private String note3;
}

View File

@ -0,0 +1,69 @@
package io.renren.modules.resourceBrowse.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.baomidou.mybatisplus.annotation.*;
import java.util.Date;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("tb_resource_browse")
public class ResourceBrowseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId
private Long id;
/**
* 用户ID
*/
private Long userId;
/**
* 能力ID
*/
private Long resourceId;
/**
* 状态0:正常
*/
private Integer state;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
private Long creator;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createDate;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Long updater;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
/**
* 备用字段1
*/
private String note1;
/**
* 备用字段2
*/
private String note2;
/**
* 备用字段3
*/
private String note3;
}

View File

@ -0,0 +1,43 @@
package io.renren.modules.resourceBrowse.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import java.util.Date;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
@Data
@ContentRowHeight(20)
@HeadRowHeight(20)
@ColumnWidth(25)
public class ResourceBrowseExcel {
@ExcelProperty(value = "主键", index = 0)
private Long id;
@ExcelProperty(value = "用户ID", index = 1)
private Long userId;
@ExcelProperty(value = "能力ID", index = 2)
private Long resourceId;
@ExcelProperty(value = "状态0:正常,", index = 3)
private Integer state;
@ExcelProperty(value = "创建人", index = 4)
private Long creator;
@ExcelProperty(value = "创建时间", index = 5)
private Date createDate;
@ExcelProperty(value = "修改人", index = 6)
private Long updater;
@ExcelProperty(value = "修改时间", index = 7)
private Date updateDate;
@ExcelProperty(value = "备用字段1", index = 8)
private String note1;
@ExcelProperty(value = "备用字段2", index = 9)
private String note2;
@ExcelProperty(value = "备用字段3", index = 10)
private String note3;
}

View File

@ -0,0 +1,20 @@
package io.renren.modules.resourceBrowse.service;
import io.renren.common.service.CrudService;
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
public interface ResourceBrowseService extends CrudService<ResourceBrowseEntity, ResourceBrowseDTO> {
Object selectDayAvg();
Object selectDayMax();
Object selectDayList(String startDate, String endDate);
}

View File

@ -0,0 +1,79 @@
package io.renren.modules.resourceBrowse.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.constant.Constant;
import io.renren.common.utils.DateUtils;
import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao;
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
import io.renren.modules.security.user.SecurityUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
@Service
public class ResourceBrowseServiceImpl extends CrudServiceImpl<ResourceBrowseDao, ResourceBrowseEntity, ResourceBrowseDTO> implements ResourceBrowseService {
@Autowired
private ResourceBrowseDao resourceBrowseDao;
@Value("${system.startDay}")
private String systemDay;
@Override
public QueryWrapper<ResourceBrowseEntity> getWrapper(Map<String, Object> params){
QueryWrapper<ResourceBrowseEntity> wrapper = new QueryWrapper<>();
wrapper.eq("state", 0)
.eq("user_id", SecurityUser.getUserId())
.orderByDesc("create_date");
return wrapper;
}
@Override
public Object selectDayAvg() {
Date startDay = DateUtils.stringToDate(systemDay, DateUtils.DATE_PATTERN);
Date today = new Date();
Long days = (today.getTime() - startDay.getTime()) / (1000 * 60 * 60 * 24);
return resourceBrowseDao.selectDayAvg(days);
}
@Override
public Object selectDayMax() {
return resourceBrowseDao.selectDayMax();
}
@Override
public Object selectDayList(String startDate, String endDate) {
List<Map> maps = resourceBrowseDao.selectDayList(startDate, endDate);
Date startDay = DateUtils.parse(startDate, DateUtils.DATE_PATTERN);
Date endDay = DateUtils.parse(endDate, DateUtils.DATE_PATTERN);
ArrayList<String> dayList = new ArrayList<>();
while (startDay.before(endDay)) {
dayList.add(DateUtils.format(startDay, DateUtils.DATE_PATTERN));
startDay = DateUtils.addDateDays(startDay, 1);
}
ArrayList<Map<String, Integer>> resultMap = new ArrayList<>();
for (int i = 0; i < dayList.size(); i++) {
HashMap<String, Integer> dayMap = new HashMap<>();
dayMap.put(dayList.get(i), 0);
for (Map map : maps) {
if (dayList.get(i).equals(map.get("date"))) {
dayMap.put(dayList.get(i), (Integer) map.get("count"));
}
}
resultMap.add(dayMap);
}
return resultMap;
}
}

View File

@ -1,5 +1,6 @@
package io.renren.modules.resourceMountApply.dto;
import io.renren.common.dto.AuditingBaseDTO;
import io.renren.modules.resource.dto.ResourceDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -11,7 +12,7 @@ import java.util.List;
@Data
@ApiModel(value = "批量资源挂载申请表单 前端录入用")
public class TResourceBatchMountApplyDTO implements Serializable {
public class TResourceBatchMountApplyDTO extends AuditingBaseDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "上架申请人id")
@ -36,4 +37,7 @@ public class TResourceBatchMountApplyDTO implements Serializable {
@ApiModelProperty(value = "附件")
private String enclosure;
@ApiModelProperty(value = "附件")
private List<Long> resourceIds;
}

View File

@ -1,6 +1,7 @@
package io.renren.modules.resourceMountApply.dto;
import com.alibaba.fastjson.JSON;
import io.renren.common.dto.AuditingBaseDTO;
import io.renren.modules.resource.dto.ResourceDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -16,7 +17,7 @@ import java.io.Serializable;
*/
@Data
@ApiModel(value = "资源挂载申请表单")
public class TResourceMountApplyDTO implements Serializable {
public class TResourceMountApplyDTO extends AuditingBaseDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
@ -43,11 +44,14 @@ public class TResourceMountApplyDTO implements Serializable {
@ApiModelProperty(value = "附件")
private String enclosure;
@ApiModelProperty(value = "资源id")
private Long resourceId;
public ResourceDTO getResourceDTO() {
if (this.parameterContent != null) {
return JSON.parseObject(this.parameterContent, ResourceDTO.class);
}
return resourceDTO;
return null;
}
public void setResourceDTO(ResourceDTO resourceDTO) {

View File

@ -1,5 +1,6 @@
package io.renren.modules.resourceMountApply.dto;
import io.renren.common.dto.AuditingBaseDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -11,7 +12,7 @@ import java.util.Map;
@Data
@ApiModel(value = "资源下架申请表单")
public class TResourceUndercarriageApplyDTO implements Serializable {
public class TResourceUndercarriageApplyDTO extends AuditingBaseDTO implements Serializable {
@ApiModelProperty(value = "下架申请人id")
private String userId;
@ApiModelProperty(value = "下架申请人名字")

View File

@ -57,4 +57,10 @@ public class TResourceMountApplyEntity extends BaseEntity {
* 附件
*/
private String enclosure;
/**
* 资源id
*/
private Long resourceId;
}

View File

@ -2,9 +2,12 @@ package io.renren.modules.resourceMountApply.listener;
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.ApiGatewayService;
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.SysDeptDTO;
@ -23,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
/**
@ -114,15 +118,22 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A
* @param kv
*/
private void endTake(Map<String, Object> kv) { // 进入最后结束节点
Gson gson = new Gson();
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();
ResourceDTO re = resourceService.get(resourceMountApplyDTO.getResourceId());
if (re != null) {
re.setDelFlag(0);
re.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
resourceService.update(re);
logger.error("审批通过资源id:" + re.getId());
try {
apiGatewayService.registerApi2Gateway(String.valueOf(re.getId())); // 发布到应用网关
} catch (Exception exception) {
logger.error("发布到应用网关", exception);
}
}
}
@ -133,15 +144,15 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A
*/
private void complete(DelegateTask delegateTask) {
Map<String, Object> kv = delegateTask.getVariables();
Gson gson = new Gson();
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);
Long resourceID = resourceMountApplyDTO.getResourceDTO().getId();
// apiGatewayService.registerApi2Gateway(String.valueOf(resourceID));
ResourceDTO re = resourceMountApplyDTO.getResourceDTO();
if (re != null) {
re.setDelFlag(0);
re.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
resourceService.update(re);
}
}
@ -155,12 +166,15 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A
*/
private void create(DelegateTask delegateTask, final SysRoleDTO roleDTO) {
Map<String, Object> kv = delegateTask.getVariables();
Gson gson = new Gson();
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));
ResourceDTO re = resourceMountApplyDTO.getResourceDTO();
if (re.getDeptId() != null) {
ResourceDTO re = resourceMountApplyDTO.getResourceDTO() == null ? resourceService.get(resourceMountApplyDTO.getResourceId()) : resourceMountApplyDTO.getResourceDTO();
if (re != null && re.getDeptId() != null) {
SysDeptDTO deptDTO =
sysDeptService.get(re.getDeptId());
SysUserDTO userDTO = null;

View File

@ -75,7 +75,6 @@ public class ResourceScoreController {
dto.setUserId(user.getId());
dto.setDelFlag(0);
resourceScoreService.save(dto);
return new Result();
}

View File

@ -5,7 +5,6 @@ import com.yawei.pso.PSORequest;
import com.yawei.pso.SSOResponse;
import com.yawei.pso.TicketManager;
import io.renren.common.constant.Constant;
import io.renren.common.exception.ErrorCode;
import io.renren.common.interceptor.Validator;
import io.renren.common.interceptor.YaweiSSOProperties;
import io.renren.common.utils.HttpContextUtils;
@ -15,17 +14,13 @@ import org.apache.http.HttpStatus;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.web.filter.authc.AuthenticatingFilter;
import org.apache.shiro.web.servlet.ShiroHttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ -36,7 +31,6 @@ import java.util.Map;
/**
* oauth2过滤器
*
*/
@Component()
@Scope("prototype")

View File

@ -37,6 +37,12 @@ public class SysDeptDTO extends TreeNode implements Serializable {
@NotBlank(message="{sysdept.name.require}", groups = DefaultGroup.class)
private String name;
@ApiModelProperty(value = "类型1省级部门2市级部门3区级部门4企业")
private Integer type;
@ApiModelProperty(value = "")
private Long district;
@ApiModelProperty(value = "排序")
@Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class)
private Integer sort;
@ -76,6 +82,22 @@ public class SysDeptDTO extends TreeNode implements Serializable {
this.name = name;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Long getDistrict() {
return district;
}
public void setDistrict(Long district) {
this.district = district;
}
public Integer getSort() {
return sort;
}

View File

@ -29,6 +29,14 @@ public class SysDeptEntity extends BaseEntity {
* 部门名称
*/
private String name;
/**
* 类型1省级部门2市级部门3区级部门4企业
*/
private Integer type;
/**
* 地区
*/
private Long district;
/**
* 排序
*/

View File

@ -0,0 +1,115 @@
package io.renren.modules.workDynamics.controller;
import io.renren.common.annotation.LogOperation;
import io.renren.common.constant.Constant;
import io.renren.common.page.PageData;
import io.renren.common.utils.ExcelUtils;
import io.renren.common.utils.Result;
import io.renren.common.validator.AssertUtils;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.workDynamics.dto.WorkDynamicsDTO;
import io.renren.modules.workDynamics.excel.WorkDynamicsExcel;
import io.renren.modules.workDynamics.service.WorkDynamicsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 工作动态
*
* @author dg
* @since 1.0 2022-05-06
*/
@RestController
@RequestMapping("/workdynamics")
@Api(tags="工作动态")
public class WorkDynamicsController {
@Autowired
private WorkDynamicsService workDynamicsService;
@GetMapping("/page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "name", value = "工作动态标题", paramType = "query", dataType="String")
})
//@RequiresPermissions("workDynamics:workdynamics:page")
public Result<PageData<WorkDynamicsDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<WorkDynamicsDTO> page = workDynamicsService.page(params);
return new Result<PageData<WorkDynamicsDTO>>().ok(page);
}
@GetMapping("/select/{id}")
@ApiOperation("信息")
//@RequiresPermissions("workDynamics:workdynamics:info")
public Result<WorkDynamicsDTO> get(@PathVariable("id") Long id){
WorkDynamicsDTO data = workDynamicsService.get(id);
return new Result<WorkDynamicsDTO>().ok(data);
}
@PostMapping("/insert")
@ApiOperation("保存")
@LogOperation("保存")
//@RequiresPermissions("workDynamics:workdynamics:save")
public Result save(@RequestBody WorkDynamicsDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
workDynamicsService.save(dto);
return new Result();
}
@PutMapping("/update")
@ApiOperation("修改")
@LogOperation("修改")
//@RequiresPermissions("workDynamics:workdynamics:update")
public Result update(@RequestBody WorkDynamicsDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
workDynamicsService.update(dto);
return new Result();
}
@DeleteMapping("/delete")
@ApiOperation("删除")
@LogOperation("删除")
//@RequiresPermissions("workDynamics:workdynamics:delete")
public Result delete(@RequestBody Long[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
workDynamicsService.deleteByIds(ids);
return new Result();
}
@GetMapping("/export")
@ApiOperation("导出")
@LogOperation("导出")
//@RequiresPermissions("workDynamics:workdynamics:export")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<WorkDynamicsDTO> list = workDynamicsService.list(params);
ExcelUtils.exportExcelToTarget(response, null, "工作动态", list, WorkDynamicsExcel.class);
}
}

View File

@ -0,0 +1,18 @@
package io.renren.modules.workDynamics.dao;
import io.renren.common.dao.BaseDao;
import io.renren.modules.workDynamics.entity.WorkDynamicsEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 工作动态
*
* @author dg
* @since 1.0 2022-05-06
*/
@Mapper
public interface WorkDynamicsDao extends BaseDao<WorkDynamicsEntity> {
Integer deleteByIds(@Param("ids") Long[] ids);
}

View File

@ -0,0 +1,50 @@
package io.renren.modules.workDynamics.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 工作动态
*
* @author dg
* @since 1.0 2022-05-06
*/
@Data
@ApiModel(value = "工作动态")
public class WorkDynamicsDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
private Long id;
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "导航图保存地址")
private String imageUrl;
@ApiModelProperty(value = "内容")
private String content;
@ApiModelProperty(value = "删除标志0:正常1:删除9:其他")
private Integer delFlag;
@ApiModelProperty(value = "创建人")
private Long creator;
@ApiModelProperty(value = "创建时间")
private Date createDate;
@ApiModelProperty(value = "修改人")
private Long updater;
@ApiModelProperty(value = "修改时间")
private Date updateDate;
@ApiModelProperty(value = "备用字段1")
private String note1;
@ApiModelProperty(value = "备用字段2")
private String note2;
@ApiModelProperty(value = "备用字段3")
private String note3;
@ApiModelProperty(value = "备用字段4")
private String note4;
@ApiModelProperty(value = "备用字段5")
private String note5;
}

View File

@ -0,0 +1,81 @@
package io.renren.modules.workDynamics.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.baomidou.mybatisplus.annotation.*;
import java.util.Date;
/**
* 工作动态
*
* @author dg
* @since 1.0 2022-05-06
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("tb_work_dynamics")
public class WorkDynamicsEntity {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId
private Long id;
/**
* 标题
*/
private String title;
/**
* 导航图保存地址
*/
private String imageUrl;
/**
* 内容
*/
private String content;
/**
* 删除标志0:正常1:删除9:其他
*/
private Integer delFlag;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
private Long creator;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createDate;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Long updater;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
/**
* 备用字段1
*/
private String note1;
/**
* 备用字段2
*/
private String note2;
/**
* 备用字段3
*/
private String note3;
/**
* 备用字段4
*/
private String note4;
/**
* 备用字段5
*/
private String note5;
}

View File

@ -0,0 +1,49 @@
package io.renren.modules.workDynamics.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import java.util.Date;
/**
* 工作动态
*
* @author dg
* @since 1.0 2022-05-06
*/
@Data
@ContentRowHeight(20)
@HeadRowHeight(20)
@ColumnWidth(25)
public class WorkDynamicsExcel {
@ExcelProperty(value = "id", index = 0)
private Long id;
@ExcelProperty(value = "标题", index = 1)
private String title;
@ExcelProperty(value = "导航图保存地址", index = 2)
private String imageUrl;
@ExcelProperty(value = "文件地址", index = 3)
private String fileUrl;
@ExcelProperty(value = "删除标志0:正常1:删除9:其他", index = 4)
private Integer delFlag;
@ExcelProperty(value = "创建人", index = 5)
private Long creator;
@ExcelProperty(value = "创建时间", index = 6)
private Date createDate;
@ExcelProperty(value = "修改人", index = 7)
private Long updater;
@ExcelProperty(value = "修改时间", index = 8)
private Date updateDate;
@ExcelProperty(value = "备用字段1", index = 9)
private String note1;
@ExcelProperty(value = "备用字段2", index = 10)
private String note2;
@ExcelProperty(value = "备用字段3", index = 11)
private String note3;
@ExcelProperty(value = "备用字段4", index = 12)
private String note4;
@ExcelProperty(value = "备用字段5", index = 13)
private String note5;
}

View File

@ -0,0 +1,16 @@
package io.renren.modules.workDynamics.service;
import io.renren.common.service.CrudService;
import io.renren.modules.workDynamics.dto.WorkDynamicsDTO;
import io.renren.modules.workDynamics.entity.WorkDynamicsEntity;
/**
* 工作动态
*
* @author dg
* @since 1.0 2022-05-06
*/
public interface WorkDynamicsService extends CrudService<WorkDynamicsEntity, WorkDynamicsDTO> {
void deleteByIds(Long[] ids);
}

View File

@ -0,0 +1,47 @@
package io.renren.modules.workDynamics.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.constant.Constant;
import io.renren.modules.workDynamics.dao.WorkDynamicsDao;
import io.renren.modules.workDynamics.dto.WorkDynamicsDTO;
import io.renren.modules.workDynamics.entity.WorkDynamicsEntity;
import io.renren.modules.workDynamics.service.WorkDynamicsService;
import io.renren.modules.security.user.SecurityUser;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 工作动态
*
* @author dg
* @since 1.0 2022-05-06
*/
@Service
public class WorkDynamicsServiceImpl extends CrudServiceImpl<WorkDynamicsDao, WorkDynamicsEntity, WorkDynamicsDTO> implements WorkDynamicsService {
@Autowired
private WorkDynamicsDao workDynamicsDao;
@Override
public QueryWrapper<WorkDynamicsEntity> getWrapper(Map<String, Object> params){
QueryWrapper<WorkDynamicsEntity> wrapper = new QueryWrapper<>();
if (ObjectUtil.isNotNull(params.get("name"))) {
wrapper.like("title", params.get("name").toString());
}
wrapper.eq("del_flag", 0)
.orderByDesc("create_date");
return wrapper;
}
@Override
public void deleteByIds(Long[] ids) {
workDynamicsDao.deleteByIds(ids);
}
}

View File

@ -5,7 +5,6 @@ spring:
druid:
#MySQL
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

@ -36,7 +36,7 @@ spring:
multi-statement-allow: true
#上传的静态资源配置
resource:
root_url: 15.2.21.238
root_url: 15.72.183.90
path: /data/services/nengli/files/
devModelFilePath: /data/services/nengli/files/devModelFile
# 大数据部门相关配置

View File

@ -0,0 +1,80 @@
server:
port: 8888
spring:
datasource:
druid:
#MySQL
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://15.2.21.238:3310/share_platform_show?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
username: root
password: Hisense2019
# #Oracle
# driver-class-name: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@192.168.10.10:1521:xe
# username: renren_security
# password: 123456
# #SQLServer
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://localhost:1433;DatabaseName=security_enterprise
# username: sa
# password: 123456
# #postgresql
# driver-class-name: org.postgresql.Driver
# 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
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
#Oracle需要打开注释
validation-query: SELECT 1
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /druid/*
#login-username: admin
#login-password: admin
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
#上传的静态资源配置
resource:
root_url: 15.2.21.238
path: /home/yth/files/
devModelFilePath: /home/yth/files/devModelFile
# 大数据部门相关配置
big_date:
name: 青岛市大数据发展管理局
assignee_role_name: 部门审批人
hisense:
gateway:
url: http://devtest-security-app.hismarttv.com:8080
##多数据源的配置需要引用renren-dynamic-datasource
#dynamic:
# datasource:
# slave1:
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://123456:1433;DatabaseName=security_enterprise
# username: sa
# password: 123456
# slave2:
# driver-class-name: org.postgresql.Driver
# url: jdbc:postgresql://123456:5432/security_enterprise
# username: postgres
# password: 123456

View File

@ -5,6 +5,10 @@ big_date:
# 需要进行统计数目的资源 type
census:
type: 组件服务,应用资源,基础设施,数据资源,知识库
# 海信网关
hisense:
gateway:
url: http://devtest-security-app.hismarttv.com:8080
# Tomcat
server:
tomcat:
@ -20,7 +24,7 @@ server:
http-only: true
spring:
# 环境 dev|test|prod
# 环境 dev|test|prod|show
profiles:
active: dev
messages:
@ -76,3 +80,7 @@ mybatis-plus:
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#系统上线日期,用于统计能力浏览记录
system:
startDay: 2022-01-01

View File

@ -43,7 +43,7 @@
</appender>
<!-- 开发、测试环境 -->
<springProfile name="dev,test">
<springProfile name="dev,test,show">
<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/>
<logger name="io.renren" level="DEBUG"/>

View File

@ -17,5 +17,13 @@
<result property="note4" column="note4"/>
<result property="note5" column="note5"/>
</resultMap>
<select id="commentCount" resultType="java.lang.Long">
SELECT
COUNT( id )
FROM
t_demand_comment
WHERE
target_id = #{dataId};
</select>
</mapper>

View File

@ -24,4 +24,24 @@
WHERE
t1.id = #{businessKey}
</select>
<select id="countApplyAll" resultType="java.lang.Long">
SELECT
COUNT( id )
FROM
t_ability_application
WHERE
approve_status = '通过'
</select>
<select id="getAmountGroupByType" resultType="java.util.Map">
SELECT
tbr.type AS type,
COUNT( taa.id ) AS amount
FROM
t_ability_application AS taa
INNER JOIN tb_data_resource AS tbr ON taa.resource_id = tbr.id
WHERE
taa.approve_status = '通过'
GROUP BY
tbr.type
</select>
</mapper>

View File

@ -30,6 +30,9 @@
<result property="note3" column="note3"/>
<result property="note4" column="note4"/>
<result property="note5" column="note5"/>
<result property="enclosure" column="enclosure"/>
<result property="undercarriageReason" column="undercarriage_reason"/>
<result property="undercarriageUserName" column="undercarriage_user_name"/>
</resultMap>
<resultMap id="resourceDTO" type="io.renren.modules.resource.dto.ResourceDTO">
@ -59,6 +62,9 @@
<result property="note3" column="note3"/>
<result property="note4" column="note4"/>
<result property="note5" column="note5"/>
<result property="enclosure" column="enclosure"/>
<result property="undercarriageReason" column="undercarriage_reason"/>
<result property="undercarriageUserName" column="undercarriage_user_name"/>
<!-- 自定义字段 -->
<result property="deptName" column="deptName"/>
<result property="isCollect" column="isCollect"/>
@ -99,6 +105,7 @@
SELECT
tdr.*,
tda.*,
IFNULL(taa2.approve_status, '未申请') AS "applyState",
IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount",
@ -122,16 +129,30 @@
AND user_id = #{dto.creator}
GROUP BY resource_id
) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, user_id, approve_status FROM t_ability_application WHERE
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1
AND tdr.type = #{dto.type}
<if test="dto.type != null and dto.type != ''">
AND tdr.type LIKE CONCAT('%',#{dto.type},'%')
</if>
AND tdr.del_flag = 0
<if test="dto.name != null and dto.name != ''">
AND tdr.name like CONCAT('%',#{dto.name},'%')
AND tdr.name LIKE CONCAT('%',#{dto.name},'%')
</if>
<if test="dto.districtId != null and dto.districtId != ''">
AND tdr.district_id = #{dto.districtId}
</if>
<if test="null != dto.deptIds and dto.deptIds.size > 0">
AND tdr.dept_id IN
<foreach collection="dto.deptIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="dto.shareCondition != null and dto.shareCondition != ''">
AND tdr.share_condition = #{dto.shareCondition}
</if>
<if test="dto.deptId != null and dto.deptId != ''">
AND tdr.dept_id = #{dto.deptId}
</if>
@ -145,7 +166,7 @@
<foreach collection="dto.infoList" item="item" separator="union all">
SELECT data_resource_id FROM tb_data_attr
WHERE attr_type = #{item.attrType}
AND attr_value = #{item.attrValue}
AND attr_value LIKE CONCAT('%', #{item.attrValue}, '%')
AND del_flag = 0
</foreach>) tb
GROUP BY tb.data_resource_id
@ -189,7 +210,7 @@
1 = 1
AND tdr.del_flag = 0
<if test="type != null and type != ''">
AND tdr.type = #{type}
AND tdr.type LIKE CONCAT('%',#{type},'%')
</if>
<if test="name != null and name != ''">
AND tdr.name LIKE CONCAT('%',#{name},'%')
@ -207,7 +228,7 @@
IFNULL(trc.collectCount, 0) AS "collectCount",
sd.name as "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect",
IFNULL(taa2.applyState, 'false') AS "applyState"
IFNULL(taa2.approve_status, '未申请') AS "applyState"
FROM
tb_data_resource tdr
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id
@ -221,8 +242,7 @@
FROM tb_resource_collection WHERE
1 = 1 AND del_flag = 0 AND user_id = #{userId}
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE approve_status WHEN '通过' THEN 'true' ELSE 'false' END ) AS
"applyState" FROM t_ability_application WHERE
LEFT JOIN ( SELECT resource_id, approve_status FROM t_ability_application WHERE
1 = 1 AND del_flag = 0 AND user_id = #{userId}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
@ -239,7 +259,7 @@
IFNULL(trc.collectCount, 0) AS "collectCount",
sd.name AS "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect",
IFNULL(taa2.applyState, 'false') AS "applyState",
IFNULL(taa2.approve_status, '未申请') AS "applyState",
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0) + IFNULL(collectCount,0)) AS total
FROM
tb_data_resource tdr
@ -253,8 +273,7 @@
FROM tb_resource_collection WHERE
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE approve_status WHEN '通过' THEN 'true' ELSE 'false' END ) AS
"applyState" FROM t_ability_application WHERE
LEFT JOIN ( SELECT resource_id, approve_status FROM t_ability_application WHERE
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
@ -269,6 +288,18 @@
<if test="dto.districtId != null and dto.districtId != ''">
AND tdr.district_id = #{dto.districtId}
</if>
<if test="null != dto.deptIds and dto.deptIds.size > 0">
AND tdr.dept_id IN
<foreach collection="dto.deptIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="dto.shareCondition != null and dto.shareCondition != ''">
AND tdr.share_condition = #{dto.shareCondition}
</if>
<if test="dto.deptId != null and dto.deptId != ''">
AND tdr.dept_id = #{dto.deptId}
</if>
ORDER BY ${orderField} ${orderType}
LIMIT ${pageNum}, ${pageSize}
</select>
@ -318,4 +349,182 @@
GROUP BY
type
</select>
<select id="countAllDept" resultType="java.lang.Long">
SELECT
COUNT( DISTINCT dept_id )
FROM
tb_data_resource
WHERE
del_flag = 0
</select>
<select id="selectGroupByDeptId" resultType="java.util.Map">
SELECT
*
FROM
(
SELECT
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
sd.NAME AS "deptName",
IFNULL( tdr.deptCount, 0 ) AS "deptCount",
sd.id AS "deptId",
sr.name AS "districtName",
sr.id AS "districtId"
FROM
sys_dept sd
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag IN (0 ,5)
<if test="type != null and type != ''">
AND type = #{type}
</if>
GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
LEFT JOIN sys_region sr ON sd.district = sr.id
) temp1
WHERE
1 = 1
AND temp1.deptCount != 0
</select>
<select id="selectTypeCountByDept" resultType="java.lang.Integer">
SELECT
SUM( deptCount )
FROM
(
SELECT
*
FROM
(
SELECT
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
sd.NAME AS "deptName",
IFNULL( tdr.deptCount, 0 ) AS "deptCount"
FROM
sys_dept sd
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag IN (0, 5)
<if test="resourceType != null and resourceType != ''">
AND type = #{resourceType}
</if>
GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
) temp1
WHERE
1 = 1
AND temp1.deptCount != 0
) temp2
WHERE 1 = 1
AND temp2.type = #{deptType}
GROUP BY
temp2.type
</select>
<select id="selectAlgorithmPage" resultType="io.renren.modules.resource.dto.ResourceDTO">
SELECT *
FROM tb_data_resource
WHERE 1 = 1
ORDER BY ${orderField} ${orderType}
LIMIT ${pageNum}, ${pageSize}
</select>
<select id="selectTypeCountByDist" resultType="java.lang.Integer">
SELECT
SUM( deptCount )
FROM
(
SELECT
*
FROM
(
SELECT
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
sd.NAME AS "deptName",
IFNULL( tdr.deptCount, 0) AS "deptCount",
IFNULL(sr.name, '暂无该地区') AS "districtName",
sr.id AS "districtId"
FROM
sys_dept sd
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource
WHERE 1 = 1 AND del_flag IN (0, 5)
<if test="resourceType != null and resourceType != ''">
AND type = #{resourceType}
</if>
GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
LEFT JOIN sys_region sr ON sd.district = sr.id
) temp1
WHERE
1 = 1
AND temp1.deptCount != 0
) temp2
WHERE 1 = 1
AND temp2.districtName = #{districtName}
GROUP BY
temp2.type
</select>
<select id="countAllVisits" resultType="java.lang.Long">
SELECT
COUNT( visits )
FROM
tb_data_resource
</select>
<select id="selectDeptCount" resultType="java.lang.Integer">
SELECT
COUNT( 1 )
FROM
( SELECT DISTINCT dept_id FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 AND dept_id IS NOT NULL ) temp
</select>
<select id="selectDeptTypeCount" resultType="java.util.Map">
SELECT IFNULL(COUNT(deptId),0) AS "count",
type
FROM (
SELECT DISTINCT
tbr.dept_id AS "deptId",
(CASE sd.type
WHEN 1 THEN
'省级'
WHEN 2 THEN
'市级'
WHEN 3 THEN
'区级'
WHEN 4 THEN
'企业' ELSE '其他'
END ) AS "type"
FROM
sys_dept sd
RIGHT JOIN tb_data_resource tbr ON tbr.dept_id = sd.id
WHERE
1 = 1
AND del_flag = 0
AND dept_id IS NOT NULL) temp GROUP BY type
</select>
<select id="selectDeptTotalCount" resultType="java.util.Map">
SELECT
COUNT( type ) AS "total",
type
FROM
(
SELECT
(
CASE
WHEN ( COUNT( id ) BETWEEN 0 AND 5 ) THEN
'0'
WHEN ( COUNT( id ) BETWEEN 5 AND 10 ) THEN
'5'
WHEN ( COUNT( id ) BETWEEN 10 AND 15 ) THEN
'10'
WHEN ( COUNT( id ) BETWEEN 15 AND 20 ) THEN
'15' ELSE '20'
END
) AS "type"
FROM
tb_data_resource
WHERE
del_flag = 0
AND dept_id IS NOT NULL
GROUP BY
dept_id
) temp
GROUP BY
type
</select>
</mapper>

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.renren.modules.resourceBrowse.dao.ResourceBrowseDao">
<resultMap type="io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity" id="resourceBrowseMap">
<result property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="resourceId" column="resource_id"/>
<result property="state" column="state"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
<result property="updater" column="updater"/>
<result property="updateDate" column="update_date"/>
<result property="note1" column="note1"/>
<result property="note2" column="note2"/>
<result property="note3" column="note3"/>
</resultMap>
<select id="selectDayAvg" resultType="java.lang.Integer">
SELECT IFNULL(COUNT(id), 0) / ${days}
FROM tb_resource_browse
WHERE 1 = 1
AND state = 0
</select>
<select id="selectDayMax" resultType="java.lang.Integer">
SELECT IFNULL(MAX(count), 0)
FROM
(SELECT
COUNT( id ) AS "count"
FROM
tb_resource_browse
WHERE
1 = 1
AND state = 0
GROUP BY
SUBSTR(create_date, 1, 10)) temp
</select>
<select id="selectDayList" resultType="java.util.Map">
SELECT
SUBSTR(create_date, 1, 10) AS "date",
COUNT( id ) AS "count"
FROM
tb_resource_browse
WHERE
1 = 1
AND state = 0
AND create_date BETWEEN ${startDate} AND ${endDate}
GROUP BY
SUBSTR(create_date, 1, 10)
</select>
</mapper>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.renren.modules.workDynamics.dao.WorkDynamicsDao">
<resultMap type="io.renren.modules.workDynamics.entity.WorkDynamicsEntity" id="workDynamicsMap">
<result property="id" column="id"/>
<result property="title" column="title"/>
<result property="imageUrl" column="image_url"/>
<result property="content" column="content"/>
<result property="delFlag" column="del_flag"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
<result property="updater" column="updater"/>
<result property="updateDate" column="update_date"/>
<result property="note1" column="note1"/>
<result property="note2" column="note2"/>
<result property="note3" column="note3"/>
<result property="note4" column="note4"/>
<result property="note5" column="note5"/>
</resultMap>
<update id="deleteByIds">
update tb_work_dynamics
set del_flag = 1 ,
update_date = now()
where 1 = 1
and id in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
</mapper>