Browse Source

农场任务搜索实现

zyh
小久哥 3 years ago
parent
commit
1971f3031c
  1. 8
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java
  2. 61
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageSearchReqVO.java
  3. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/task/TaskMapper.java
  4. 8
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java
  5. 11
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java
  6. 39
      zsw-farm/zsw-farm-impl/src/main/resources/mapper/task/TaskMapper.xml

8
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java

@ -85,6 +85,14 @@ public class TaskController {
return success(TaskConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/pageSearch")
@ApiOperation("搜索条件获得农场项目分页")
public CommonResult<PageResult<TaskRespVO>> getTaskSearchPage(@Valid TaskPageSearchReqVO pageVO) {
PageResult<TaskDO> pageResult = taskService.getTaskSearchPage(pageVO);
return success(TaskConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@ApiOperation("导出农场项目 Excel")
@PreAuthorize("@ss.hasPermission('farm:task:export')")

61
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageSearchReqVO.java

@ -0,0 +1,61 @@
package cn.iocoder.yudao.module.farm.controller.admin.task.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 农场项目分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class TaskPageSearchReqVO extends PageParam {
@ApiModelProperty(value = "")
private String name;
@ApiModelProperty(value = "")
private String content;
@ApiModelProperty(value = "")
private String resources;
@ApiModelProperty(value = "")
private Object images;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始")
private LocalDateTime beginPlanStartTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束")
private LocalDateTime endPlanStartTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始")
private LocalDateTime beginPlanEndTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束")
private LocalDateTime endPlanEndTime;
@ApiModelProperty(value = "优先级")
private Integer weight;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始")
private LocalDateTime beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束")
private LocalDateTime endCreateTime;
}

2
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/task/TaskMapper.java

@ -43,4 +43,6 @@ public interface TaskMapper extends BaseMapperX<TaskDO> {
.orderByDesc(TaskDO::getId));
}
List<TaskDO> getTaskSearchPage(TaskPageSearchReqVO reqVO);
}

8
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java

@ -59,6 +59,14 @@ public interface TaskService {
*/
PageResult<TaskDO> getTaskPage(TaskPageReqVO pageReqVO);
/**
* 搜索条件获得农场项目分页
*
* @param pageReqVO 分页查询
* @return 农场项目分页
*/
PageResult<TaskDO> getTaskSearchPage(TaskPageSearchReqVO pageReqVO);
/**
* 获得农场项目列表, 用于 Excel 导出
*

11
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java

@ -74,6 +74,17 @@ public class TaskServiceImpl implements TaskService {
return taskMapper.selectPage(pageReqVO);
}
@Override
public PageResult<TaskDO> getTaskSearchPage(TaskPageSearchReqVO pageVO){
pageVO.setPageNo(pageVO.getPageNo() - 1);
List<TaskDO> list = taskMapper.getTaskSearchPage(pageVO);
PageResult<TaskDO> result = new PageResult<>();
result.setList(list);
result.setTotal(Long.valueOf(list.size()));
return result;
}
@Override
public List<TaskDO> getTaskList(TaskExportReqVO exportReqVO) {
return taskMapper.selectList(exportReqVO);

39
zsw-farm/zsw-farm-impl/src/main/resources/mapper/task/TaskMapper.xml

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.farm.dal.mysql.task.TaskMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="getTaskSearchPage" resultType="cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO">
SELECT t.* FROM farm_task t
INNER JOIN farm_resource r
ON JSON_CONTAINS(t.resources, CONVERT(r.id, CHAR))
AND 1 = 1
<if test="name != null and name != '' ">
AND t.name like concat('%', #{name}, '%')
</if>
<if test="resources != null and resources != '' ">
AND r.name like concat('%', #{resources}, '%')
</if>
<if test="weight != null">
AND t.weight = #{weight}
</if>
<if test="beginPlanStartTime != null and endPlanStartTime != null">
AND t.plan_start_time <![CDATA[ >= ]]> #{beginPlanStartTime} AND t.plan_start_time <![CDATA[ <= ]]> #{endPlanStartTime}
</if>
<if test="beginPlanEndTime != null and endPlanEndTime != null">
AND t.plan_end_time <![CDATA[ >= ]]> #{beginPlanEndTime} AND t.plan_end_time <![CDATA[ <= ]]> #{endPlanEndTime}
</if>
<if test="beginCreateTime != null and endCreateTime != null">
AND t.create_time <![CDATA[ >= ]]> #{beginCreateTime} AND t.create_time <![CDATA[ <= ]]> #{endCreateTime}
</if>
GROUP BY t.id
LIMIT #{pageNo},#{pageSize}
</select>
</mapper>
Loading…
Cancel
Save