From 82fbd8493d34e6b14f36e18a92039040473ef769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E9=A3=9E=E5=AE=87?= <2684146481@qq.com> Date: Wed, 12 Apr 2023 10:53:17 +0800 Subject: [PATCH] TaskFeignClientFallback --- .../defect/entity/OperDefectEntity.java | 147 +++++++------ .../inspect/areamonthly/feign/TaskFeignClient.java | 6 +- .../feign/fallback/TaskFeignClientFallback.java | 6 + .../inspect/task/controller/TaskController.java | 2 +- .../defect/controller/OperDefectController.java | 244 +++++++++++---------- 5 files changed, 209 insertions(+), 196 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperDefectEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperDefectEntity.java index 14d1094..fba3124 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperDefectEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperDefectEntity.java @@ -12,12 +12,13 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import org.springframework.format.annotation.DateTimeFormat; +import java.time.YearMonth; import java.util.Date; import java.util.List; /** - * 实体类 + * 实体类 * * @author Chill */ @@ -27,83 +28,85 @@ import java.util.List; @ApiModel(value = "缺陷表", description = "缺陷表") public class OperDefectEntity extends TenantEntity { - private static final long serialVersionUID = -3122149146340663132L; + private static final long serialVersionUID = -3122149146340663132L; - /** - * 现象/缺陷编码 - */ - @QueryField(condition = SqlCondition.LIKE) - @ApiModelProperty(value = "现象/缺陷编码") - private String defectCode; - /** - * 处理流程Key - */ - @QueryField(condition = SqlCondition.EQUAL) - @ApiModelProperty(value = "处理流程Key") - private String procDefId; - /** - * 处理工作流实例ID - */ - @ApiModelProperty(value = "处理工作流实例ID") - private String processInstanceId; - /** - * 处理状态 - */ - @QueryField(condition = SqlCondition.EQUAL) - @ApiModelProperty(value = "处理状态") - private String handleStatus; + /** + * 现象/缺陷编码 + */ + @QueryField(condition = SqlCondition.LIKE) + @ApiModelProperty(value = "现象/缺陷编码") + private String defectCode; + /** + * 处理流程Key + */ + @QueryField(condition = SqlCondition.EQUAL) + @ApiModelProperty(value = "处理流程Key") + private String procDefId; + /** + * 处理工作流实例ID + */ + @ApiModelProperty(value = "处理工作流实例ID") + private String processInstanceId; + /** + * 处理状态 + */ + @QueryField(condition = SqlCondition.EQUAL) + @ApiModelProperty(value = "处理状态") + private String handleStatus; - /** - * 处理方式 - */ - @QueryField(condition = SqlCondition.EQUAL) - @ApiModelProperty(value = "处理方式") - private Integer handleType; + /** + * 处理方式 + */ + @QueryField(condition = SqlCondition.EQUAL) + @ApiModelProperty(value = "处理方式") + private Integer handleType; - /** - * 实际开始时间 - */ - @DateTimeFormat( - pattern = "yyyy-MM-dd HH:mm:ss" - ) - @JsonFormat( - pattern = "yyyy-MM-dd HH:mm:ss" - ) - @ApiModelProperty("实际开始时间") - private Date actStartTime; + /** + * 实际开始时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("实际开始时间") + private Date actStartTime; - /** - * 实际结束时间 - */ - @DateTimeFormat( - pattern = "yyyy-MM-dd HH:mm:ss" - ) - @JsonFormat( - pattern = "yyyy-MM-dd HH:mm:ss" - ) - @ApiModelProperty(value = "实际结束时间") - private Date actEndTime; - /** - * 实际工时,多个处理人工时逗号隔开 - */ - @ApiModelProperty(value = "实际工时,多个处理人工时逗号隔开") - private String actHours; + /** + * 实际结束时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "实际结束时间") + private Date actEndTime; + /** + * 实际工时,多个处理人工时逗号隔开 + */ + @ApiModelProperty(value = "实际工时,多个处理人工时逗号隔开") + private String actHours; - /** - * 最后处理人处理描述 - */ - @ApiModelProperty(value = "最后处理人处理描述") - private String disposeDesc; + /** + * 最后处理人处理描述 + */ + @ApiModelProperty(value = "最后处理人处理描述") + private String disposeDesc; - @TableField(exist=false) - @ApiModelProperty(value = "开始时间") - private String startTime; + @TableField(exist = false) + @ApiModelProperty(value = "开始时间") + private String startTime; - @TableField(exist=false) - @ApiModelProperty(value = "结束时间") - private String endTime; + @TableField(exist = false) + @ApiModelProperty(value = "结束时间") + private String endTime; - @TableField(exist=false) - @ApiModelProperty(value = "机构编号集合") - private List deptIds; + @TableField(exist = false) + @ApiModelProperty(value = "机构编号集合") + private List deptIds; + + + /** + * 区域Id + */ + private String areaId; + /** + * 年月 + */ + private YearMonth yearMonth; } diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/TaskFeignClient.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/TaskFeignClient.java index 9f7f51f..ba56f8c 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/TaskFeignClient.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/TaskFeignClient.java @@ -1,6 +1,5 @@ package com.hnac.hzinfo.inspect.areamonthly.feign; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzinfo.inspect.areamonthly.feign.fallback.TaskFeignClientFallback; import com.hnac.hzinfo.inspect.areamonthly.vo.TaskListQuery; import com.hnac.hzinfo.inspect.areamonthly.vo.TaskVo; @@ -11,8 +10,6 @@ import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import static com.hnac.hzinfo.inspect.Constants.APP_NAME; @@ -31,8 +28,7 @@ public interface TaskFeignClient { @ApiOperation(value = "分页显示任务列表", notes = "传入task") public R> list(TaskListQuery task, Query query); - - @RequestMapping(value = "/task/detail", method = {RequestMethod.GET, RequestMethod.POST}) + @GetMapping(value = "/task/detail") @ApiOperation(value = "查看,下面列表再调用eventController.list", notes = "传入taskid") public R detail(@RequestParam Long id); } diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/fallback/TaskFeignClientFallback.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/fallback/TaskFeignClientFallback.java index 038046b..adbbad2 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/fallback/TaskFeignClientFallback.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/fallback/TaskFeignClientFallback.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzinfo.inspect.areamonthly.feign.TaskFeignClient; import com.hnac.hzinfo.inspect.areamonthly.vo.TaskListQuery; import com.hnac.hzinfo.inspect.areamonthly.vo.TaskVo; +import com.hnac.hzinfo.inspect.task.entity.TaskEntity; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Query; @@ -24,4 +25,9 @@ public class TaskFeignClientFallback implements TaskFeignClient { return R.fail("远程调用失败"); } + + @Override + public R detail(Long id) { + return R.fail("远程调用失败"); + } } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java index ce8422c..7273e46 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java @@ -70,7 +70,7 @@ public class TaskController extends BladeController { /** * 查看任务详情 */ - @RequestMapping(value = "/detail", method = {RequestMethod.GET, RequestMethod.POST}) + @GetMapping(value = "/detail") @ApiOperation(value = "查看,下面列表再调用eventController.list", notes = "传入taskid") public R detail(@RequestParam Long id) { TaskEntity detail = taskService.getById(id); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java index d075403..dd4a6a2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java @@ -2,6 +2,7 @@ package com.hnac.hzims.operational.defect.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.invalid.DictInvalid; import com.hnac.hzims.common.invalid.ObjectRequiredInvalid; @@ -19,6 +20,7 @@ import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.log.annotation.ApiLog; +import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -29,6 +31,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.time.YearMonth; import java.util.HashMap; import java.util.Map; @@ -44,135 +47,140 @@ import java.util.Map; @Validated public class OperDefectController extends BladeController { - private final IOperDefectService defectService; - - /** - * 详情 - */ - @GetMapping("/detail") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "详情", notes = "传入defect") - public R detail(OperDefectEntity defect) { - return defectService.detail(defect); - } - - /** - * 分页 代码自定义代号 - */ - @ApiLog - @GetMapping("/list") - @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入defect") - @ApiImplicitParams({ - }) - @OperationAnnotation(moduleName = "缺陷管理", - title = "缺陷库",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,action - = "分页") - public R> list(OperDefectEntity defect, Query query) { - LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new OperDefectEntity(), defect); - if (defect.getActStartTime() != null) { - queryWrapper.ge(OperDefectEntity::getActStartTime, defect.getActStartTime()); - } - if (defect.getActEndTime() != null) { - queryWrapper.le(OperDefectEntity::getActEndTime, defect.getActEndTime()); - } - if (defect.getStartTime() != null) { - queryWrapper.ge(OperDefectEntity::getCreateTime, defect.getStartTime()); - } - if (defect.getEndTime() != null) { - queryWrapper.le(OperDefectEntity::getCreateTime, defect.getEndTime()); - } - queryWrapper.orderByDesc(OperDefectEntity::getActStartTime); - IPage pages = defectService.page(Condition.getPage(query), queryWrapper); - IPage vos = OperDefectWrapper.build().pageVO(pages); - return R.data(vos); - } - - - /* - */ + private final IOperDefectService defectService; + + /** + * 详情 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入defect") + public R detail(OperDefectEntity defect) { + return defectService.detail(defect); + } + + /** + * 分页 代码自定义代号 + */ + @ApiLog + @GetMapping("/list") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "分页", notes = "传入defect") + @ApiImplicitParams({ + }) + @OperationAnnotation(moduleName = "缺陷管理", + title = "缺陷库", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, action + = "分页") + public R> list(OperDefectEntity defect, Query query) { + LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new OperDefectEntity(), defect); + if (defect.getActStartTime() != null) { + queryWrapper.ge(OperDefectEntity::getActStartTime, defect.getActStartTime()); + } + if (defect.getActEndTime() != null) { + queryWrapper.le(OperDefectEntity::getActEndTime, defect.getActEndTime()); + } + if (defect.getStartTime() != null) { + queryWrapper.ge(OperDefectEntity::getCreateTime, defect.getStartTime()); + } + if (defect.getEndTime() != null) { + queryWrapper.le(OperDefectEntity::getCreateTime, defect.getEndTime()); + } + + queryWrapper.eq(StringUtils.isNotBlank(defect.getAreaId()), BaseEntity::getCreateDept, defect.getCreateDept()); + + queryWrapper.apply(defect.getYearMonth() != null,"date_format(CREATE_TIME,'%Y-%m')", defect.getYearMonth()); + + queryWrapper.orderByDesc(OperDefectEntity::getActStartTime); + IPage pages = defectService.page(Condition.getPage(query), queryWrapper); + IPage vos = OperDefectWrapper.build().pageVO(pages); + return R.data(vos); + } + + + /* + */ /** * 新增 代码自定义代号 - *//* + */ /* - @PostMapping("/save") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "新增", notes = "传入defect") - public R save(@Valid @RequestBody OperDefectEntity defect) { - return R.status(defectService.save(defect)); - } + @PostMapping("/save") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "新增", notes = "传入defect") + public R save(@Valid @RequestBody OperDefectEntity defect) { + return R.status(defectService.save(defect)); + } - */ + */ /** * 修改 代码自定义代号 - *//* + */ /* - @PostMapping("/update") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "修改", notes = "传入defect") - public R update(@Valid @RequestBody OperDefectEntity defect) { - return R.status(defectService.updateById(defect)); - } + @PostMapping("/update") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "修改", notes = "传入defect") + public R update(@Valid @RequestBody OperDefectEntity defect) { + return R.status(defectService.updateById(defect)); + } - */ + */ /** * 新增或修改 代码自定义代号 - *//* - - @PostMapping("/submit") - @ApiOperationSupport(order = 6) - @ApiOperation(value = "新增或修改", notes = "传入defect") - public R submit(@Valid @RequestBody OperDefectEntity defect) { - return R.status(defectService.saveOrUpdate(defect)); - } + */ /* + + @PostMapping("/submit") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "新增或修改", notes = "传入defect") + public R submit(@Valid @RequestBody OperDefectEntity defect) { + return R.status(defectService.saveOrUpdate(defect)); + } */ - /* */ - - /** - * 删除 代码自定义代号 - *//* - @PostMapping("/remove") - @ApiOperationSupport(order = 7) - @ApiOperation(value = "逻辑删除", notes = "传入ids") - public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(defectService.deleteLogic(Func.toLongList(ids))); - }*/ - @PostMapping("/handleProcess") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "执行问题处理流程", notes = "执行问题处理流程") - public R handleProcess(@RequestBody @ObjectRequiredInvalid(attributes = {"taskId", "processInstanceId", "comment", "flag", - "variables.pass", "variables.handleStatus", "variables.disposeDesc", "variables.actHours", "variables.actStartTime", "variables.actEndTime"}, message = "参数不能为空") @DictInvalid(dictKey = "defectHandleStatus",attribute = "variables.handleStatus") BladeFlow flow) { - - return R.status(defectService.handleProcess(flow)); - } - - - /** - * 获取缺陷的统计月报 - */ - @ApiLog - @GetMapping("/getDefectStatistics") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "获取缺陷的统计月报", notes = " month 格式:2021-01") - @OperationAnnotation(moduleName = "缺陷管理",title = "缺陷月报表",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE, - action = "获取缺陷的统计月报") - public R> getDefectStatistics(@ApiParam(value = "month 格式:2021-01", required = true) @RequestParam String month) { - Map defectStatistics = defectService.getDefectStatistics(month); - return R.data(defectStatistics); - } - - @ApiOperation(value = "缺陷月报表导出-Excel") - @RequestMapping(value = "/exportFualtMonthExcel", method = {RequestMethod.GET, RequestMethod.POST}) - public void exportFualtMonthExcel(HttpServletResponse response, @ApiParam(value = "month 格式:2021-01", required = true) @RequestParam String month) { - Map result = new HashMap<>(); - try { - defectService.exportFualtMonthExcel(response, month); - result.put("success", "true"); - } catch (IOException e) { - result.put("success", "false"); - result.put("msg", "按月巡检详细信息导出失败-" + e.getMessage()); - } - } + /* */ + + /** + * 删除 代码自定义代号 + */ /* + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "逻辑删除", notes = "传入ids") + public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return R.status(defectService.deleteLogic(Func.toLongList(ids))); + }*/ + @PostMapping("/handleProcess") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "执行问题处理流程", notes = "执行问题处理流程") + public R handleProcess(@RequestBody @ObjectRequiredInvalid(attributes = {"taskId", "processInstanceId", "comment", "flag", + "variables.pass", "variables.handleStatus", "variables.disposeDesc", "variables.actHours", "variables.actStartTime", "variables.actEndTime"}, message = "参数不能为空") @DictInvalid(dictKey = "defectHandleStatus", attribute = "variables.handleStatus") BladeFlow flow) { + + return R.status(defectService.handleProcess(flow)); + } + + + /** + * 获取缺陷的统计月报 + */ + @ApiLog + @GetMapping("/getDefectStatistics") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "获取缺陷的统计月报", notes = " month 格式:2021-01") + @OperationAnnotation(moduleName = "缺陷管理", title = "缺陷月报表", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, + action = "获取缺陷的统计月报") + public R> getDefectStatistics(@ApiParam(value = "month 格式:2021-01", required = true) @RequestParam String month) { + Map defectStatistics = defectService.getDefectStatistics(month); + return R.data(defectStatistics); + } + + @ApiOperation(value = "缺陷月报表导出-Excel") + @RequestMapping(value = "/exportFualtMonthExcel", method = {RequestMethod.GET, RequestMethod.POST}) + public void exportFualtMonthExcel(HttpServletResponse response, @ApiParam(value = "month 格式:2021-01", required = true) @RequestParam String month) { + Map result = new HashMap<>(); + try { + defectService.exportFualtMonthExcel(response, month); + result.put("success", "true"); + } catch (IOException e) { + result.put("success", "false"); + result.put("msg", "按月巡检详细信息导出失败-" + e.getMessage()); + } + } }