diff --git a/yudao-framework/yudao-common/pom.xml b/yudao-framework/yudao-common/pom.xml
index 3794bc50..9326bcfc 100644
--- a/yudao-framework/yudao-common/pom.xml
+++ b/yudao-framework/yudao-common/pom.xml
@@ -127,6 +127,12 @@
com.alibaba
transmittable-thread-local
+
+ com.github.pagehelper
+ pagehelper
+ 5.3.0
+ compile
+
diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/page/PageUtil.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/page/PageUtil.java
new file mode 100644
index 00000000..3e162d0f
--- /dev/null
+++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/page/PageUtil.java
@@ -0,0 +1,98 @@
+package cn.iocoder.yudao.framework.common.page;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.experimental.UtilityClass;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 分页工具类
+ *
+ * @author xggz
+ * @since 2021/6/4 11:50
+ */
+@UtilityClass
+public class PageUtil {
+
+ /**
+ * 转换PageHelper插件的分页数据
+ *
+ * @param pageInfo
+ * @param
+ * @return
+ */
+ public PageVO convertPageInfo(PageInfo pageInfo) {
+ return BeanUtil.copyProperties(pageInfo, PageVO.class);
+ }
+
+ /**
+ * 转换PageHelper插件的分页数据
+ *
+ * @param list
+ * @param
+ * @return
+ */
+ public PageVO convertPageInfo(List list) {
+ return BeanUtil.copyProperties(new PageInfo(list), PageVO.class);
+ }
+
+ /**
+ * 复制分页数据
+ *
+ * @param sourcePage
+ * @param results
+ * @param
+ * @return
+ */
+ public PageVO copyPage(Object sourcePage, List results) {
+ PageVO targetPage = BeanUtil.copyProperties(sourcePage, PageVO.class);
+ targetPage.setList(results);
+ return targetPage;
+ }
+
+ /**
+ * 返回空白的分页对象
+ *
+ * @param pageNum
+ * @param pageSize
+ * @param dataClass
+ * @param
+ * @return
+ */
+ public PageVO emptyPage(Integer pageNum, Integer pageSize, Class dataClass) {
+ PageVO page = new PageVO<>();
+ page.setPageNum(pageNum);
+ page.setPageSize(pageSize);
+ page.setSize(0);
+ page.setPages(0);
+ page.setTotal(0);
+ page.setHasNextPage(false);
+ page.setHasPreviousPage(false);
+ page.setList(new ArrayList());
+ return page;
+ }
+
+ /**
+ * 返回空白的分页对象
+ *
+ * @param pageDTO
+ * @param dataClass
+ * @param
+ * @return
+ */
+ public PageVO emptyPage(PageDTO pageDTO, Class dataClass) {
+ return emptyPage(pageDTO.getPageNum(), pageDTO.getPageSize(), dataClass);
+ }
+
+ /**
+ * 使用PageHelper设置分页参数
+ *
+ * @param pageDTO
+ */
+ public void startPage(PageDTO pageDTO) {
+ PageHelper.startPage(pageDTO.getPageNum(), pageDTO.getPageSize());
+ }
+}
\ No newline at end of file
diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/page/PageVO.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/page/PageVO.java
new file mode 100644
index 00000000..2e205fab
--- /dev/null
+++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/page/PageVO.java
@@ -0,0 +1,45 @@
+package cn.iocoder.yudao.framework.common.page;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 分页结果
+ *
+ * @author xggz
+ * @since 2021/6/4 10:53
+ */
+@Data
+@ApiModel(value = "PageVO", description = "分页结果")
+public class PageVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("当前页")
+ private int pageNum;
+
+ @ApiModelProperty("每页的数量")
+ private int pageSize;
+
+ @ApiModelProperty("当前页的数量")
+ private int size;
+
+ @ApiModelProperty("总页数")
+ private int pages;
+
+ @ApiModelProperty("是否有前一页")
+ private boolean hasPreviousPage = false;
+
+ @ApiModelProperty("是否有后一页")
+ private boolean hasNextPage = false;
+
+ @ApiModelProperty("总记录数")
+ private long total;
+
+ @ApiModelProperty("结果集")
+ private List list;
+}
\ No newline at end of file
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserBaseVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserBaseVO.java
index f0aec405..cebffbfb 100644
--- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserBaseVO.java
+++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserBaseVO.java
@@ -43,4 +43,7 @@ public class CpUserBaseVO {
@ApiModelProperty(value = "企业邮件")
private String bizMail;
+ @ApiModelProperty(value = "工时")
+ private Integer workHour;
+
}
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserExcelVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserExcelVO.java
index 46a9c71d..62d92d24 100644
--- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserExcelVO.java
+++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserExcelVO.java
@@ -47,4 +47,7 @@ public class CpUserExcelVO {
@ExcelProperty("企业邮件")
private String bizMail;
+ @ApiModelProperty(value = "工时")
+ private Integer workHour;
+
}
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserExportReqVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserExportReqVO.java
index 6b4a0678..1fbc8f3d 100644
--- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserExportReqVO.java
+++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserExportReqVO.java
@@ -47,4 +47,6 @@ public class CpUserExportReqVO {
@ApiModelProperty(value = "企业邮件")
private String bizMail;
+ @ApiModelProperty(value = "工时")
+ private Integer workHour;
}
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserPageReqVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserPageReqVO.java
index 8169c6ff..b82c5da0 100644
--- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserPageReqVO.java
+++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/CpUser/vo/CpUserPageReqVO.java
@@ -49,4 +49,6 @@ public class CpUserPageReqVO extends PageParam {
@ApiModelProperty(value = "企业邮件")
private String bizMail;
+ @ApiModelProperty(value = "工时")
+ private Integer workHour;
}
diff --git a/zsw-farm/zsw-farm-impl/pom.xml b/zsw-farm/zsw-farm-impl/pom.xml
index 2c816d72..86dddb78 100644
--- a/zsw-farm/zsw-farm-impl/pom.xml
+++ b/zsw-farm/zsw-farm-impl/pom.xml
@@ -59,6 +59,12 @@
1.6.2-snapshot
compile
+
+ cn.iocoder.boot
+ zsw-spi
+ 1.6.2-snapshot
+ compile
+
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 a289b7cf..5fc973bb 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
@@ -1,7 +1,9 @@
package cn.iocoder.yudao.module.farm.controller.admin.project;
+import cn.iocoder.yudao.framework.common.page.PageVO;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO;
+import com.zsw.base.R;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@@ -108,7 +110,7 @@ public class ProjectController {
@ApiOperation("小程序项目列表")
@PostMapping("/findProjectList")
- public List findProjectList(ProjectPageDTO pageDTO){
+ public R> findProjectList(@RequestBody ProjectPageDTO pageDTO){
return projectService.findProjectList(pageDTO);
}
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectListDTO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectListDTO.java
index 6d155f61..fc05b45e 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectListDTO.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectListDTO.java
@@ -4,6 +4,8 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO;
import lombok.*;
+import java.time.LocalDateTime;
+import java.util.Date;
import java.util.List;
@Data
@@ -18,5 +20,7 @@ public class ProjectListDTO extends ProjectDO {
String taskName;
+ Date finishTime;
+
}
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/dto/TaskMsgDTO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/dto/TaskMsgDTO.java
new file mode 100644
index 00000000..86d22fb4
--- /dev/null
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/dto/TaskMsgDTO.java
@@ -0,0 +1,26 @@
+package cn.iocoder.yudao.module.farm.controller.admin.task.dto;
+
+import cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO;
+import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class TaskMsgDTO extends TaskDO {
+
+ List areaName;
+
+ List executorName;
+
+ String taskName;
+
+ Date finishTime;
+
+
+}
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 48bd54d7..1f1f5eb8 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
@@ -16,8 +16,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
public class TaskBaseVO {
- private Integer projectId;
- private Integer cropId;
+ private Long projectId;
+ private Long cropId;
private Integer cropNum;
private Long taskCateId;
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExcelVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExcelVO.java
index c55bbcee..bfd3d3f4 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExcelVO.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExcelVO.java
@@ -19,9 +19,9 @@ public class TaskExcelVO {
private Long id;
@ExcelProperty("")
- private Integer projectId;
+ private Long projectId;
@ExcelProperty("")
- private Integer cropId;
+ private Long cropId;
@ExcelProperty("")
private Integer cropNum;
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExportReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExportReqVO.java
index e727f563..bde3ac21 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExportReqVO.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExportReqVO.java
@@ -13,8 +13,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
public class TaskExportReqVO {
- private Integer projectId;
- private Integer cropId;
+ private Long projectId;
+ private Long cropId;
private Integer cropNum;
private Long taskCateId;
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageReqVO.java
index 676dd11d..90acbe95 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageReqVO.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageReqVO.java
@@ -15,8 +15,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true)
public class TaskPageReqVO extends PageParam {
- private Integer projectId;
- private Integer cropId;
+ private Long projectId;
+ private Long cropId;
private Integer cropNum;
private Long taskCateId;
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageSearchReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageSearchReqVO.java
index 5a039337..d8c0df4c 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageSearchReqVO.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageSearchReqVO.java
@@ -20,8 +20,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true)
public class TaskPageSearchReqVO extends PageParam {
- private Integer projectId;
- private Integer cropId;
+ private Long projectId;
+ private Long cropId;
private Integer cropNum;
private Long taskCateId;
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 7c002ba8..5117460f 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
@@ -27,9 +27,9 @@ public class TaskDO extends BaseDO {
private Long id;
@ApiModelProperty("项目id")
- private Integer projectId;
+ private Long projectId;
@ApiModelProperty("作物id")
- private Integer cropId;
+ private Long cropId;
@ApiModelProperty("作物数量")
private Integer cropNum;
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/project/ProjectMapper.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/project/ProjectMapper.java
index 0bdeb9cf..3dbfbffa 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/project/ProjectMapper.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/project/ProjectMapper.java
@@ -50,10 +50,4 @@ public interface ProjectMapper extends BaseMapperX {
List getProjectSearchPage(ProjectSearchPageReqVO reqVO);
- default List findProjectList(ProjectPageDTO pageDTO){
- return selectList(new LambdaQueryWrapperX()
- .eqIfPresent(ProjectDO::getState, pageDTO.getState())
- .orderByDesc(ProjectDO::getId));
- }
-
}
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectService.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectService.java
index 6d33f941..b2e4911a 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectService.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectService.java
@@ -3,11 +3,13 @@ package cn.iocoder.yudao.module.farm.service.project;
import java.util.*;
import javax.validation.*;
+import cn.iocoder.yudao.framework.common.page.PageVO;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO;
import cn.iocoder.yudao.module.farm.controller.admin.project.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import com.zsw.base.R;
/**
* 农场项目 Service 接口
@@ -79,6 +81,6 @@ public interface ProjectService {
/**
* @Description 小程序项目列表
**/
- List findProjectList(ProjectPageDTO pageDTO);
+ R> findProjectList(ProjectPageDTO pageDTO);
}
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java
index 317f8a38..88a81cc6 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java
@@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.farm.service.project;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
+import cn.iocoder.yudao.framework.common.page.PageUtil;
+import cn.iocoder.yudao.framework.common.page.PageVO;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO;
+import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskMsgDTO;
import cn.iocoder.yudao.module.farm.dal.dataobject.area.AreaDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.taskCate.TaskCateDO;
@@ -17,8 +20,12 @@ import cn.iocoder.yudao.module.system.dal.mysql.CpUser.CpUserMapper;
import cn.iocoder.yudao.module.system.service.CpUser.CpUserService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.PageInfo;
+import com.zsw.base.R;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@@ -55,6 +62,8 @@ public class ProjectServiceImpl implements ProjectService {
private AreaMapper areaMapper;
@Resource
private TaskCateMapper taskCateMapper;
+ @Resource
+ private TaskService taskService;
@Override
public Long createProject(ProjectCreateReqVO createReqVO) {
@@ -119,93 +128,123 @@ public class ProjectServiceImpl implements ProjectService {
}
@Override
- public List findProjectList(ProjectPageDTO pageDTO){
- List list = projectMapper.findProjectList(pageDTO);
+ public R> findProjectList(ProjectPageDTO pageDTO){
+ PageUtil.startPage(pageDTO);
+ LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery();
+ queryWrapper.eq(ProjectDO::getState, pageDTO.getState());
+ List list = projectMapper.selectList(queryWrapper);
+ if (ObjectUtil.isEmpty(list)){
+ return R.success(PageUtil.emptyPage(pageDTO, ProjectListDTO.class));
+ }
+// List list = projectMapper.selectList(Wrappers.lambdaQuery()
+// .eq(ProjectDO::getState, pageDTO.getState())
+// .last("limit " + (pageDTO.getPageNum() -1) * pageDTO.getPageSize() +"," + pageDTO.getPageSize()));
+
List idList = list.stream().map(ProjectDO::getId).collect(Collectors.toList());
+ List ProjectListDTOList = BeanUtil.copyToList(list, ProjectListDTO.class);
+
//任务完成的
List taskList = taskMapper.selectList(Wrappers.lambdaQuery().in(TaskDO::getProjectId, idList)
.eq(TaskDO::getStatus, TaskStatus.COMPLETE.getCode()));
+ /* //项目没有任务 跳过
+ if (ObjectUtil.isNotEmpty(taskList)){
+
+ List taskMsgDTOList = taskService.getTaskMsg(taskList);
- Set personSet = new HashSet<>();
- Set areaSet = new HashSet<>();
- Set taskCateSet = new HashSet<>();
+ Set personSet = new HashSet<>();
+ Set areaSet = new HashSet<>();
+ Set taskCateSet = new HashSet<>();
- taskList.stream().forEach(item ->{
- //项目参与人
- item.getExecutorPerson().forEach(p ->{
- if (p != null) {
- personSet.add(Long.valueOf( p.toString()));
+ taskList.stream().forEach(item ->{
+ //项目参与人
+ item.getExecutorPerson().forEach(p ->{
+ if (p != null) {
+ personSet.add(Long.valueOf( p.toString()));
+ }
+ });
+ //项目区域
+ if (item.getAreas() != null){
+ item.getAreas().forEach(area ->{
+ JSONArray array = JSONArray.parseArray(area.toString());
+ areaSet.add(Long.valueOf(array.get(0).toString()));
+ areaSet.add(Long.valueOf(array.get(1).toString()));
+ });
}
+ //任务分类名
+ taskCateSet.add(item.getTaskCateId());
});
- //项目区域
- if (item.getAreas() != null){
- item.getAreas().forEach(area ->{
- JSONArray array = JSONArray.parseArray(area.toString());
- areaSet.add(Long.valueOf(array.get(0).toString()));
- areaSet.add(Long.valueOf(array.get(1).toString()));
- });
- }
- //任务分类名
- taskCateSet.add(item.getTaskCateId());
- });
-
- List joinPerson = new ArrayList(personSet);
- List cpUserList = cpUserMapper.selectList(Wrappers.lambdaQuery().in(CpUserDO::getId, joinPerson));
- List joinArea = new ArrayList(areaSet);
- List areaDOList = areaMapper.selectList(Wrappers.lambdaQuery().in(AreaDO::getId, joinArea));
- List joinTaskCate = new ArrayList<>(taskCateSet);
- List taskCateDOList = taskCateMapper.selectList(Wrappers.lambdaQuery().in(TaskCateDO::getId, joinTaskCate));
-
- //拼接 姓名/区域/任务名
- List dto = BeanUtil.copyToList(list, ProjectListDTO.class);
- for (ProjectListDTO projectListDTO : dto) {
- for (TaskDO taskDO : taskList) {
-
- if (Long.valueOf(taskDO.getProjectId()).equals(projectListDTO.getId())){
- //任务名
- for (TaskCateDO taskCateDO : taskCateDOList) {
- if (taskCateDO.getId().equals(taskDO.getTaskCateId())){
- projectListDTO.setTaskName(taskCateDO.getName());
- }
- }
- //执行人
- List personNameList = new ArrayList<>();
- for (Long executorPerson : taskDO.getExecutorPerson().toJavaList(Long.class)) {
- for (CpUserDO cpUserDO : cpUserList) {
- if (cpUserDO.getId().equals(executorPerson)){
- personNameList.add(cpUserDO.getName());
+ List joinPerson = new ArrayList(personSet);
+ List cpUserList = cpUserMapper.selectList(Wrappers.lambdaQuery().in(CpUserDO::getId, joinPerson));
+ List joinArea = new ArrayList(areaSet);
+ List areaDOList = areaMapper.selectList(Wrappers.lambdaQuery().in(AreaDO::getId, joinArea));
+ List joinTaskCate = new ArrayList<>(taskCateSet);
+ List taskCateDOList = taskCateMapper.selectList(Wrappers.lambdaQuery().in(TaskCateDO::getId, joinTaskCate));
+
+ //拼接 姓名/区域/任务名
+ for (ProjectListDTO projectListDTO : ProjectListDTOList) {
+ for (TaskDO taskDO : taskList) {
+ if (Long.valueOf(taskDO.getProjectId()).equals(projectListDTO.getId())){
+ //完成时间
+ projectListDTO.setFinishTime(taskDO.getUpdateTime());
+ //任务名
+ for (TaskCateDO taskCateDO : taskCateDOList) {
+ if (taskCateDO.getId().equals(taskDO.getTaskCateId())){
+ projectListDTO.setTaskName(taskCateDO.getName());
}
}
- projectListDTO.setExecutorName(personNameList);
- }
- //任务区域
- List areaNameList = new ArrayList<>();
- for (Object area : taskDO.getAreas()) {
- JSONArray array = JSONArray.parseArray(area.toString());
- Long areaParent = Long.valueOf(String.valueOf(array.get(0)));
- Long areaSon = Long.valueOf(String.valueOf(array.get(1)));
- StringBuilder areaName = new StringBuilder();
- for (AreaDO areaDO : areaDOList) {
- if (areaDO.getId().equals(areaParent)){
- areaName.append(areaDO.getName());
- }
- if (areaDO.getId().equals(areaSon)){
- areaName.append(areaDO.getName());
+ //执行人
+ List personNameList = new ArrayList<>();
+ for (Long executorPerson : taskDO.getExecutorPerson().toJavaList(Long.class)) {
+ for (CpUserDO cpUserDO : cpUserList) {
+ if (cpUserDO.getId().equals(executorPerson)){
+ personNameList.add(cpUserDO.getName());
+ }
}
+ projectListDTO.setExecutorName(personNameList);
}
- if (ObjectUtil.isNotEmpty(areaName)){
- areaNameList.add(areaName.toString());
+ //任务区域
+ List areaNameList = new ArrayList<>();
+ for (Object area : taskDO.getAreas()) {
+ JSONArray array = JSONArray.parseArray(area.toString());
+ Long areaParent = Long.valueOf(String.valueOf(array.get(0)));
+ Long areaSon = Long.valueOf(String.valueOf(array.get(1)));
+ StringBuilder areaName = new StringBuilder();
+ for (AreaDO areaDO : areaDOList) {
+ if (areaDO.getId().equals(areaParent)){
+ areaName.append(areaDO.getName());
+ }
+ if (areaDO.getId().equals(areaSon)){
+ areaName.append(areaDO.getName());
+ }
+ }
+ if (ObjectUtil.isNotEmpty(areaName)){
+ areaNameList.add(areaName.toString());
+ }
+ projectListDTO.setAreaName(areaNameList);
}
- projectListDTO.setAreaName(areaNameList);
}
}
}
+ }*/
+
+
+ if (ObjectUtil.isNotEmpty(taskList)) {
+ List taskMsgDTOList = taskService.getTaskMsg(taskList);
+ Map> taskMsgMap = taskMsgDTOList.stream().collect(Collectors.groupingBy(TaskMsgDTO::getProjectId));
+ for (ProjectListDTO projectListDTO : ProjectListDTOList) {
+ if (taskMsgMap.containsKey(projectListDTO.getId())){
+ TaskMsgDTO msgDTO = taskMsgMap.get(projectListDTO.getId()).get(0);
+ projectListDTO.setAreaName(msgDTO.getAreaName());
+ projectListDTO.setExecutorName(msgDTO.getExecutorName());
+ projectListDTO.setTaskName(msgDTO.getTaskName());
+ projectListDTO.setFinishTime(msgDTO.getUpdateTime());
+ }
+ }
}
-
- return dto;
-
+ PageVO returnList = PageUtil.convertPageInfo(ProjectListDTOList);
+ return R.success(returnList);
}
}
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java
index 64b326da..3cb040cf 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java
@@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.farm.service.task;
import java.util.*;
import javax.validation.*;
+
+import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskMsgDTO;
import cn.iocoder.yudao.module.farm.controller.admin.task.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@@ -75,4 +77,12 @@ public interface TaskService {
*/
List getTaskList(TaskExportReqVO exportReqVO);
+
+ /**
+ * @Description 根据taskDOList 获取每个taskDO的 执行人、区域、任务名
+ * @param taskDOList 任务List
+ * @return 返回每个任务的执行人、区域、任务名
+ **/
+ public List getTaskMsg(List taskDOList);
+
}
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java
index 7483d200..1e283dd6 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java
@@ -1,5 +1,18 @@
package cn.iocoder.yudao.module.farm.service.task;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO;
+import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskMsgDTO;
+import cn.iocoder.yudao.module.farm.dal.dataobject.area.AreaDO;
+import cn.iocoder.yudao.module.farm.dal.dataobject.taskCate.TaskCateDO;
+import cn.iocoder.yudao.module.farm.dal.mysql.area.AreaMapper;
+import cn.iocoder.yudao.module.farm.dal.mysql.taskCate.TaskCateMapper;
+import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO;
+import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
+import cn.iocoder.yudao.module.system.dal.mysql.CpUser.CpUserMapper;
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@@ -26,6 +39,12 @@ public class TaskServiceImpl implements TaskService {
@Resource
private TaskMapper taskMapper;
+ @Resource
+ private CpUserMapper cpUserMapper;
+ @Resource
+ private AreaMapper areaMapper;
+ @Resource
+ private TaskCateMapper taskCateMapper;
@Override
public Long createTask(TaskCreateReqVO createReqVO) {
@@ -90,4 +109,86 @@ public class TaskServiceImpl implements TaskService {
return taskMapper.selectList(exportReqVO);
}
+
+ public List getTaskMsg(List taskList){
+ Set personSet = new HashSet<>();
+ Set areaSet = new HashSet<>();
+ Set taskCateSet = new HashSet<>();
+ List taskMsgList = new ArrayList<>();
+
+ //先获取所有任务得到 去重后的 参与人、区域、任务分类名
+ for (TaskDO taskDO : taskList) {
+ //项目参与人
+ taskDO.getExecutorPerson().forEach(p ->{
+ if (p != null) {
+ personSet.add(Long.valueOf( p.toString()));
+ }
+ });
+ //项目区域
+ if (taskDO.getAreas() != null){
+ taskDO.getAreas().forEach(area ->{
+ JSONArray array = JSONArray.parseArray(area.toString());
+ areaSet.add(Long.valueOf(array.get(0).toString()));
+ areaSet.add(Long.valueOf(array.get(1).toString()));
+ });
+ }
+ //任务分类名
+ taskCateSet.add(taskDO.getTaskCateId());
+ }
+
+ //一次查出所需信息
+ List joinPerson = new ArrayList(personSet);
+ List cpUserList = cpUserMapper.selectList(Wrappers.lambdaQuery().in(CpUserDO::getId, joinPerson));
+ List joinArea = new ArrayList(areaSet);
+ List areaDOList = areaMapper.selectList(Wrappers.lambdaQuery().in(AreaDO::getId, joinArea));
+ List joinTaskCate = new ArrayList<>(taskCateSet);
+ List taskCateDOList = taskCateMapper.selectList(Wrappers.lambdaQuery().in(TaskCateDO::getId, joinTaskCate));
+
+ //查询任务的 姓名/区域/任务名
+ for (TaskDO taskDO : taskList) {
+ TaskMsgDTO msgDTO = BeanUtil.copyProperties(taskDO, TaskMsgDTO.class);
+ //完成时间
+ msgDTO.setFinishTime(taskDO.getUpdateTime());
+ //任务名
+ for (TaskCateDO taskCateDO : taskCateDOList) {
+ if (taskCateDO.getId().equals(taskDO.getTaskCateId())){
+ msgDTO.setTaskName(taskCateDO.getName());
+ }
+ }
+
+ //执行人
+ List personNameList = new ArrayList<>();
+ for (Long executorPerson : taskDO.getExecutorPerson().toJavaList(Long.class)) {
+ for (CpUserDO cpUserDO : cpUserList) {
+ if (cpUserDO.getId().equals(executorPerson)){
+ personNameList.add(cpUserDO.getName());
+ }
+ }
+ msgDTO.setExecutorName(personNameList);
+ }
+ //任务区域
+ List areaNameList = new ArrayList<>();
+ for (Object area : taskDO.getAreas()) {
+ JSONArray array = JSONArray.parseArray(area.toString());
+ Long areaParent = Long.valueOf(String.valueOf(array.get(0)));
+ Long areaSon = Long.valueOf(String.valueOf(array.get(1)));
+ StringBuilder areaName = new StringBuilder();
+ for (AreaDO areaDO : areaDOList) {
+ if (areaDO.getId().equals(areaParent)){
+ areaName.append(areaDO.getName());
+ }
+ if (areaDO.getId().equals(areaSon)){
+ areaName.append(areaDO.getName());
+ }
+ }
+ if (ObjectUtil.isNotEmpty(areaName)){
+ areaNameList.add(areaName.toString());
+ }
+ msgDTO.setAreaName(areaNameList);
+ }
+ taskMsgList.add(msgDTO);
+ }
+ return taskMsgList;
+ }
+
}