From cd0aca28c89f1b5511cd922a07303d50110cd24d Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 25 Apr 2022 09:58:12 +0800 Subject: [PATCH] ... --- .../modules/demand/entity/BsDemandEntity.java | 115 +++++++++--------- .../listener/CorrectionListener.java | 69 +++++++---- .../listener/DataCenterListener.java | 36 ++++-- .../controller/ResourceController.java | 56 ++++----- .../service/impl/ResourceServiceImpl.java | 18 +-- .../listener/ResourceOwnerListener.java | 82 +++++++------ 6 files changed, 209 insertions(+), 167 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/demand/entity/BsDemandEntity.java b/renren-admin/src/main/java/io/renren/modules/demand/entity/BsDemandEntity.java index 29e8afed..33f3263c 100644 --- a/renren-admin/src/main/java/io/renren/modules/demand/entity/BsDemandEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/demand/entity/BsDemandEntity.java @@ -1,73 +1,74 @@ package io.renren.modules.demand.entity; -import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.renren.common.entity.BaseEntity; import lombok.Data; import lombok.EqualsAndHashCode; -import com.baomidou.mybatisplus.annotation.*; + import java.util.Date; -import io.renren.common.entity.BaseEntity; /** * 能力需求 * - * @author wxw + * @author wxw * @since 3.0 2022-01-11 */ @Data -@EqualsAndHashCode(callSuper=false) +@EqualsAndHashCode(callSuper = false) @TableName("bs_demand") public class BsDemandEntity extends BaseEntity { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** - * 目录位置 - */ - private String pcode; - /** - * 名称 - */ - private String name; - /** - * 内容 - */ - private String context; - /** - * 建议 - - */ - private String suggest; - /** - * 描述 - */ - private String descripition; - /** - * 图片 - */ - private String images; - /** - * 0-未删除 1-删除 默认0 - */ - private String isDelete; - /** - * 更新者 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private String updater; - /** - * 更新时间 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private Date updateDate; - /** - * 文件 - */ - private String files; - /** - * 状态 - * */ - private String state; - /*** - * 审核意见 - */ - private String opinion; + /** + * 目录位置 + */ + private String pcode; + /** + * 名称 + */ + private String name; + /** + * 内容 + */ + private String context; + /** + * 建议 + */ + private String suggest; + /** + * 描述 + */ + private String descripition; + /** + * 图片 + */ + private String images; + /** + * 0-未删除 1-删除 默认0 + */ + private String isDelete; + /** + * 更新者 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private String updater; + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateDate; + /** + * 文件 + */ + private String files; + /** + * 状态 + */ + private String state; + /*** + * 审核意见 + */ + private String opinion; } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/listener/CorrectionListener.java b/renren-admin/src/main/java/io/renren/modules/processForm/listener/CorrectionListener.java index f325ab65..78f6d492 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/listener/CorrectionListener.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/listener/CorrectionListener.java @@ -53,6 +53,48 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti @Override public void notify(DelegateTask delegateTask) { logger.error("-------------------------进入部门动态审批人流程-------------------------------"); + final String eventName = delegateTask.getEventName(); + switch (eventName) { + case EVENTNAME_CREATE: + create(delegateTask); + break; + default: + } + logger.error("-------------------------结束部门动态审批人流程-------------------------------"); + } + + @Override + public void notify(DelegateExecution delegateExecution) throws Exception { +// logger.info("事件:" + delegateExecution.getEventName()); +// delegateExecution.getVariableNames().stream().forEach(index -> logger.info("variable:" + index)); +// delegateExecution.getVariables().values().stream().filter(index -> index != null).forEach(value -> logger.info(value.toString())); +// // taskService.setAssignee(delegateExecution.getProcessInstanceId(), "1516307964617076737");// 可以设置 +// +// logger.info("修改审批人成功!" + delegateExecution.getCurrentActivityId() + " " + delegateExecution.getProcessInstanceId() + " " + delegateExecution.getProcessBusinessKey()); + } + + @Override + public void onEvent(ActivitiEvent activitiEvent) { // 事件回调 + logger.info("事件类型:" + activitiEvent.getType().toString()); + logger.info("" + activitiEvent.getProcessDefinitionId()); + } + + @Override + public boolean isFailOnException() { + return true; + } + + @Override + public void execute(DelegateExecution delegateExecution) throws Exception { + logger.info("异常", delegateExecution); + } + + /** + * 节点创建时动态分配资源部门审核人 + * + * @param delegateTask + */ + private void create(DelegateTask delegateTask) { Map kv = delegateTask.getVariables(); Gson gson = new Gson(); JsonElement jsonElement = gson.toJsonTree(kv); @@ -95,32 +137,5 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti logger.error("未查到该部门对应的 " + roleName); taskService.setAssignee(delegateTask.getId(), "1513432847327199233"); } - logger.error("-------------------------结束部门动态审批人流程-------------------------------"); - } - - @Override - public void notify(DelegateExecution delegateExecution) throws Exception { -// logger.info("事件:" + delegateExecution.getEventName()); -// delegateExecution.getVariableNames().stream().forEach(index -> logger.info("variable:" + index)); -// delegateExecution.getVariables().values().stream().filter(index -> index != null).forEach(value -> logger.info(value.toString())); -// // taskService.setAssignee(delegateExecution.getProcessInstanceId(), "1516307964617076737");// 可以设置 -// -// logger.info("修改审批人成功!" + delegateExecution.getCurrentActivityId() + " " + delegateExecution.getProcessInstanceId() + " " + delegateExecution.getProcessBusinessKey()); - } - - @Override - public void onEvent(ActivitiEvent activitiEvent) { // 事件回调 - logger.info("事件类型:" + activitiEvent.getType().toString()); - logger.info("" + activitiEvent.getProcessDefinitionId()); - } - - @Override - public boolean isFailOnException() { - return true; - } - - @Override - public void execute(DelegateExecution delegateExecution) throws Exception { - logger.info("异常", delegateExecution); } } diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/listener/DataCenterListener.java b/renren-admin/src/main/java/io/renren/modules/processForm/listener/DataCenterListener.java index 4e3da6d5..eb62ca16 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/listener/DataCenterListener.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/listener/DataCenterListener.java @@ -53,6 +53,32 @@ public class DataCenterListener implements TaskListener, ExecutionListener, Acti @Override public void notify(DelegateTask delegateTask) { logger.info("事件类型:" + delegateTask.getEventName()); + final String eventName = delegateTask.getEventName(); + switch (eventName) { + case EVENTNAME_CREATE: + createEvent(delegateTask); + break; + default: + logger.info("未处理该事件:" + eventName); + } + } + + @Override + public void onEvent(ActivitiEvent activitiEvent) { + + } + + @Override + public boolean isFailOnException() { + return false; + } + + /** + * 节点创建时动态分配大数据局审批人 + * + * @param delegateTask + */ + private void createEvent(DelegateTask delegateTask) { logger.info("大数据局名称:" + bigDateDeptName); SysDeptDTO deptDTO = sysDeptService.getByName(bigDateDeptName); logger.info("deptDTOId:" + deptDTO.getId()); @@ -68,14 +94,4 @@ public class DataCenterListener implements TaskListener, ExecutionListener, Acti logger.info("未查到该部门对应 " + roleName); } } - - @Override - public void onEvent(ActivitiEvent activitiEvent) { - - } - - @Override - public boolean isFailOnException() { - return false; - } } diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index 8019efe3..41012581 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -31,14 +31,14 @@ import java.io.IOException; import java.util.Map; /** -* 资源表 -* -* @author dg -* @since 1.0 2022-04-13 -*/ + * 资源表 + * + * @author dg + * @since 1.0 2022-04-13 + */ @RestController @RequestMapping("/resource") -@Api(tags="资源表") +@Api(tags = "资源表") public class ResourceController { @Value("${resource.devModelFilePath}") @@ -52,15 +52,15 @@ public class ResourceController { @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 = "type", value = "类型", paramType = "query",required = true, dataType="String") , - //@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 = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = "type", value = "类型", paramType = "query", required = true, dataType = "String"), + //@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") }) //@RequiresPermissions("resource:resource:page") - public Result> page(@ApiIgnore @RequestParam Map params){ + public Result> page(@ApiIgnore @RequestParam Map params) { //ResourceDTO resourceDTO = JSON.toJavaObject(jsonObject, ResourceDTO.class); //resourceService.pageWithAttrs(resourceDTO); PageData page = resourceService.page(params); @@ -73,7 +73,7 @@ public class ResourceController { @PostMapping("/pageWithAttrs") @ApiOperation("分页查询资源信息2") @LogOperation("分页查询资源信息2") - public Result pageWithAttrs(@RequestBody JSONObject jsonObject){ + public Result pageWithAttrs(@RequestBody JSONObject jsonObject) { return new Result<>().ok(resourceService.pageWithAttrs(jsonObject)); } @@ -81,7 +81,7 @@ public class ResourceController { @ApiOperation("查询资源详细信息") @LogOperation("查询资源详细信息") //@RequiresPermissions("resource:resource:info") - public Result get(@PathVariable("id") Long id){ + public Result get(@PathVariable("id") Long id) { ResourceDTO data = resourceService.selectWithAttrs(id); return new Result().ok(data); } @@ -89,21 +89,21 @@ public class ResourceController { @GetMapping("/selectTotal") @ApiOperation("查询系统及本部门已汇聚能力") @LogOperation("查询系统及本部门已汇聚能力") - public Result selectTotal(){ + public Result selectTotal() { return new Result<>().ok(resourceService.selectTotal()); } @GetMapping("/selectNewest") @ApiOperation("查询最新上架能力") @LogOperation("查询最新上架能力") - public Result selectNewest(@RequestBody JSONObject jsonObject){ + public Result selectNewest(@RequestBody JSONObject jsonObject) { return new Result<>().ok(resourceService.selectNewest(jsonObject)); } @GetMapping("/selectMostPopular") @ApiOperation("查询热门能力") @LogOperation("查询热门能力") - public Result selectMostPopular(@RequestBody JSONObject jsonObject){ + public Result selectMostPopular(@RequestBody JSONObject jsonObject) { return new Result<>().ok(resourceService.selectMostPopular(jsonObject)); } @@ -122,20 +122,20 @@ public class ResourceController { @ApiOperation("保存") @LogOperation("保存") //@RequiresPermissions("resource:resource:save") - public Result save(@RequestBody ResourceDTO dto){ + public Result save(@RequestBody ResourceDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); resourceService.insertWithAttrs(dto); - return new Result(); + return new Result().ok(dto.getId() == null ? "" : dto.getId()); } @PutMapping("/update") @ApiOperation("修改") @LogOperation("修改") //@RequiresPermissions("resource:resource:update") - public Result update(@RequestBody ResourceDTO dto){ + public Result update(@RequestBody ResourceDTO dto) { ////效验数据 //ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); @@ -148,7 +148,7 @@ public class ResourceController { @ApiOperation("删除") @LogOperation("删除") //@RequiresPermissions("resource:resource:delete") - public Result delete(@RequestBody JSONObject jsonObject){ + public Result delete(@RequestBody JSONObject jsonObject) { resourceService.deleteWithAttrs(jsonObject); @@ -159,16 +159,16 @@ public class ResourceController { @ApiOperation("获取开发指南") @LogOperation("获取开发指南") @ApiImplicitParams({ - @ApiImplicitParam(name = "type", value = "类型", paramType = "query",required = true, dataType="String") , - @ApiImplicitParam(name = "resourceId", value = "能力ID", paramType = "query",required = false, dataType="Long") , - }) - public void getDevelopmentFile(@ApiIgnore HttpServletRequest request, @ApiIgnore HttpServletResponse response){ + @ApiImplicitParam(name = "type", value = "类型", paramType = "query", required = true, dataType = "String"), + @ApiImplicitParam(name = "resourceId", value = "能力ID", paramType = "query", required = false, dataType = "Long"), + }) + public void getDevelopmentFile(@ApiIgnore HttpServletRequest request, @ApiIgnore HttpServletResponse response) { try { resourceService.getDevelopmentFile(request, response); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); - new Result<>().error(500,"文件获取失败!"); + new Result<>().error(500, "文件获取失败!"); } } @@ -178,7 +178,7 @@ public class ResourceController { @ApiImplicitParam(name = "file", value = "开发指南文件", paramType = "file", dataType = "file", required = true) }) public Result upload(@RequestParam("file") MultipartFile uploadFile, - HttpServletRequest request) { + HttpServletRequest request) { logger.info("上传文件:" + uploadFile.getOriginalFilename()); File folder = new File(devModelFilePath); if (!folder.isDirectory()) { diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index 3795b4d8..d268d582 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -41,7 +41,7 @@ import java.util.Map; /** * 资源表 * - * @author dg + * @author dg * @since 1.0 2022-04-13 */ @Service @@ -61,7 +61,7 @@ public class ResourceServiceImpl extends CrudServiceImpl getWrapper(Map params){ + public QueryWrapper getWrapper(Map params) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("type", params.get("type").toString()) .eq("del_flag", 0) @@ -80,7 +80,9 @@ public class ResourceServiceImpl extends CrudServiceImpl attrEntities= dto.getInfoList(); + BeanUtils.copyProperties(resourceEntity, dto); // 将entity id 写入 dto + + List attrEntities = dto.getInfoList(); attrEntities.forEach(item -> { item.setDelFlag(0); item.setDataResourceId(resourceID); @@ -106,7 +108,7 @@ public class ResourceServiceImpl extends CrudServiceImpl list = new ArrayList<>(); list.add(resourceEntity.getId()); attrDao.delete4Resource(list); - List attrEntities= dto.getInfoList(); + List attrEntities = dto.getInfoList(); attrEntities.forEach(item -> { item.setDelFlag(0); attrDao.insert(item); @@ -141,8 +143,8 @@ public class ResourceServiceImpl extends CrudServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq("del_flag", 0) .like(StringUtils.isNotBlank(resourceDTO.getName()), "name", resourceDTO.getName()) - .eq(ObjectUtil.isNotNull(resourceDTO.getDistrictId()),"district_id", resourceDTO.getDistrictId()) - .eq(ObjectUtil.isNotNull(resourceDTO.getDeptId()),"dept_id", resourceDTO.getDeptId()) + .eq(ObjectUtil.isNotNull(resourceDTO.getDistrictId()), "district_id", resourceDTO.getDistrictId()) + .eq(ObjectUtil.isNotNull(resourceDTO.getDeptId()), "dept_id", resourceDTO.getDeptId()) .eq("type", resourceDTO.getType()); Page entityPage = resourceDao.selectPage(page, queryWrapper); ArrayList list = new ArrayList<>(); @@ -163,7 +165,7 @@ public class ResourceServiceImpl extends CrudServiceImpl recordLists = new ArrayList<>(); - for (int i = (pageNum - 1 ) * pageSize; i < j; i++) { + for (int i = (pageNum - 1) * pageSize; i < j; i++) { recordLists.add(resourceDTOS.get(i)); } resultPage.setRecords(recordLists); @@ -237,7 +239,7 @@ public class ResourceServiceImpl extends CrudServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.orderByDesc("create_date") - .eq(StringUtils.isNotBlank(jsonObject.getString("type")),"type", jsonObject.getString("type")); + .eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type")); return resourceDao.selectList(queryWrapper); } diff --git a/renren-admin/src/main/java/io/renren/modules/resourceMountApply/listener/ResourceOwnerListener.java b/renren-admin/src/main/java/io/renren/modules/resourceMountApply/listener/ResourceOwnerListener.java index 6eb93b2e..1339e726 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceMountApply/listener/ResourceOwnerListener.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceMountApply/listener/ResourceOwnerListener.java @@ -66,43 +66,8 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A final String eventName = delegateTask.getEventName(); switch (eventName) { case EVENTNAME_CREATE: // 创建当前审批节点事件 - { - Map kv = delegateTask.getVariables(); - Gson gson = new Gson(); - JsonElement jsonElement = gson.toJsonTree(kv); - TResourceMountApplyDTO resourceMountApplyDTO = gson.fromJson(jsonElement, TResourceMountApplyDTO.class); - logger.info(JSONObject.toJSONString(resourceMountApplyDTO)); - ResourceDTO re = resourceMountApplyDTO.getResourceDTO(); - if (re.getDeptId() != null) { - SysDeptDTO deptDTO = - sysDeptService.get(re.getDeptId()); - SysUserDTO userDTO = null; - if (deptDTO.getId() != null) { - userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId()); // 搜出审批人 - } - if (userDTO != null) { - logger.error("审批人id:" + userDTO.getId()); - taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString()); - } else { - logger.error("未查到该部门对应的 " + roleName); - taskService.setAssignee(delegateTask.getId(), "1513432847327199233"); - } - } else { - logger.info("大数据局名称:" + bigDateDeptName); - SysDeptDTO deptDTO = sysDeptService.getByName(bigDateDeptName); - logger.info("roleDTOId:" + roleDTO.getId()); - SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId()); - - if (userDTO != null) { - logger.info("大数据审批人id:" + userDTO.getId()); - taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString()); - } else { - delegateTask.setAssignee("1513432847327199233"); - logger.info("未查到大数据部门对应 " + roleName); - } - } - } - break; + create(delegateTask, roleDTO); + break; default: logger.info("未处理该事件:" + eventName); } @@ -126,4 +91,47 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A public boolean isFailOnException() { return false; } + + /** + * 节点创建时动态分配资源部门审核人 + * + * @param delegateTask + * @param roleDTO + */ + private void create(DelegateTask delegateTask, final SysRoleDTO roleDTO) { + Map kv = delegateTask.getVariables(); + Gson gson = new Gson(); + JsonElement jsonElement = gson.toJsonTree(kv); + TResourceMountApplyDTO resourceMountApplyDTO = gson.fromJson(jsonElement, TResourceMountApplyDTO.class); + logger.info(JSONObject.toJSONString(resourceMountApplyDTO)); + ResourceDTO re = resourceMountApplyDTO.getResourceDTO(); + if (re.getDeptId() != null) { + SysDeptDTO deptDTO = + sysDeptService.get(re.getDeptId()); + SysUserDTO userDTO = null; + if (deptDTO.getId() != null) { + userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId()); // 搜出审批人 + } + if (userDTO != null) { + logger.error("审批人id:" + userDTO.getId()); + taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString()); + } else { + logger.error("未查到该部门对应的 " + roleName); + taskService.setAssignee(delegateTask.getId(), "1513432847327199233"); + } + } else { + logger.info("大数据局名称:" + bigDateDeptName); + SysDeptDTO deptDTO = sysDeptService.getByName(bigDateDeptName); + logger.info("roleDTOId:" + roleDTO.getId()); + SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId()); + + if (userDTO != null) { + logger.info("大数据审批人id:" + userDTO.getId()); + taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString()); + } else { + taskService.setAssignee(delegateTask.getId(), "1513432847327199233"); + logger.info("未查到大数据部门对应 " + roleName); + } + } + } }