| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.house.dto.UserHouseLabelDTO; |
| | | import org.springblade.modules.house.entity.UserHouseLabelEntity; |
| | |
| | | import org.springblade.modules.house.mapper.UserHouseLabelMapper; |
| | | import org.springblade.modules.house.service.IUserHouseLabelService; |
| | | import org.springblade.modules.house.vo.HouseholdLabelVO; |
| | | import org.springblade.modules.house.vo.UserHouseLabelVO; |
| | | import org.springblade.modules.label.entity.LabelEntity; |
| | | import org.springblade.modules.label.service.ILabelService; |
| | | import org.springblade.modules.label.service.impl.LabelServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 住户-标签 服务实现类 |
| | |
| | | |
| | | /** |
| | | * 住户-标签 自定义新增或修改 |
| | | * |
| | | * @param householdLabel |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean saveOrUpdateHouseholdLabel(UserHouseLabelEntity householdLabel) { |
| | | // 查询标签名称 |
| | | LabelEntity labelEntity = labelService.getById(householdLabel.getLabelId()); |
| | | householdLabel.setLabelName(labelEntity.getLabelName()); |
| | | if (!Strings.isBlank(householdLabel.getLabelName())) { |
| | | LabelEntity labelEntity = labelService.getById(householdLabel.getLabelId()); |
| | | householdLabel.setLabelName(labelEntity.getLabelName()); |
| | | } |
| | | // 判断同一个住户同一个标签是否已存在,已存在则更新,不存在则新增 |
| | | QueryWrapper<UserHouseLabelEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("household_id",householdLabel.getHouseholdId()) |
| | | .eq("label_id",householdLabel.getLabelId()); |
| | | queryWrapper.eq("household_id", householdLabel.getHouseholdId()) |
| | | .eq("label_id", householdLabel.getLabelId()); |
| | | UserHouseLabelEntity one = getOne(queryWrapper); |
| | | if (null != one){ |
| | | if (null != one) { |
| | | householdLabel.setId(one.getId()); |
| | | // 更新 |
| | | return updateById(householdLabel); |
| | | } |
| | | // 插入 |
| | | return save(householdLabel); |
| | | return saveOrUpdate(householdLabel); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public IPage<HouseholdLabelVO> statisticalLabels(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel) { |
| | | return page.setRecords(baseMapper.statisticalLabels(page, householdLabel)); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<HouseholdLabelVO> orgStatisticalLabels(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel) { |
| | | return page.setRecords(baseMapper.orgStatisticalLabels(page, householdLabel)); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<HouseholdLabelVO> unitedFrontStatisticalLabels(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel) { |
| | | return page.setRecords(baseMapper.unitedFrontStatisticalLabels(page, householdLabel)); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<HouseholdLabelVO> followStatisticalLabels(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel) { |
| | | return page.setRecords(baseMapper.followStatisticalLabels(page, householdLabel)); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<HouseholdLabelVO> getCommunityStatisticalLabels(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel) { |
| | | return page.setRecords(baseMapper.getCommunityStatisticalLabels(page, householdLabel)); |
| | | } |
| | | |
| | | /** |
| | | * 房屋-标签 房屋自定义新增或修改 |
| | | * |
| | | * @param userHouseLabelEntity |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean saveOrUpdateHouseLabel(UserHouseLabelEntity userHouseLabelEntity) { |
| | | // 查询标签名称 |
| | | LabelEntity labelEntity = labelService.getById(userHouseLabelEntity.getLabelId()); |
| | | if (labelEntity != null) { |
| | | userHouseLabelEntity.setLabelName(labelEntity.getLabelName()); |
| | | } |
| | | // 先删除之前的房屋绑定的标签 |
| | | QueryWrapper<UserHouseLabelEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("house_code", userHouseLabelEntity.getHouseCode()) |
| | | .eq("lable_type", 2); |
| | | // 删除 |
| | | remove(queryWrapper); |
| | | // 插入 |
| | | return save(userHouseLabelEntity); |
| | | } |
| | | |
| | | /** |
| | | * 查询对应的label集合信息 |
| | | * @param labelName |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<UserHouseLabelEntity> getLabelList(String labelName) { |
| | | return baseMapper.getLabelList(labelName); |
| | | } |
| | | |
| | | @Override |
| | | public List<UserHouseLabelEntity> getUserHouseLabelList(UserHouseLabelVO userHouseLabelVO) { |
| | | return baseMapper.getUserHouseLabelList(userHouseLabelVO); |
| | | } |
| | | } |