From e0e3450a866886741a497d210b42da7b8bb14fec Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 18 Apr 2022 17:12:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E8=BF=9B=E8=A1=8C=E8=83=BD?= =?UTF-8?q?=E5=8A=9B=E7=94=B3=E8=AF=B7=E6=8E=A5=E5=8F=A3=EF=BC=88=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=8E=A5=E5=8F=A3=E6=90=9E=E5=AE=9A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AbilityCenterController.java | 100 ++++++++++++++++++ .../dto/TAbilityBatchApplicationDTO.java | 35 ++++++ 2 files changed, 135 insertions(+) create mode 100644 renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java create mode 100644 renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityBatchApplicationDTO.java diff --git a/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java new file mode 100644 index 00000000..d41473b8 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java @@ -0,0 +1,100 @@ +package io.renren.common.controller; + + +import cn.hutool.core.util.ObjectUtil; +import io.renren.common.page.PageData; +import io.renren.common.utils.Result; +import io.renren.common.validator.ValidatorUtils; +import io.renren.common.validator.group.AddGroup; +import io.renren.common.validator.group.DefaultGroup; +import io.renren.modules.activiti.dto.ProcessInstanceDTO; +import io.renren.modules.activiti.dto.ProcessStartDTO; +import io.renren.modules.activiti.service.ActProcessService; +import io.renren.modules.activiti.service.ActRunningService; +import io.renren.modules.processForm.dto.TAbilityApplicationDTO; +import io.renren.modules.processForm.dto.TAbilityBatchApplicationDTO; +import io.renren.modules.processForm.service.TAbilityApplicationService; +import org.codehaus.jackson.map.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +/** + * 能力集中中心 接口 + */ +@RestController +@RequestMapping("/ability/center") +public class AbilityCenterController { + @Autowired + private ActProcessService actProcessService; + @Autowired + private TAbilityApplicationService tAbilityApplicationService; + @Autowired + private ActRunningService actRunningService; + + private static Map params = new HashMap() { + { + put("isLatestVersion", true); // 取最新版本 + put("key", "abilityprocess"); // 限定 + } + }; + + + /** + * 批量进行批量能力申请 + * + * @param abilityBatchApplicationDTO + * @return + */ + @PostMapping(value = "/apply") + public Result> apply(@RequestBody TAbilityBatchApplicationDTO abilityBatchApplicationDTO) { + // 仿照请求接口 /act/process/lastestPage + PageData> page = actProcessService.page(params); + if (page.getTotal() <= 0) { // + return new Result().error("联系管理员添加流程"); + } + return new Result().ok(abilityBatchApplicationDTO.getSystem().stream().map(index -> { + TAbilityApplicationDTO tAbilityApplicationDTO = new TAbilityApplicationDTO(); + tAbilityApplicationDTO.setArea(abilityBatchApplicationDTO.getArea()); + tAbilityApplicationDTO.setAttachment(abilityBatchApplicationDTO.getAttachment()); + tAbilityApplicationDTO.setBasis(abilityBatchApplicationDTO.getBasis()); + tAbilityApplicationDTO.setPhone(abilityBatchApplicationDTO.getPhone()); + tAbilityApplicationDTO.setScene(abilityBatchApplicationDTO.getScene()); + tAbilityApplicationDTO.setInstanceId(abilityBatchApplicationDTO.getInstanceId()); + tAbilityApplicationDTO.setUnit(abilityBatchApplicationDTO.getUnit()); + tAbilityApplicationDTO.setUser(abilityBatchApplicationDTO.getUser()); + tAbilityApplicationDTO.setSystem(index); + // 仿照请求接口 /processForm/tabilityapplication + ValidatorUtils.validateEntity(tAbilityApplicationDTO, AddGroup.class, DefaultGroup.class); + tAbilityApplicationService.save(tAbilityApplicationDTO); // 写能力申请数据 + if (tAbilityApplicationDTO.getId() == null) { + return null; + } + + // 仿照请求接口 /act/running/startOfBusinessKey + ProcessStartDTO processStartDTO = new ProcessStartDTO(); + processStartDTO.setBusinessKey(tAbilityApplicationDTO.getId().toString()); + processStartDTO.setProcessDefinitionKey("abilityprocess"); //限定 + ObjectMapper oMapper = new ObjectMapper(); + Map variables = oMapper.convertValue(tAbilityApplicationDTO, Map.class); + processStartDTO.setVariables(variables); + ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO); + + if (Long.valueOf(dto.getBusinessKey()) != null) { + // 仿照请求接口 /processForm/tabilityapplication/updateInstanceId + tAbilityApplicationService.updateInstanceId(dto.getProcessInstanceId(), Long.valueOf(dto.getBusinessKey())); + } + return dto; + }).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList())); + } + + +} diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityBatchApplicationDTO.java b/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityBatchApplicationDTO.java new file mode 100644 index 00000000..7647ddf2 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityBatchApplicationDTO.java @@ -0,0 +1,35 @@ +package io.renren.modules.processForm.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + + +@Data +@ApiModel(value = "批量能力申请表单") +public class TAbilityBatchApplicationDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + @ApiModelProperty(value = "申请人") + private String user; + @ApiModelProperty(value = "申请人电话") + private String phone; + @ApiModelProperty(value = "申请人单位") + private String unit; + @ApiModelProperty(value = "申请人所在地区") + private String area; + @ApiModelProperty(value = "申请应用系统") + private List system; + @ApiModelProperty(value = "申请场景") + private String scene; + @ApiModelProperty(value = "申请依据") + private String basis; + @ApiModelProperty(value = "申请附件") + private String attachment; + @ApiModelProperty(value = "实例ID") + private String instanceId; +}