Browse Source

后台项目搜索

zyh
小久哥 3 years ago
parent
commit
6063523f30
  1. 8
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java
  2. 6
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/vo/ProjectPageReqVO.java
  3. 69
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskSearchVO.java
  4. 19
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/project/ProjectMapper.java
  5. 5
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectService.java
  6. 10
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java
  7. 34
      zsw-farm/zsw-farm-impl/src/main/resources/mapper/project/ProjectMapper.xml

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

@ -94,14 +94,6 @@ public class ProjectController {
return success(ProjectConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/pageSearch")
@ApiOperation("获得农场项目搜索分页")
public CommonResult<PageResult<ProjectRespVO>> getProjectSearchPage(@Valid ProjectSearchPageReqVO pageVO) {
System.out.println("进入搜索分页");
PageResult<ProjectDO> resultPage = projectService.getProjectSearchPage(pageVO);
return success(ProjectConvert.INSTANCE.convertPage(resultPage));
}
@GetMapping("/export-excel")
@ApiOperation("导出农场项目 Excel")
@PreAuthorize("@ss.hasPermission('farm:project:export')")

6
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/vo/ProjectPageReqVO.java

@ -65,4 +65,10 @@ public class ProjectPageReqVO extends PageParam {
private Boolean pretendDelete = false;
@ApiModelProperty("后台搜索区域id")
private Long areaId;
@ApiModelProperty("后台区域搜索成员")
private Long executorName;
}

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

@ -1,69 +0,0 @@
package cn.iocoder.yudao.module.farm.controller.admin.task.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import com.alibaba.fastjson.JSONArray;
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.List;
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 TaskSearchVO extends PageParam {
@ApiModelProperty("草稿")
private Boolean draft = false;
@ApiModelProperty("项目名")
private String projectId;
@ApiModelProperty("区域名")
private String areaId;
@ApiModelProperty("任务父级名")
private Long taskCateId;
@ApiModelProperty("任务子级名")
private Long taskCateName;
@ApiModelProperty("资源名")
private Long resourceId;
@ApiModelProperty(value = "优先级")
private Integer weight;
@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;
@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;
}

19
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/project/ProjectMapper.java

@ -2,11 +2,13 @@ package cn.iocoder.yudao.module.farm.dal.mysql.project;
import java.util.*;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO;
import cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.farm.controller.admin.project.vo.*;
@ -19,8 +21,16 @@ import cn.iocoder.yudao.module.farm.controller.admin.project.vo.*;
public interface ProjectMapper extends BaseMapperX<ProjectDO> {
default PageResult<ProjectDO> selectPage(ProjectPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ProjectDO>()
.likeIfPresent(ProjectDO::getName, reqVO.getName())
LambdaQueryWrapperX<ProjectDO> lambdaQueryWrapperX = new LambdaQueryWrapperX<ProjectDO>();
//搜索执行人
if (ObjectUtil.isNotEmpty(reqVO.getExecutorName())){
lambdaQueryWrapperX.apply("JSON_CONTAINS(members, '"+ reqVO.getExecutorName()+"')");
}
//区域
if (ObjectUtil.isNotEmpty(reqVO.getAreaId())){
lambdaQueryWrapperX.apply("JSON_CONTAINS(areas, '"+ reqVO.getAreaId()+"')");
}
lambdaQueryWrapperX.likeIfPresent(ProjectDO::getName, reqVO.getName())
.eqIfPresent(ProjectDO::getContent, reqVO.getContent())
.eqIfPresent(ProjectDO::getAreas, reqVO.getAreas())
.eqIfPresent(ProjectDO::getCropId, reqVO.getCropId())
@ -32,7 +42,9 @@ public interface ProjectMapper extends BaseMapperX<ProjectDO> {
.betweenIfPresent(ProjectDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.eqIfPresent(ProjectDO::getPretendDelete, reqVO.getPretendDelete())
.eqIfPresent(ProjectDO::getDraft, reqVO.getDraft())
.orderByDesc(ProjectDO::getId));
.orderByDesc(ProjectDO::getId);
return selectPage(reqVO,lambdaQueryWrapperX);
}
default List<ProjectDO> selectList(ProjectExportReqVO reqVO) {
@ -52,6 +64,5 @@ public interface ProjectMapper extends BaseMapperX<ProjectDO> {
.orderByDesc(ProjectDO::getId));
}
List<ProjectDO> getProjectSearchPage(ProjectSearchPageReqVO reqVO);
}

5
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectService.java

@ -64,11 +64,6 @@ public interface ProjectService {
*/
PageResult<ProjectDO> getProjectPage(ProjectPageReqVO pageReqVO);
/**
* 搜索条件农场项目分页
**/
PageResult<ProjectDO> getProjectSearchPage(ProjectSearchPageReqVO pageReqVO);
/**
* 获得农场项目列表, 用于 Excel 导出
*

10
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java

@ -127,16 +127,6 @@ public class ProjectServiceImpl implements ProjectService {
return projectMapper.selectPage(pageReqVO);
}
@Override
public PageResult<ProjectDO> getProjectSearchPage(ProjectSearchPageReqVO pageReqVO){
pageReqVO.setPageNo(pageReqVO.getPageNo() - 1);
List<ProjectDO> list = projectMapper.getProjectSearchPage(pageReqVO);
PageResult<ProjectDO> result = new PageResult<>();
result.setList(list);
result.setTotal(Long.valueOf(list.size()));
return result;
}
@Override
public List<ProjectDO> getProjectList(ProjectExportReqVO exportReqVO) {
return projectMapper.selectList(exportReqVO);

34
zsw-farm/zsw-farm-impl/src/main/resources/mapper/project/ProjectMapper.xml

@ -9,38 +9,4 @@
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="getProjectSearchPage" resultType="cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO">
SELECT p.* FROM farm_project p
-- INNER JOIN farm_resource r
-- ON JSON_CONTAINS(p.resources, CONVERT(r.id, CHAR))
INNER JOIN farm_area a
ON JSON_CONTAINS(p.areas, CONVERT(a.id, CHAR))
AND 1 = 1
<if test="name != null and name != '' ">
AND p.name like concat('%', #{name}, '%')
</if>
<!-- <if test="resources != null and resources != '' ">-->
<!-- AND r.name like concat('%', #{resources}, '%')-->
<!-- </if>-->
<if test="areas != null and areas != '' ">
AND a.name like concat('%', #{areas}, '%')
</if>
<if test="state != null and state != '' ">
AND r.state like concat('%', #{state}, '%')
</if>
<if test="weight != null">
AND p.weight = #{weight}
</if>
<if test="beginPlanStartTime != null and endPlanStartTime != null">
AND p.plan_start_time <![CDATA[ >= ]]> #{beginPlanStartTime} AND p.plan_start_time <![CDATA[ <= ]]> #{endPlanStartTime}
</if>
<if test="beginPlanEndTime != null and endPlanEndTime != null">
AND p.plan_end_time <![CDATA[ >= ]]> #{beginPlanEndTime} AND p.plan_end_time <![CDATA[ <= ]]> #{endPlanEndTime}
</if>
<if test="beginCreateTime != null and endCreateTime != null">
AND p.create_time <![CDATA[ >= ]]> #{beginCreateTime} AND p.create_time <![CDATA[ <= ]]> #{endCreateTime}
</if>
GROUP BY p.id
LIMIT #{pageNo},#{pageSize}
</select>
</mapper>

Loading…
Cancel
Save