| | |
| | | |
| | | 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.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.utils.IdUtils; |
| | | import org.springblade.common.utils.NodeTreeUtil; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.house.entity.HouseEntity; |
| | | import org.springblade.modules.house.entity.HouseholdEntity; |
| | | import org.springblade.modules.house.entity.UserHouseLabelEntity; |
| | | import org.springblade.modules.house.excel.HouseAndHoldExcel; |
| | | import org.springblade.modules.house.excel.HouseExcel; |
| | | import org.springblade.modules.house.mapper.HouseMapper; |
| | | import org.springblade.modules.house.service.IHouseService; |
| | | import org.springblade.modules.house.service.IHouseholdService; |
| | | import org.springblade.modules.house.service.IUserHouseLabelService; |
| | | import org.springblade.modules.house.vo.HouseParam; |
| | | import org.springblade.modules.house.vo.HouseTree; |
| | | import org.springblade.modules.house.vo.HouseVO; |
| | | import org.springblade.modules.label.entity.LabelEntity; |
| | | import org.springblade.modules.label.service.ILabelService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importHouseAndHold(List<HouseAndHoldExcel> data, Boolean isCovered) { |
| | | for (HouseAndHoldExcel houseAndHoldExcel : data) { |
| | | // System.out.println("houseAndHoldExcel = " + houseAndHoldExcel); |
| | | // System.out.println(houseAndHoldExcel); |
| | | System.out.println("houseAndHoldExcel = " + houseAndHoldExcel); |
| | | // 保存房屋数据--一个一个插入,防止一个表格中存在多个地址编号相同的数据 |
| | | saveHouseData(houseAndHoldExcel); |
| | | // 保存住户数据(包含标签)--一个一个插入,防止一个表格中存在多个地址编号相同的数据 |
| | |
| | | QueryWrapper<HouseholdEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("house_code",houseAndHoldExcel.getHouseCode()) |
| | | .eq("is_deleted",0) |
| | | .eq("phone_number",houseAndHoldExcel.getPhoneNumber()); |
| | | .eq("name",houseAndHoldExcel.getName()); |
| | | HouseholdEntity one = householdService.getOne(wrapper); |
| | | // 不存在则插入,存在则不操作 |
| | | if (null == one){ |
| | |
| | | householdEntity.setUpdateTime(new Date()); |
| | | householdEntity.setUpdateUser(AuthUtil.getUserId()); |
| | | // 新增 |
| | | householdService.save(householdEntity); |
| | | boolean save = householdService.save(householdEntity); |
| | | if (save) { |
| | | String labelId = houseAndHoldExcel.getLabelId(); |
| | | if (StringUtils.isBlank(labelId)) { |
| | | return; |
| | | } |
| | | String[] split = labelId.split(","); |
| | | IUserHouseLabelService bean = SpringUtils.getBean(IUserHouseLabelService.class); |
| | | ILabelService bean1 = SpringUtils.getBean(ILabelService.class); |
| | | for (String s : split) { |
| | | LabelEntity one1 = bean1.getOne(Wrappers.<LabelEntity>lambdaQuery().eq(LabelEntity::getLabelName, s)); |
| | | if (one1 != null) { |
| | | UserHouseLabelEntity userHouseLabelEntity = new UserHouseLabelEntity(); |
| | | userHouseLabelEntity.setLabelId(BigDecimal.valueOf(one1.getId()).longValue()); |
| | | userHouseLabelEntity.setHouseholdId(householdEntity.getId()); |
| | | userHouseLabelEntity.setLableType(1); |
| | | userHouseLabelEntity.setLabelName(s); |
| | | userHouseLabelEntity.setHouseCode(houseAndHoldExcel.getHouseCode()); |
| | | bean.save(userHouseLabelEntity); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |