From 09b9e92585976a2b9e8afc10accc6c87a9efc2a8 Mon Sep 17 00:00:00 2001 From: Loki <654612@qq.com> Date: Thu, 2 Jun 2022 10:56:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=B4=BB=E5=8A=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3-=E4=BB=BB=E5=8A=A1=E7=8A=B6=E6=80=81=E6=9E=9A?= =?UTF-8?q?=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/YudaoMybatisAutoConfiguration.java | 1 + .../config/YudaoJacksonAutoConfiguration.java | 4 ++- .../src/main/resources/application-dev.yaml | 2 +- zsw-farm/zsw-farm-api/pom.xml | 10 ++++++ .../yudao/module/farm/enums/TaskStatus.java | 31 +++++++++++++++++++ .../admin/discuss/dto/DiscussDto.java | 4 +++ .../admin/discuss/vo/DiscussBaseVO.java | 5 ++- .../admin/discuss/vo/DiscussExcelVO.java | 8 ++++- .../admin/project/ProjectController.java | 2 +- .../controller/admin/task/TaskController.java | 2 +- .../controller/admin/task/vo/TaskBaseVO.java | 3 ++ .../admin/workHour/vo/WorkHourBaseVO.java | 6 ++-- .../dal/dataobject/discuss/DiscussDO.java | 12 +++++-- .../farm/dal/dataobject/task/TaskDO.java | 3 ++ .../dal/dataobject/workHour/WorkHourDO.java | 6 ++-- .../service/task/TaskServiceImplTest.java | 30 +++++++++--------- 16 files changed, 100 insertions(+), 29 deletions(-) create mode 100644 zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/TaskStatus.java create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/dto/DiscussDto.java diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java index 145a3299..6c962d53 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java @@ -60,6 +60,7 @@ public class YudaoMybatisAutoConfiguration { public SqlSessionFactory sqlSessionFactoryMaster(DynamicDataSourceProvider dynamicDataSourceProvider) throws Exception { //手动处理下原来的sqlsessionfactory MybatisSqlSessionFactoryBean factory = new MybatisSqlSessionFactoryBean(); + factory.setTypeEnumsPackage("cn.iocoder.yudao.module.farm.enums"); Map map = dynamicDataSourceProvider.loadDataSources(); factory.setDataSource(map.get("master")); return getSqlSessionFactory(factory); diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java index 4668b184..dbd7c6dc 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.jackson.core.databind.LocalDateTimeDeserialize import cn.iocoder.yudao.framework.jackson.core.databind.LocalDateTimeSerializer; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.module.SimpleModule; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeansException; @@ -38,7 +39,8 @@ public class YudaoJacksonAutoConfiguration { .addDeserializer(LocalDateTime.class, LocalDateTimeDeserializer.INSTANCE); objectMapper.registerModules(simpleModule); - + // 序列化枚举 + objectMapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING,true); JsonUtils.init(objectMapper); log.info("初始化 jackson 自动配置"); return bean; diff --git a/yudao-server/src/main/resources/application-dev.yaml b/yudao-server/src/main/resources/application-dev.yaml index a2f191b7..38c8214a 100644 --- a/yudao-server/src/main/resources/application-dev.yaml +++ b/yudao-server/src/main/resources/application-dev.yaml @@ -66,7 +66,7 @@ spring: # Quartz 配置项,对应 QuartzProperties 配置类 spring: quartz: - auto-startup: true # 测试环境,需要开启 Job + auto-startup: false # 测试环境,需要开启 Job scheduler-name: schedulerName # Scheduler 名字。默认为 schedulerName job-store-type: jdbc # Job 存储器类型。默认为 memory 表示内存,可选 jdbc 使用数据库。 wait-for-jobs-to-complete-on-shutdown: true # 应用关闭时,是否等待定时任务执行完成。默认为 false ,建议设置为 true diff --git a/zsw-farm/zsw-farm-api/pom.xml b/zsw-farm/zsw-farm-api/pom.xml index d37f1e6c..036729aa 100644 --- a/zsw-farm/zsw-farm-api/pom.xml +++ b/zsw-farm/zsw-farm-api/pom.xml @@ -17,6 +17,16 @@ cn.iocoder.boot yudao-common + + + com.fasterxml.jackson.core + jackson-databind + + + + cn.iocoder.boot + yudao-spring-boot-starter-mybatis + diff --git a/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/TaskStatus.java b/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/TaskStatus.java new file mode 100644 index 00000000..9aca1686 --- /dev/null +++ b/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/TaskStatus.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.farm.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.baomidou.mybatisplus.annotation.IEnum; +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.Getter; + +@Getter +public enum TaskStatus { + + PLAN(0,"计划中"), + READY(1,"准备中"), + STARTED(2,"开始"), + EXCEPTION(3,"异常状态"), + COMPLETE(4,"任务完成"), + RETRY(5,"返工"), + END(6,"任务关闭"); + + @JsonValue + @EnumValue + private final Integer code; + + private final String desc; + + TaskStatus(Integer code, String desc) { + this.code = code; + this.desc = desc; + } + + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/dto/DiscussDto.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/dto/DiscussDto.java new file mode 100644 index 00000000..95e17951 --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/dto/DiscussDto.java @@ -0,0 +1,4 @@ +package cn.iocoder.yudao.module.farm.controller.admin.discuss.dto; + +public class DiscussDto { +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussBaseVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussBaseVO.java index 0859b48e..79276022 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussBaseVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussBaseVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.farm.controller.admin.discuss.vo; +import cn.iocoder.yudao.module.farm.controller.admin.workHour.vo.WorkHourBaseVO; import lombok.*; import java.util.*; import io.swagger.annotations.*; @@ -24,6 +25,8 @@ public class DiscussBaseVO { private String content; @ApiModelProperty(value = "") - private String images; + private List images; + + private List workHourList; } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExcelVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExcelVO.java index ba512260..14f1b3ec 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExcelVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExcelVO.java @@ -1,5 +1,8 @@ package cn.iocoder.yudao.module.farm.controller.admin.discuss.vo; +import cn.iocoder.yudao.module.farm.controller.admin.workHour.vo.WorkHourBaseVO; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.*; import java.util.*; import io.swagger.annotations.*; @@ -27,9 +30,12 @@ public class DiscussExcelVO { private String content; @ExcelProperty("") - private String images; + private List images; @ExcelProperty("") private Date createTime; + @ExcelProperty("") + private List workHourList; + } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java index 8cb1ac33..005b45a9 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java @@ -26,7 +26,7 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO; import cn.iocoder.yudao.module.farm.convert.project.ProjectConvert; import cn.iocoder.yudao.module.farm.service.project.ProjectService; -@Api(tags = "管理后台 - 农场项目") +@Api(tags = "管理后台 - 项目管理") @RestController @RequestMapping("/farm/project") @Validated diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java index b74d3dcb..ec87d888 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java @@ -26,7 +26,7 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO; import cn.iocoder.yudao.module.farm.convert.task.TaskConvert; import cn.iocoder.yudao.module.farm.service.task.TaskService; -@Api(tags = "管理后台 - 农场项目") +@Api(tags = "管理后台 - 任务管理") @RestController @RequestMapping("/farm/task") @Validated diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskBaseVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskBaseVO.java index ecaa98f2..3019b2db 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskBaseVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskBaseVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.farm.controller.admin.task.vo; +import cn.iocoder.yudao.module.farm.enums.TaskStatus; import lombok.*; import java.util.*; import io.swagger.annotations.*; @@ -44,4 +45,6 @@ public class TaskBaseVO { @ApiModelProperty(value = "优先级") private Integer weight; + @ApiModelProperty("任务状态") + private TaskStatus status; } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourBaseVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourBaseVO.java index 91fead14..625d5789 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourBaseVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/workHour/vo/WorkHourBaseVO.java @@ -13,13 +13,13 @@ import javax.validation.constraints.*; public class WorkHourBaseVO { @ApiModelProperty(value = "") - private Integer userId; + private Long userId; @ApiModelProperty(value = "") - private Integer projectId; + private Long projectId; @ApiModelProperty(value = "") - private Integer taskId; + private Long taskId; @ApiModelProperty(value = "", required = true) @NotNull(message = "不能为空") diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/discuss/DiscussDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/discuss/DiscussDO.java index c2b782cf..3e935066 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/discuss/DiscussDO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/discuss/DiscussDO.java @@ -1,5 +1,8 @@ package cn.iocoder.yudao.module.farm.dal.dataobject.discuss; +import cn.iocoder.yudao.module.farm.controller.admin.workHour.vo.WorkHourBaseVO; +import cn.iocoder.yudao.module.farm.dal.dataobject.workHour.WorkHourDO; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.*; import java.util.*; import com.baomidou.mybatisplus.annotation.*; @@ -10,7 +13,7 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; * * @author 系统管理员 */ -@TableName("farm_discuss") +@TableName(value = "farm_discuss",autoResultMap = true) @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) @@ -32,13 +35,18 @@ public class DiscussDO extends BaseDO { * */ private Long taskId; + + @TableField(typeHandler = JacksonTypeHandler.class) + private List workHourList; /** * */ private String content; + /** * */ - private String images; + @TableField(typeHandler = JacksonTypeHandler.class) + private List images; } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java index 6564d9dd..9842a4c7 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.farm.dal.dataobject.task; +import cn.iocoder.yudao.module.farm.enums.TaskStatus; import lombok.*; import java.util.*; import com.baomidou.mybatisplus.annotation.*; @@ -57,4 +58,6 @@ public class TaskDO extends BaseDO { */ private Integer weight; + private TaskStatus status; + } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/workHour/WorkHourDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/workHour/WorkHourDO.java index d455340c..a4430f1e 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/workHour/WorkHourDO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/workHour/WorkHourDO.java @@ -27,15 +27,15 @@ public class WorkHourDO extends BaseDO { /** * */ - private Integer userId; + private Long userId; /** * */ - private Integer projectId; + private Long projectId; /** * */ - private Integer taskId; + private Long taskId; /** * */ diff --git a/zsw-farm/zsw-farm-impl/src/test/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImplTest.java b/zsw-farm/zsw-farm-impl/src/test/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImplTest.java index 605505c7..0ce7c97d 100644 --- a/zsw-farm/zsw-farm-impl/src/test/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImplTest.java +++ b/zsw-farm/zsw-farm-impl/src/test/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImplTest.java @@ -108,8 +108,8 @@ public class TaskServiceImplTest extends BaseDbUnitTest { public void testGetTaskPage() { // mock 数据 TaskDO dbTask = randomPojo(TaskDO.class, o -> { // 等会查询到 - o.setName(null); - o.setContent(null); +// o.setName(null); +// o.setContent(null); o.setResources(null); o.setImages(null); o.setPlanStartTime(null); @@ -118,10 +118,10 @@ public class TaskServiceImplTest extends BaseDbUnitTest { o.setCreateTime(null); }); taskMapper.insert(dbTask); - // 测试 name 不匹配 - taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setName(null))); - // 测试 content 不匹配 - taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setContent(null))); +// // 测试 name 不匹配 +// taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setName(null))); +// // 测试 content 不匹配 +// taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setContent(null))); // 测试 resources 不匹配 taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setResources(null))); // 测试 images 不匹配 @@ -136,8 +136,8 @@ public class TaskServiceImplTest extends BaseDbUnitTest { taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setCreateTime(null))); // 准备参数 TaskPageReqVO reqVO = new TaskPageReqVO(); - reqVO.setName(null); - reqVO.setContent(null); +// reqVO.setName(null); +// reqVO.setContent(null); reqVO.setResources(null); reqVO.setImages(null); reqVO.setBeginPlanStartTime(null); @@ -161,8 +161,8 @@ public class TaskServiceImplTest extends BaseDbUnitTest { public void testGetTaskList() { // mock 数据 TaskDO dbTask = randomPojo(TaskDO.class, o -> { // 等会查询到 - o.setName(null); - o.setContent(null); +// o.setName(null); +// o.setContent(null); o.setResources(null); o.setImages(null); o.setPlanStartTime(null); @@ -172,9 +172,9 @@ public class TaskServiceImplTest extends BaseDbUnitTest { }); taskMapper.insert(dbTask); // 测试 name 不匹配 - taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setName(null))); - // 测试 content 不匹配 - taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setContent(null))); +// taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setName(null))); +// // 测试 content 不匹配 +// taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setContent(null))); // 测试 resources 不匹配 taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setResources(null))); // 测试 images 不匹配 @@ -189,8 +189,8 @@ public class TaskServiceImplTest extends BaseDbUnitTest { taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setCreateTime(null))); // 准备参数 TaskExportReqVO reqVO = new TaskExportReqVO(); - reqVO.setName(null); - reqVO.setContent(null); +// reqVO.setName(null); +// reqVO.setContent(null); reqVO.setResources(null); reqVO.setImages(null); reqVO.setBeginPlanStartTime(null);