| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.utils.NodeTreeUtil; |
| | | 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.excel.HouseAndHoldExcel; |
| | | import org.springblade.modules.house.service.IHouseholdService; |
| | | import org.springblade.modules.house.vo.HouseParam; |
| | | import org.springblade.modules.house.vo.HouseTree; |
| | | import org.springblade.modules.house.vo.HouseVO; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private IGridService gridService; |
| | | |
| | | @Autowired |
| | | private IHouseholdService householdService; |
| | | |
| | | @Override |
| | | public IPage<HouseVO> selectHousePage(IPage<HouseVO> page, HouseVO house) { |
| | |
| | | } |
| | | return stringList; |
| | | } |
| | | |
| | | /** |
| | | * 人房数据导入 |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importHouseAndHold(List<HouseAndHoldExcel> data, Boolean isCovered) { |
| | | for (HouseAndHoldExcel houseAndHoldExcel : data) { |
| | | // System.out.println("houseAndHoldExcel = " + houseAndHoldExcel); |
| | | // 保存房屋数据--一个一个插入,防止一个表格中存在多个地址编号相同的数据 |
| | | saveHouseData(houseAndHoldExcel); |
| | | // 保存住户数据(包含标签)--一个一个插入,防止一个表格中存在多个地址编号相同的数据 |
| | | saveHouseholdData(houseAndHoldExcel); |
| | | // 保存租户数据 |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存房屋数据 |
| | | * @param houseAndHoldExcel |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveHouseholdData(HouseAndHoldExcel houseAndHoldExcel) { |
| | | // 查询库中是否已存在 |
| | | QueryWrapper<HouseEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("house_code",houseAndHoldExcel.getHouseCode()) |
| | | .eq("is_deleted",0); |
| | | HouseEntity one = getOne(wrapper); |
| | | // 不存在则插入,存在则不操作 |
| | | if (null == one){ |
| | | HouseEntity houseEntity = new HouseEntity(); |
| | | houseEntity.setHouseCode(houseAndHoldExcel.getHouseCode()); |
| | | houseEntity.setHouseName(houseAndHoldExcel.getHouseName()); |
| | | houseEntity.setDistrictName(houseAndHoldExcel.getDistrictName()); |
| | | houseEntity.setUnit(houseAndHoldExcel.getUnit()); |
| | | if (!Strings.isBlank(houseAndHoldExcel.getFloor())){ |
| | | houseEntity.setFloor(houseAndHoldExcel.getFloor()); |
| | | } |
| | | houseEntity.setRoom(houseAndHoldExcel.getRoom()); |
| | | houseEntity.setBuilding(houseAndHoldExcel.getBuilding()); |
| | | houseEntity.setArea(houseAndHoldExcel.getArea()); |
| | | houseEntity.setPropertyPrice(houseAndHoldExcel.getPropertyPrice()); |
| | | houseEntity.setServiceDue(houseAndHoldExcel.getServiceDue()); |
| | | houseEntity.setRemark(houseAndHoldExcel.getRemark()); |
| | | houseEntity.setCreateTime(new Date()); |
| | | houseEntity.setCreateUser(AuthUtil.getUserId().toString()); |
| | | houseEntity.setUpdateTime(new Date()); |
| | | houseEntity.setUpdateUser(AuthUtil.getUserId().toString()); |
| | | // 新增 |
| | | save(houseEntity); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存住户数据 |
| | | * @param houseAndHoldExcel |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveHouseData(HouseAndHoldExcel houseAndHoldExcel) { |
| | | // 查询库中是否已存在 |
| | | QueryWrapper<HouseholdEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("house_code",houseAndHoldExcel.getHouseCode()) |
| | | .eq("is_deleted",0) |
| | | .eq("phone_number",houseAndHoldExcel.getPhoneNumber()); |
| | | HouseholdEntity one = householdService.getOne(wrapper); |
| | | // 不存在则插入,存在则不操作 |
| | | if (null == one){ |
| | | HouseholdEntity householdEntity = new HouseholdEntity(); |
| | | householdEntity.setHouseCode(houseAndHoldExcel.getHouseCode()); |
| | | householdEntity.setName(houseAndHoldExcel.getName()); |
| | | householdEntity.setPhoneNumber(houseAndHoldExcel.getPhoneNumber()); |
| | | if (!Strings.isBlank(houseAndHoldExcel.getRoleType())){ |
| | | householdEntity.setRoleType(Integer.parseInt(houseAndHoldExcel.getRoleType())); |
| | | } |
| | | if (!Strings.isBlank(houseAndHoldExcel.getRelationship())){ |
| | | householdEntity.setRelationship(Integer.parseInt(houseAndHoldExcel.getRelationship())); |
| | | } |
| | | if (!Strings.isBlank(houseAndHoldExcel.getIsPrimaryContact())){ |
| | | householdEntity.setIsPrimaryContact(Integer.parseInt(houseAndHoldExcel.getIsPrimaryContact())); |
| | | } |
| | | // 居住状态 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getResidentialStatus())){ |
| | | householdEntity.setResidentialStatus(Integer.parseInt(houseAndHoldExcel.getResidentialStatus())); |
| | | } |
| | | // 性别 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getGender())){ |
| | | householdEntity.setGender(Short.parseShort(houseAndHoldExcel.getGender())); |
| | | } |
| | | householdEntity.setIdCard(houseAndHoldExcel.getIdCard()); |
| | | // 党员 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getPartyEmber())){ |
| | | householdEntity.setPartyEmber(Integer.parseInt(houseAndHoldExcel.getPartyEmber())); |
| | | } |
| | | householdEntity.setHkmtPass(houseAndHoldExcel.getHkmtPass()); |
| | | householdEntity.setPassport(houseAndHoldExcel.getPassport()); |
| | | if (!Strings.isBlank(houseAndHoldExcel.getEthnicity())){ |
| | | householdEntity.setEthnicity(Integer.parseInt(houseAndHoldExcel.getEthnicity())); |
| | | } |
| | | if (!Strings.isBlank(houseAndHoldExcel.getEducation())){ |
| | | householdEntity.setEducation(Integer.parseInt(houseAndHoldExcel.getEducation())); |
| | | } |
| | | householdEntity.setHukouRegistration(houseAndHoldExcel.getHukouRegistration()); |
| | | if (!Strings.isBlank(houseAndHoldExcel.getWorkStatus())){ |
| | | householdEntity.setWorkStatus(Integer.parseInt(houseAndHoldExcel.getWorkStatus())); |
| | | } |
| | | householdEntity.setEmployer(houseAndHoldExcel.getEmployer()); |
| | | if (!Strings.isBlank(houseAndHoldExcel.getMaritalStatus())){ |
| | | householdEntity.setMaritalStatus(Integer.parseInt(houseAndHoldExcel.getMaritalStatus())); |
| | | } |
| | | householdEntity.setCardNumber(houseAndHoldExcel.getCardNumber()); |
| | | householdEntity.setOtherContact(houseAndHoldExcel.getOtherContact()); |
| | | householdEntity.setDisabilityCert(houseAndHoldExcel.getDisabilityCert()); |
| | | householdEntity.setRemark(houseAndHoldExcel.getRemarks()); |
| | | householdEntity.setCreateTime(new Date()); |
| | | householdEntity.setCreateUser(AuthUtil.getUserId()); |
| | | householdEntity.setUpdateTime(new Date()); |
| | | householdEntity.setUpdateUser(AuthUtil.getUserId()); |
| | | // 新增 |
| | | householdService.save(householdEntity); |
| | | } |
| | | } |
| | | } |