Commit e01ccc1b authored by 田涛's avatar 田涛

数字预案分页查询接口

parent b437c0ec
package com.yeejoin.amos.fas.business.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.fas.business.service.intfc.ContingencyPlanService;
import com.yeejoin.amos.fas.business.vo.PlanDetailVo;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.exception.YeeException;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -70,6 +72,27 @@ public class ContingencyPlanController extends BaseController {
}
/**
* 数字预案分页查询
*/
@Permission
@ApiOperation(value = "查看数字预案详情", notes = "查看数字预案详情")
@GetMapping(value = "/page", produces = "application/json;charset=UTF-8")
public CommonResponse pageFilter(@RequestParam(value = "current") int current,
@RequestParam(value = "planName", required = false) String planName,
@RequestParam(value = "classifyId", required = false) Long[] classifyId,
@RequestParam(value = "planRange", required = false) String[] planRange,
@RequestParam(value = "editOrgName", required = false) String editOrgName,
@RequestParam(value = "implementationTimeLeft", required = false) Date implementationTimeLeft,
@RequestParam(value = "implementationTimeRight", required = false) Date implementationTimeRight,
@RequestParam(value = "size") int size) {
if (current < 1 || size < 1) {
throw new YeeException("分页参数有误");
}
Page page = new Page(current, size);
return CommonResponseUtil.success(contingencyPlanService.pageFilter(page, planName, classifyId, planRange, editOrgName, implementationTimeLeft, implementationTimeRight));
}
/**
* 启用预案
*/
@Permission
......
package com.yeejoin.amos.fas.business.dao.mapper;
import com.yeejoin.amos.fas.business.vo.PlanDetailVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
......@@ -17,4 +19,10 @@ public interface PlanDetailMapper {
int updatePlanStatusByIdList(@Param("idList") List<Long> idList, @Param("status") Integer status);
int updateIsDeleteByIdList(@Param("idList") List<Long> idList, @Param("isDelete") Boolean isDelete);
Integer filterCount(@Param("planName") String planName, @Param("classifyId") Long[] classifyId, @Param("planRange") String[] planRange, @Param("editOrgName") String editOrgName, @Param("implementationTimeLeft") Date implementationTimeLeft, @Param("implementationTimeRight") Date implementationTimeRight);
List<PlanDetailVo> filterList(@Param("planName") String planName, @Param("classifyId") Long[] classifyId, @Param("planRange") String[] planRange, @Param("editOrgName") String editOrgName, @Param("implementationTimeLeft") Date implementationTimeLeft, @Param("implementationTimeRight") Date implementationTimeRight, @Param("start") long start, @Param("size") long size);
}
package com.yeejoin.amos.fas.business.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.fas.business.dao.mapper.PlanDetailMapper;
import com.yeejoin.amos.fas.business.dao.repository.*;
import com.yeejoin.amos.fas.business.service.intfc.ContingencyPlanService;
......@@ -15,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Optional;
......@@ -189,4 +191,22 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
planDetailMapper.updateIsDeleteByIdList(idList, true);
return true;
}
@Override
public Page<PlanDetailVo> pageFilter(Page page, String planName, Long[] classifyId, String[] planRange, String editOrgName, Date implementationTimeLeft, Date implementationTimeRight) {
int total = planDetailMapper.filterCount(planName, classifyId, planRange, editOrgName, implementationTimeLeft, implementationTimeRight);
page.setTotal(total);
long start = (page.getCurrent() - 1) * page.getSize();
if (total == 0) {
page.setCurrent(1);
} else {
if (total < start) {
page.setCurrent(1);
start = 0;
}
List<PlanDetailVo> planList = planDetailMapper.filterList(planName, classifyId, planRange, editOrgName, implementationTimeLeft, implementationTimeRight, start, page.getSize());
page.setRecords(planList);
}
return page;
}
}
\ No newline at end of file
package com.yeejoin.amos.fas.business.service.intfc;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.fas.business.vo.PlanDetailVo;
import com.yeejoin.amos.fas.dao.entity.PlanDetail;
import java.util.Date;
import java.util.List;
/**
......@@ -53,4 +55,18 @@ public interface ContingencyPlanService {
* @return
*/
Boolean delete(List<Long> idList);
/**
* 分页查询
* @param page 分页
* @param planName 预案名称
* @param classifyId 预案类型
* @param planRange 适用范围
* @param editOrgName 编写部门
* @param implementationTimeLeft 实施时间左界限
* @param implementationTimeRight 实施时间右界限
* @return Page
*/
Page<PlanDetailVo> pageFilter(Page page, String planName, Long[] classifyId, String[] planRange, String editOrgName, Date implementationTimeLeft, Date implementationTimeRight);
}
......@@ -16,4 +16,88 @@
</foreach>
</update>
<select id="filterCount" parameterType="string" resultType="int">
SELECT
count(1)
FROM
c_plan_detail cpd
<where>
<if test="planName != null and planName.length > 0">
AND plan_name LIKE concat('%', #{planName}, '%')
</if>
<if test="classifyId != null and classifyId.size > 0">
AND classify_id IN
<foreach collection="classifyId" separator="," item="cid" open="(" close=")">
#{cid}
</foreach>
</if>
<if test="planRange != null and planRange.size > 0">
AND plan_range IN
<foreach collection="planRange" separator="," item="pr" open="(" close=")">
#{pr}
</foreach>
</if>
<if test="editOrgName != null and editOrgName.length > 0">
AND edit_org_name LIKE concat('%', #{editOrgName}, '%')
</if>
<if test="implementationTimeLeft != null">
AND implementation_time <![CDATA[ >= ]]> #{implementationTimeLeft}
</if>
<if test="implementationTimeRight != null">
AND implementation_time <![CDATA[ < ]]> #{implementationTimeRight}
</if>
AND is_delete = 0
</where>
</select>
<select id="filterList" parameterType="string" resultType="com.yeejoin.amos.fas.business.vo.PlanDetailVo">
SELECT
id
, create_date createDate
, plan_name planName
, code
, classify_id classifyId
, plan_range planRange
, edit_org_name editOrgName
, edition
, implementation_time implementationTime
, remark
, status
, creator
, reviser
, update_time updateTime
, org_code orgCode
, is_delete isDelete
, (SELECT classify_name FROM c_plan_classify_tree cpct WHERE id = cpd.classify_id) classifyName
, (SELECT count(1) FROM c_plan_operation_record cpor WHERE plan_id = cpd.id) executionTimes
FROM
c_plan_detail cpd
<where>
<if test="planName != null and planName.length > 0">
AND plan_name LIKE concat('%', #{planName}, '%')
</if>
<if test="classifyId != null and classifyId.size > 0">
AND classify_id IN
<foreach collection="classifyId" separator="," item="cid" open="(" close=")">
#{cid}
</foreach>
</if>
<if test="planRange != null and planRange.size > 0">
AND plan_range IN
<foreach collection="planRange" separator="," item="pr" open="(" close=")">
#{pr}
</foreach>
</if>
<if test="editOrgName != null and editOrgName.length > 0">
AND edit_org_name LIKE concat('%', #{editOrgName}, '%')
</if>
<if test="implementationTimeLeft != null">
AND implementation_time <![CDATA[ >= ]]> #{implementationTimeLeft}
</if>
<if test="implementationTimeRight != null">
AND implementation_time <![CDATA[ < ]]> #{implementationTimeRight}
</if>
AND is_delete = 0
</where>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment