Commit aad8d98c authored by 田涛's avatar 田涛

执行记录分页列表

parent f0953cd0
......@@ -183,21 +183,23 @@ public class ContingencyPlanController extends BaseController {
}
@ApiOperation(value = "预案启动记录分页列表")
@RequestMapping(value = "/recordList", method = RequestMethod.GET)
@RequestMapping(value = "/record/page", method = RequestMethod.GET)
public ResponseModel recordList(
@RequestParam int current,
@RequestParam int pageSize,
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int pageSize,
@ApiParam(value = "预案类型") @RequestParam(value = "classifyId", required = false) List<Long> classifyId,
@ApiParam(value = "预案类型") @RequestParam(value = "startTimeLeft", required = false) Long startTimeLeftStamp,
@ApiParam(value = "预案类型") @RequestParam(value = "startTimeRight", required = false) Long startTimeRightStamp,
@ApiParam(value = "预案类型") @RequestParam(value = "executionType", required = false) Integer executionType,
@ApiParam(value = "预案类型") @RequestParam(value = "planPattern", required = false) Integer planPattern,
@ApiParam(value = "启动时间左边界") @RequestParam(value = "startTimeLeft", required = false) Long startTimeLeftStamp,
@ApiParam(value = "启动时间右边界") @RequestParam(value = "startTimeRight", required = false) Long startTimeRightStamp,
@ApiParam(value = "执行方式") @RequestParam(value = "executionType", required = false) Integer executionType,
@ApiParam(value = "运行模式") @RequestParam(value = "planPattern", required = false) Integer planPattern,
@ApiParam(value = "预案名称") @RequestParam(value = "planName", required = false) String planName) {
Date startTimeLeft = startTimeLeftStamp == null ? null : new Date(startTimeLeftStamp);
Date startTimeRight = startTimeRightStamp == null ? null : new Date(startTimeRightStamp);
Page page = contingencyPlanService.recordListByPage(current, pageSize, planName);
return CommonResponseUtil2.success(page);
if (current < 1 || pageSize < 1) {
throw new YeeException("分页参数有误");
}
Page page = new Page(current, pageSize);
return CommonResponseUtil2.success(contingencyPlanService.recordListByPage(page, planName, classifyId, startTimeLeft, startTimeRight, executionType, planPattern));
}
@ApiOperation(value = "第一次查看预案记录")
......
package com.yeejoin.amos.fas.business.dao.mapper;
import com.yeejoin.amos.fas.business.vo.PlanDetailVo;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
......@@ -14,6 +15,9 @@ import java.util.Map;
*/
@Repository
public interface PlanOperationRecordMapper {
Integer PlanOperationRecordListByCount(Map<String,Object> params);
List<HashMap<String,Object>> PlanOperationRecordListByPage(Map<String,Object> params);
int filterCount(Map<String, Object> params);
List<Map<String, Object>> filterList(Map<String, Object> params);
}
......@@ -271,18 +271,30 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
}
@Override
public Page recordListByPage(int current, int pageSize, String planName) {
public Page recordListByPage(Page page, String planName, List<Long> classifyId, Date startTimeLeft, Date startTimeRight, Integer executionType, Integer planPattern) {
Map<String, Object> params = new HashMap<>();
params.put("planName", planName);
params.put("offset", (current - 1) * pageSize);
params.put("pageSize", pageSize);
List<HashMap<String, Object>> result = planOperationRecordMapper.PlanOperationRecordListByPage(params);
Integer count = planOperationRecordMapper.PlanOperationRecordListByCount(params);
Page page = new Page();
page.setRecords(result);
page.setTotal(count);
page.setSize(pageSize);
page.setCurrent(current);
params.put("start", (int) ((page.getCurrent() - 1) * page.getSize()));
params.put("size", (int) page.getSize());
params.put("classifyId", classifyId);
params.put("startTimeLeft", startTimeLeft);
params.put("startTimeRight", startTimeRight);
params.put("executionType", executionType);
params.put("planPattern", planPattern);
int total = planOperationRecordMapper.filterCount(params);
page.setTotal(total);
long start = (page.getCurrent() - 1) * page.getSize();
if (total == 0) {
page.setCurrent(1);
} else {
if (total < start) {
page.setCurrent(1);
params.put("start", 0);
}
List<Map<String, Object>> planList = planOperationRecordMapper.filterList(params);
page.setRecords(planList);
}
return page;
}
......
......@@ -29,7 +29,6 @@ public interface IContingencyPlanService {
ContingencyPlanParamVo equipmentScene(Long equipmentId,String riskType );
Page recordListByPage ( int current, int pageSize,String planName);
/**
* 创建
* @param planDetail
......@@ -114,4 +113,7 @@ public interface IContingencyPlanService {
Map<String, Object> firstGetRecord(String batchNo);
List<HashMap<String,Object>> getRecordList(String batchNo);
Page recordListByPage(Page page, String planName, List<Long> classifyId, Date startTimeLeft, Date startTimeRight, Integer executionType, Integer planPattern);
}
<?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="com.yeejoin.amos.fas.business.dao.mapper.PlanOperationRecordMapper">
<select id="PlanOperationRecordListByPage" parameterType="hashmap" resultType="java.util.HashMap">
<select id="filterCount" parameterType="map" resultType="java.lang.Integer">
SELECT
record.batch_No AS batchNo,
detail.plan_name AS planName,
original.fire_Equipment_Name AS fireEquipmentName,
record.start_time AS startTime,
TIMESTAMPDIFF(second,record.start_time,record.end_time) as executionTime,
record.plan_pattern as planPattern,
'' AS executionType
count(1)
FROM
`c_plan_operation_record` record
LEFT JOIN c_plan_detail detail ON detail.id = record.plan_id
LEFT JOIN contingency_original_data original ON original.batch_no = record.batch_no
<where>
<if test="planName !=null and planName != ''"> ( detail.plan_name like concat(concat("%",#{planName}),"%"))</if>
</where>
limit #{offset},#{pageSize}
c_plan_operation_record cpor
LEFT JOIN c_plan_detail cpd ON
cpor.plan_id = cpd.id
<where>
<if test="planName != null and planName.length > 0">
AND cpd.plan_name LIKE CONCAT('%', #{planName},'%')
</if>
<if test="classifyId != null and classifyId.size > 0">
AND cpd.classify_id IN
<foreach collection="classifyId" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="planPattern != null">
AND cpd.plan_pattern = #{planPattern}
</if>
<if test="executionType != null">
AND cpd.execution_type LIKE #{executionType}
</if>
<if test="startTimeLeft != null">
AND cpd.start_time <![CDATA[ >= ]]> #{implementationTimeLeft}
</if>
<if test="startTimeRight != null">
AND cpd.start_time <![CDATA[ < ]]> #{implementationTimeRight}
</if>
</where>
</select>
<select id="filterList" parameterType="map" resultType="map">
SELECT
cpor.id
, cpor.batch_no batchNo
, cpor.plan_id planId
, cpor.start_time startTime
, cpor.end_time endTime
, cpor.status
, cpor.equipment_code equipmentCode
, cpor.equipment_name equipmentName
, cpor.execution_type executionType
, cpor.plan_pattern planPattern
, cpor.start_user_name startUserName
, cpd.plan_name planName
, (SELECT classify_name FROM c_plan_classify_tree cpct WHERE id = cpd.classify_id) classifyName
, cpd.plan_range planRange
, TIMESTAMPDIFF(SECOND, cpor.start_time, ifnull(cpor.end_time, now())) spendTime
FROM
c_plan_operation_record cpor
LEFT JOIN c_plan_detail cpd ON
cpor.plan_id = cpd.id
<where>
<if test="planName != null and planName.length > 0">
AND cpd.plan_name LIKE CONCAT('%', #{planName},'%')
</if>
<if test="classifyId != null and classifyId.size > 0">
AND cpd.classify_id IN
<foreach collection="classifyId" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="planPattern != null">
AND cpd.plan_pattern = #{planPattern}
</if>
<if test="executionType != null">
AND cpd.execution_type LIKE #{executionType}
</if>
<if test="startTimeLeft != null">
AND cpd.start_time <![CDATA[ >= ]]> #{implementationTimeLeft}
</if>
<if test="startTimeRight != null">
AND cpd.start_time <![CDATA[ < ]]> #{implementationTimeRight}
</if>
</where>
ORDER BY cpor.id ASC
LIMIT #{start}, #{size}
</select>
<select id="PlanOperationRecordListByCount" parameterType="hashmap" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
`c_plan_operation_record` record
LEFT JOIN c_plan_detail detail ON detail.id = record.plan_id
LEFT JOIN contingency_original_data original ON original.batch_no = record.batch_no
<where>
<if test="planName !=null and planName != ''"> ( detail.plan_name like concat(concat("%",#{planName}),"%"))</if>
</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