Commit 98b0b20c authored by 田涛's avatar 田涛

数字预案分页查询接口返回绑定对象信息

parent 80c254e6
......@@ -18,5 +18,7 @@ public interface IPlanDocDao extends BaseDao<PlanDoc, Long> {
List<PlanDoc> getPlanDocsByPlanId(Long planId);
List<PlanDoc> findAllByPlanIdIn(List<Long> planId);
List<PlanDoc> findAllByIsDelete(Boolean isDelete);
}
package com.yeejoin.amos.fas.business.dao.repository;
import com.yeejoin.amos.fas.dao.entity.PlanDoc;
import com.yeejoin.amos.fas.dao.entity.PlanEquipment;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
......@@ -22,4 +23,6 @@ public interface IPlanEquipmentDao extends BaseDao<PlanEquipment, Long> {
List<PlanEquipment> getPlanDocsByPlanId(Long planId);
List<PlanEquipment> findAllByIsDelete(Boolean isDelete);
List<PlanEquipment> findAllByPlanIdIn(List<Long> planId);
}
package com.yeejoin.amos.fas.business.dao.repository;
import com.yeejoin.amos.fas.dao.entity.PlanDoc;
import com.yeejoin.amos.fas.dao.entity.PlanRule;
import org.springframework.stereotype.Repository;
......@@ -20,4 +21,6 @@ public interface IPlanRuleDao extends BaseDao<PlanRule, Long>{
List<PlanRule> getPlanDocsByPlanId(Long planId);
List<PlanRule> findAllByIsDelete(Boolean isDelete);
List<PlanRule> findAllByPlanIdIn(List<Long> planIds);
}
......@@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.*;
......@@ -344,11 +345,50 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
start = 0;
}
List<PlanDetailVo> planList = planDetailMapper.filterList(planName, classifyIdList, planRange, editOrgName, implementationTimeLeft, implementationTimeRight, (int) start, (int) page.getSize());
// 查询并插入绑定数据的信息
fillBindingInfo(planList);
page.setRecords(planList);
}
return page;
}
private void fillBindingInfo(List<PlanDetailVo> planList) {
if (ValidationUtil.isEmpty(planList)) {
return;
}
List<Long> idList = new ArrayList<>();
planList.forEach(e -> idList.add(e.getId()));
Map<Object, List<PlanDoc>> docMapList = null;
Map<Object, List<PlanRule>> ruleMapList = null;
Map<Object, List<PlanEquipment>> equipMapList = null;
List<PlanDoc> docs = planDocDao.findAllByPlanIdIn(idList);
if (!docs.isEmpty()) {
docMapList = Bean.list2MapList(docs, "planId");
}
List<PlanRule> rules = planRuleDao.findAllByPlanIdIn(idList);
if (!rules.isEmpty()) {
ruleMapList = Bean.list2MapList(rules, "planId");
}
List<PlanEquipment> equips = planEquipmentDao.findAllByPlanIdIn(idList);
if (!equips.isEmpty()) {
equipMapList = Bean.list2MapList(equips, "planId");
}
Map<Object, List<PlanDoc>> finalDocMapList = docMapList;
Map<Object, List<PlanRule>> finalRuleMapList = ruleMapList;
Map<Object, List<PlanEquipment>> finalEquipMapList = equipMapList;
planList.forEach(plan -> {
if (finalDocMapList != null && finalDocMapList.get(plan.getId()) != null) {
plan.setPlanDoc(finalDocMapList.get(plan.getId()).get(0));
}
if (finalRuleMapList != null && finalRuleMapList.get(plan.getId()) != null) {
plan.setPlanRule(finalRuleMapList.get(plan.getId()).get(0));
}
if (finalEquipMapList != null && finalEquipMapList.get(plan.getId()) != null) {
plan.setPlanEquipment(finalEquipMapList.get(plan.getId()));
}
});
}
@Override
public Map<Long, Long> getPlanUsedDocs() {
Map<Long, Long> resMap = new HashMap<>(64);
......
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