diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/controller/TAbilityApplicationController.java b/renren-admin/src/main/java/io/renren/modules/processForm/controller/TAbilityApplicationController.java index c2258d68..32887e74 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/controller/TAbilityApplicationController.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/controller/TAbilityApplicationController.java @@ -1,5 +1,6 @@ package io.renren.modules.processForm.controller; +import com.alibaba.fastjson.JSON; import io.renren.common.annotation.LogOperation; import io.renren.common.constant.Constant; import io.renren.common.page.PageData; @@ -22,6 +23,7 @@ import io.renren.modules.resource.service.ResourceService; import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.UserDetail; import io.renren.modules.sys.dto.SysDeptDTO; +import io.renren.modules.sys.service.SysDeptService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -34,6 +36,7 @@ import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import javax.servlet.http.HttpServletResponse; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -59,6 +62,8 @@ public class TAbilityApplicationController { private ActivitiService activitiService; @Autowired private JdbcTemplate jdbcTemplate; + @Autowired + private SysDeptService sysDeptService; @Value("${project.place}") private Integer projectPlace; @@ -70,14 +75,8 @@ public class TAbilityApplicationController { * @return */ @GetMapping("my_page") - @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 = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String") - }) + @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")}) public Result> myPage(@ApiIgnore @RequestParam Map params) { final UserDetail user = SecurityUser.getUser(); params.put("abilityprocess_v2", Boolean.TRUE); // 是否根据流程 abilityprocess_v2 来分页 @@ -86,6 +85,24 @@ public class TAbilityApplicationController { return new Result>().ok(page); } + /** + * 更新旧数据(无申请能力所属部门) + * + * @return + */ + + @GetMapping("deal") + public Result test() { + List> re = jdbcTemplate.queryForList("SELECT t_ability_application.id,t_ability_application.resource_id,tb_data_resource.dept_id from t_ability_application JOIN tb_data_resource ON t_ability_application.resource_id = tb_data_resource.id WHERE resource_owner_dept IS NULL;"); + re.stream().forEach(index -> { + SysDeptDTO sysDeptDTO = sysDeptService.get(Long.valueOf(index.get("dept_id").toString())); + if (sysDeptDTO != null) { + jdbcTemplate.update(String.format("UPDATE t_ability_application SET resource_owner_dept = '%s' WHERE id = %s", JSON.toJSONString(sysDeptDTO), index.get("id").toString())); + } + }); + return new Result().ok(LocalDateTime.now().toString()); + } + @GetMapping("getByApplyFlag/{applyFlag}") @ApiOperation("根据申请标识获取能力申请信息") @LogOperation("根据申请标识获取能力申请信息") @@ -98,65 +115,59 @@ public class TAbilityApplicationController { } }; List applicationDTOS = tAbilityApplicationService.list(params); - Map> result = - applicationDTOS.stream().collect(Collectors.groupingBy(t -> { - SysDeptDTO sysDeptDTO = t.getResourceOwnerDept(); - if (sysDeptDTO == null) { - return "无部门信息"; // 无部门信息 - } else { - return sysDeptDTO.getName(); - } - })); + Map> result = applicationDTOS.stream().collect(Collectors.groupingBy(t -> { + SysDeptDTO sysDeptDTO = t.getResourceOwnerDept(); + if (sysDeptDTO == null) { + return "无部门信息"; // 无部门信息 + } else { + return sysDeptDTO.getName(); + } + })); if (applicationDTOS.isEmpty()) { return new Result().ok(null); } TAbilityApplicationV2DTO tAbilityApplicationV2DTO = ConvertUtils.sourceToTarget(applicationDTOS.get(0), TAbilityApplicationV2DTO.class); - Map>> re = - result.keySet().stream().map(index -> { - final List tAbilityApplicationDTOList = result.get(index); - List resourceDTOS = - tAbilityApplicationDTOList.stream() - .filter(tAbilityApplicationDTO -> StringUtils.isEmpty(tAbilityApplicationDTO.getCameraList())) // 过滤非摄像头申请 - .map(tAbilityApplicationDTO -> resourceService.get(Long.valueOf(tAbilityApplicationDTO.getResourceId()))).collect(Collectors.toList()); - List taskHandleDetailInfo = activitiService.getTaskHandleDetailInfo(tAbilityApplicationDTOList.get(0).getInstanceId()); + Map>> re = result.keySet().stream().map(index -> { + final List tAbilityApplicationDTOList = result.get(index); + List resourceDTOS = tAbilityApplicationDTOList.stream().filter(tAbilityApplicationDTO -> StringUtils.isEmpty(tAbilityApplicationDTO.getCameraList())) // 过滤非摄像头申请 + .map(tAbilityApplicationDTO -> resourceService.get(Long.valueOf(tAbilityApplicationDTO.getResourceId()))).collect(Collectors.toList()); + List taskHandleDetailInfo = activitiService.getTaskHandleDetailInfo(tAbilityApplicationDTOList.get(0).getInstanceId()); - List camera = new ArrayList<>(); - switch (Constant.ProjectPlace.getByFlag(projectPlace)) { // 处理基础设施 - case TSINGTAO_XHA: - break; - case TSINGTAO: { // 大数据局 - camera = tAbilityApplicationDTOList.stream() - .filter(tAbilityApplicationDTO -> StringUtils.isNotEmpty(tAbilityApplicationDTO.getCameraList())) - .map(index_ -> jdbcTemplate.queryForObject("SELECT * FROM t_camera_channel WHERE idt_camera_channel = " + index_.getResourceId(), Map.class)) - .filter(index_ -> !index_.isEmpty()).collect(Collectors.toList()); - } - break; - case BAOTOU: - case UNKNOWN: - default: + List camera = new ArrayList<>(); + switch (Constant.ProjectPlace.getByFlag(projectPlace)) { // 处理基础设施 + case TSINGTAO_XHA: + break; + case TSINGTAO: { // 大数据局 + camera = (List) resourceService.getApplyCameraList(Long.valueOf(tAbilityApplicationDTOList.get(0).getInstanceId())); +// camera = tAbilityApplicationDTOList.stream().filter(tAbilityApplicationDTO -> StringUtils.isNotEmpty(tAbilityApplicationDTO.getCameraList())).map(index_ -> jdbcTemplate.queryForObject("SELECT * FROM t_camera_channel WHERE idt_camera_channel = " + index_.getResourceId(), Map.class)).filter(index_ -> !index_.isEmpty()).collect(Collectors.toList()); + } + break; + case BAOTOU: + case UNKNOWN: + default: + } + + List finalCamera = camera; + Map resourceApplication = new HashMap() { + { + put("instanceId", tAbilityApplicationDTOList.get(0).getInstanceId()); // 流程id + put("resourceOwnerDept", tAbilityApplicationDTOList.get(0).getResourceOwnerDept()); // 资源所属部门信息 + put("resources", resourceDTOS);//申请的该部门的能力资源 + put("taskHandleDetailInfo", taskHandleDetailInfo); // 流程详情 + if (!finalCamera.isEmpty()) { + put("camera", finalCamera); // 流程详情 } - - List finalCamera = camera; - Map resourceApplication = new HashMap() { - { - put("instanceId", tAbilityApplicationDTOList.get(0).getInstanceId()); // 流程id - put("resourceOwnerDept", tAbilityApplicationDTOList.get(0).getResourceOwnerDept()); // 资源所属部门信息 - put("resources", resourceDTOS);//申请的该部门的能力资源 - put("taskHandleDetailInfo", taskHandleDetailInfo); // 流程详情 - if (!finalCamera.isEmpty()) { - put("camera", finalCamera); // 流程详情 - } - } - }; - return resourceApplication; - }).collect(Collectors.groupingBy(t -> { - SysDeptDTO sysDeptDTO = (SysDeptDTO) t.get("resourceOwnerDept"); - if (sysDeptDTO == null) { - return "未知部门"; // 无部门信息 - } else { - return sysDeptDTO.getName(); - } - })); + } + }; + return resourceApplication; + }).collect(Collectors.groupingBy(t -> { + SysDeptDTO sysDeptDTO = (SysDeptDTO) t.get("resourceOwnerDept"); + if (sysDeptDTO == null) { + return "未知部门"; // 无部门信息 + } else { + return sysDeptDTO.getName(); + } + })); tAbilityApplicationV2DTO.setResourceApplication(re); return new Result().ok(tAbilityApplicationV2DTO); } @@ -164,12 +175,7 @@ public class TAbilityApplicationController { @GetMapping("page") @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 = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String") - }) + @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")}) public Result> page(@ApiIgnore @RequestParam Map params) { PageData page = tAbilityApplicationService.page(params); @@ -229,10 +235,7 @@ public class TAbilityApplicationController { @PostMapping("updateInstanceId") @ApiOperation("更新实例ID") @LogOperation("更新实例ID") - @ApiImplicitParams({ - @ApiImplicitParam(name = "businessKey", value = "业务KEY", paramType = "query", required = true, dataType = "String"), - @ApiImplicitParam(name = "processInstanceId", value = "实例ID", paramType = "query", required = true, dataType = "String") - }) + @ApiImplicitParams({@ApiImplicitParam(name = "businessKey", value = "业务KEY", paramType = "query", required = true, dataType = "String"), @ApiImplicitParam(name = "processInstanceId", value = "实例ID", paramType = "query", required = true, dataType = "String")}) public Result updateInstanceId(String businessKey, String processInstanceId) { Long id = Long.valueOf(businessKey); tAbilityApplicationService.updateInstanceId(processInstanceId, id);