| | |
| | | import org.springblade.modules.label.entity.LabelEntity; |
| | | import org.springblade.modules.label.service.ILabelService; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.entity.Region; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IRegionService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private IUserService userService; |
| | | |
| | | @Autowired |
| | | private IRegionService regionService; |
| | | |
| | | @Override |
| | | public IPage<HouseVO> selectHousePage(IPage<HouseVO> page, HouseVO house) { |
| | |
| | | houseEntity.setBuilding(houseAndHoldExcel.getBuilding()); |
| | | houseEntity.setArea(houseAndHoldExcel.getArea()); |
| | | houseEntity.setPropertyPrice(houseAndHoldExcel.getPropertyPrice()); |
| | | houseEntity.setServiceDue(houseAndHoldExcel.getServiceDue()); |
| | | if (!Strings.isBlank(houseAndHoldExcel.getServiceDue())) { |
| | | try { |
| | | Date date = new SimpleDateFormat("yyyy-MM-dd").parse(houseAndHoldExcel.getServiceDue()); |
| | | houseEntity.setServiceDue(date); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | houseEntity.setRemark(houseAndHoldExcel.getRemark()); |
| | | houseEntity.setCreateTime(new Date()); |
| | | houseEntity.setCreateUser(AuthUtil.getUserId().toString()); |
| | |
| | | saveOrUpdateUser(householdEntity); |
| | | } |
| | | } |
| | | /// 是否主要联系人 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getIsPrimaryContact())){ |
| | | householdEntity.setIsPrimaryContact(Integer.parseInt(houseAndHoldExcel.getIsPrimaryContact())); |
| | | } |
| | |
| | | } |
| | | 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())); |
| | | } |
| | | // 户籍类型 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getResidentType())){ |
| | | householdEntity.setResidentType(Integer.parseInt(houseAndHoldExcel.getResidentType())); |
| | | } |
| | | // 户籍地区县 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getResidentAdcode())){ |
| | | String adCode = shiftResidentResidentAdCode(houseAndHoldExcel.getResidentProvinceAdcode(), |
| | | houseAndHoldExcel.getResidentCityAdcode(), |
| | | houseAndHoldExcel.getResidentAdcode()); |
| | | // 转换行政区code |
| | | houseAndHoldExcel.setResidentAdcode(adCode); |
| | | } |
| | | householdEntity.setHukouRegistration(houseAndHoldExcel.getHukouRegistration()); |
| | | // 籍贯地区县 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getNativePlaceAdcode())){ |
| | | String adCode = shiftResidentResidentAdCode(null, |
| | | null, |
| | | houseAndHoldExcel.getNativePlaceAdcode()); |
| | | // 转换行政区code |
| | | houseAndHoldExcel.setNativePlaceAdcode(adCode); |
| | | } |
| | | // 健康状况 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getHealthStatus())){ |
| | | householdEntity.setHealthStatus(Integer.parseInt(houseAndHoldExcel.getHealthStatus())); |
| | | } |
| | | householdEntity.setDiseaseName(houseAndHoldExcel.getDiseaseName()); |
| | | householdEntity.setReligiousBelief(houseAndHoldExcel.getReligiousBelief()); |
| | | // 工作状态 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getWorkStatus())){ |
| | | householdEntity.setWorkStatus(Integer.parseInt(houseAndHoldExcel.getWorkStatus())); |
| | | } |
| | | householdEntity.setEmployer(houseAndHoldExcel.getEmployer()); |
| | | householdEntity.setOccupation(houseAndHoldExcel.getOccupation()); |
| | | householdEntity.setCmpyRegAddr(houseAndHoldExcel.getCmpyRegAddr()); |
| | | householdEntity.setGoOutReason(houseAndHoldExcel.getGoOutReason()); |
| | | if (!Strings.isBlank(houseAndHoldExcel.getGoOutTime())) { |
| | | try { |
| | | Date date = new SimpleDateFormat("yyyy-MM-dd").parse(houseAndHoldExcel.getGoOutTime()); |
| | | householdEntity.setGoOutTime(date); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | householdEntity.setGoOutWhere(houseAndHoldExcel.getGoOutWhere()); |
| | | householdEntity.setGoOutAddr(houseAndHoldExcel.getGoOutAddr()); |
| | | // 婚姻状态 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getMaritalStatus())){ |
| | | householdEntity.setMaritalStatus(Integer.parseInt(houseAndHoldExcel.getMaritalStatus())); |
| | | } |
| | | householdEntity.setCardNumber(houseAndHoldExcel.getCardNumber()); |
| | | householdEntity.setOtherContact(houseAndHoldExcel.getOtherContact()); |
| | | if (Strings.isBlank(householdEntity.getHouseCode())){ |
| | | // 暂时不处理,导入数据目前都有house_code |
| | | String adCode = shiftResidentHomeAdcode(houseAndHoldExcel.getHomeAdcode()); |
| | | // 转换行政区code |
| | | houseAndHoldExcel.setHomeAdcode(adCode); |
| | | } |
| | | householdEntity.setCurrentAddress(houseAndHoldExcel.getCurrentAddress()); |
| | | householdEntity.setDisabilityCert(houseAndHoldExcel.getDisabilityCert()); |
| | | householdEntity.setRemark(houseAndHoldExcel.getRemarks()); |
| | | householdEntity.setCreateTime(new Date()); |
| | |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | | // 更新 |
| | | one.setHouseCode(houseAndHoldExcel.getHouseCode()); |
| | | one.setName(houseAndHoldExcel.getName()); |
| | | one.setPhoneNumber(houseAndHoldExcel.getPhoneNumber()); |
| | | if (!Strings.isBlank(houseAndHoldExcel.getRoleType())){ |
| | | one.setRoleType(Integer.parseInt(houseAndHoldExcel.getRoleType())); |
| | | } |
| | | // 与角色关系 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getRelationship())){ |
| | | one.setRelationship(Integer.parseInt(houseAndHoldExcel.getRelationship())); |
| | | // 如果是业主,则需要往用户表插入用户 |
| | | if (one.getRelationship()==1){ |
| | | saveOrUpdateUser(one); |
| | | } |
| | | } |
| | | /// 是否主要联系人 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getIsPrimaryContact())){ |
| | | one.setIsPrimaryContact(Integer.parseInt(houseAndHoldExcel.getIsPrimaryContact())); |
| | | } |
| | | // 居住状态 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getResidentialStatus())){ |
| | | one.setResidentialStatus(Integer.parseInt(houseAndHoldExcel.getResidentialStatus())); |
| | | } |
| | | // 性别 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getGender())){ |
| | | one.setGender(Short.parseShort(houseAndHoldExcel.getGender())); |
| | | } |
| | | one.setIdCard(houseAndHoldExcel.getIdCard()); |
| | | // 党员 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getPartyEmber())){ |
| | | one.setPartyEmber(Integer.parseInt(houseAndHoldExcel.getPartyEmber())); |
| | | } |
| | | one.setHkmtPass(houseAndHoldExcel.getHkmtPass()); |
| | | one.setPassport(houseAndHoldExcel.getPassport()); |
| | | // 民族 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getEthnicity())){ |
| | | one.setEthnicity(Integer.parseInt(houseAndHoldExcel.getEthnicity())); |
| | | } |
| | | // 学历 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getEducation())){ |
| | | one.setEducation(Integer.parseInt(houseAndHoldExcel.getEducation())); |
| | | } |
| | | // 户籍类型 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getResidentType())){ |
| | | one.setResidentType(Integer.parseInt(houseAndHoldExcel.getResidentType())); |
| | | } |
| | | // 户籍地区县 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getResidentAdcode())){ |
| | | String adCode = shiftResidentResidentAdCode(houseAndHoldExcel.getResidentProvinceAdcode(), |
| | | houseAndHoldExcel.getResidentCityAdcode(), |
| | | houseAndHoldExcel.getResidentAdcode()); |
| | | // 转换行政区code |
| | | houseAndHoldExcel.setResidentAdcode(adCode); |
| | | } |
| | | one.setHukouRegistration(houseAndHoldExcel.getHukouRegistration()); |
| | | // 籍贯地区县 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getNativePlaceAdcode())){ |
| | | String adCode = shiftResidentResidentAdCode(null, |
| | | null, |
| | | houseAndHoldExcel.getNativePlaceAdcode()); |
| | | // 转换行政区code |
| | | houseAndHoldExcel.setNativePlaceAdcode(adCode); |
| | | } |
| | | // 健康状况 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getHealthStatus())){ |
| | | one.setHealthStatus(Integer.parseInt(houseAndHoldExcel.getHealthStatus())); |
| | | } |
| | | one.setDiseaseName(houseAndHoldExcel.getDiseaseName()); |
| | | one.setReligiousBelief(houseAndHoldExcel.getReligiousBelief()); |
| | | // 工作状态 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getWorkStatus())){ |
| | | one.setWorkStatus(Integer.parseInt(houseAndHoldExcel.getWorkStatus())); |
| | | } |
| | | one.setEmployer(houseAndHoldExcel.getEmployer()); |
| | | one.setOccupation(houseAndHoldExcel.getOccupation()); |
| | | one.setCmpyRegAddr(houseAndHoldExcel.getCmpyRegAddr()); |
| | | one.setGoOutReason(houseAndHoldExcel.getGoOutReason()); |
| | | if (!Strings.isBlank(houseAndHoldExcel.getGoOutTime())) { |
| | | try { |
| | | Date date = new SimpleDateFormat("yyyy-MM-dd").parse(houseAndHoldExcel.getGoOutTime()); |
| | | one.setGoOutTime(date); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | one.setGoOutWhere(houseAndHoldExcel.getGoOutWhere()); |
| | | one.setGoOutAddr(houseAndHoldExcel.getGoOutAddr()); |
| | | // 婚姻状态 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getMaritalStatus())){ |
| | | one.setMaritalStatus(Integer.parseInt(houseAndHoldExcel.getMaritalStatus())); |
| | | } |
| | | one.setCardNumber(houseAndHoldExcel.getCardNumber()); |
| | | one.setOtherContact(houseAndHoldExcel.getOtherContact()); |
| | | if (Strings.isBlank(one.getHouseCode())){ |
| | | // 暂时不处理,导入数据目前都有house_code |
| | | String adCode = shiftResidentHomeAdcode(houseAndHoldExcel.getHomeAdcode()); |
| | | // 转换行政区code |
| | | houseAndHoldExcel.setHomeAdcode(adCode); |
| | | } |
| | | one.setCurrentAddress(houseAndHoldExcel.getCurrentAddress()); |
| | | one.setDisabilityCert(houseAndHoldExcel.getDisabilityCert()); |
| | | one.setRemark(houseAndHoldExcel.getRemarks()); |
| | | one.setUpdateTime(new Date()); |
| | | one.setUpdateUser(AuthUtil.getUserId()); |
| | | // 新增 |
| | | boolean update = householdService.updateById(one); |
| | | if (update) { |
| | | 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(one.getId()); |
| | | userHouseLabelEntity.setLableType(1); |
| | | userHouseLabelEntity.setLabelName(s); |
| | | userHouseLabelEntity.setHouseCode(houseAndHoldExcel.getHouseCode()); |
| | | bean.save(userHouseLabelEntity); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 现居住地街道转换 |
| | | * @param homeAdcode |
| | | * @return |
| | | */ |
| | | public String shiftResidentHomeAdcode(String homeAdcode) { |
| | | // 只根据区县名称查询 |
| | | QueryWrapper<Region> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("town_name",homeAdcode); |
| | | List<Region> list = regionService.list(wrapper); |
| | | if (list.size()==1){ |
| | | return list.get(0).getTownCode(); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 根据名称转成code |
| | | * @param residentProvinceAdcode 省名称 |
| | | * @param residentCityAdcode 市名称 |
| | | * @param residentAdcode 区县名称 |
| | | */ |
| | | public String shiftResidentResidentAdCode(String residentProvinceAdcode,String residentCityAdcode,String residentAdcode) { |
| | | if (!Strings.isBlank(residentProvinceAdcode) |
| | | && !Strings.isBlank(residentCityAdcode)){ |
| | | // 根据省市县三级查询对应的区县code |
| | | QueryWrapper<Region> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("province_name",residentProvinceAdcode) |
| | | .eq("city_name",residentCityAdcode) |
| | | .eq("district_name",residentAdcode); |
| | | List<Region> list = regionService.list(wrapper); |
| | | if (list.size()>0){ |
| | | return list.get(0).getDistrictCode(); |
| | | } |
| | | }else { |
| | | // 只根据区县名称查询 |
| | | QueryWrapper<Region> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("district_name",residentAdcode); |
| | | List<Region> list = regionService.list(wrapper); |
| | | if (list.size()==1){ |
| | | return list.get(0).getDistrictCode(); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 保存或更新用户(业主) |
| | | * @param householdEntity |
| | | */ |