package com.newfiber.api.pc.service.impl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.newfiber.api.pc.dao.SitePropertyConfigMapper; import com.newfiber.api.pc.model.meet.MeetPlanType; import com.newfiber.api.pc.model.zhz.SitePropertyConfig; import com.newfiber.api.pc.service.MeetPlanTypeService; import com.newfiber.api.pc.service.SitePropertyConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.HashSet; import java.util.List; import java.util.Set; /** * @description: 因子配置业务层实现类 * @author: 张鸿志 * @date: 2020/12/15 16:15 * @version: v1.0 */ @Service @Transactional(rollbackFor = Exception.class) public class SitePropertyConfigServiceImpl extends ServiceImpl<SitePropertyConfigMapper,SitePropertyConfig> implements SitePropertyConfigService { @Autowired private MeetPlanTypeService meetPlanTypeService; @Override public List<SitePropertyConfig> queryAllocatedSiteProperty() { //查询出所有的预案类别数据 List<MeetPlanType> meetPlanTypes = meetPlanTypeService.selectList(null); Set<String> factor = new HashSet<>(); //取出所有的因子数据,并利用Set集合去重 meetPlanTypes.stream().map(MeetPlanType::getFactors).forEach(s ->{ List<String> list = JSONObject.parseArray(s, String.class); factor.addAll(list); }); //利用集合中的数据去查询因子对象 EntityWrapper<SitePropertyConfig> wrapper = new EntityWrapper<>(); wrapper.in("code_ascii",factor); return this.selectList(wrapper); } }