批量进行能力申请接口(一个接口搞定)
This commit is contained in:
parent
e1c935a254
commit
e0e3450a86
|
@ -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<String, Object> params = new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("isLatestVersion", true); // 取最新版本
|
||||||
|
put("key", "abilityprocess"); // 限定
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量进行批量能力申请
|
||||||
|
*
|
||||||
|
* @param abilityBatchApplicationDTO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/apply")
|
||||||
|
public Result<List<ProcessInstanceDTO>> apply(@RequestBody TAbilityBatchApplicationDTO abilityBatchApplicationDTO) {
|
||||||
|
// 仿照请求接口 /act/process/lastestPage
|
||||||
|
PageData<Map<String, Object>> 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<String, Object> 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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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<String> system;
|
||||||
|
@ApiModelProperty(value = "申请场景")
|
||||||
|
private String scene;
|
||||||
|
@ApiModelProperty(value = "申请依据")
|
||||||
|
private String basis;
|
||||||
|
@ApiModelProperty(value = "申请附件")
|
||||||
|
private String attachment;
|
||||||
|
@ApiModelProperty(value = "实例ID")
|
||||||
|
private String instanceId;
|
||||||
|
}
|
Loading…
Reference in New Issue