|
@@ -9,13 +9,20 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
|
import com.ruoyi.web.domain.dto.person.PersonInfoQueryRequest;
|
|
import com.ruoyi.web.domain.dto.person.PersonInfoQueryRequest;
|
|
|
|
+import com.ruoyi.web.domain.entity.HouseInfo;
|
|
|
|
+import com.ruoyi.web.domain.entity.HouseholdInfo;
|
|
import com.ruoyi.web.domain.entity.PersonInfo;
|
|
import com.ruoyi.web.domain.entity.PersonInfo;
|
|
|
|
+import com.ruoyi.web.mapper.HouseInfoMapper;
|
|
import com.ruoyi.web.mapper.PersonInfoMapper;
|
|
import com.ruoyi.web.mapper.PersonInfoMapper;
|
|
|
|
+import com.ruoyi.web.service.HouseInfoService;
|
|
|
|
+import com.ruoyi.web.service.HouseholdInfoService;
|
|
import com.ruoyi.web.service.PersonInfoService;
|
|
import com.ruoyi.web.service.PersonInfoService;
|
|
import com.ruoyi.web.domain.vo.PersonInfoVO;
|
|
import com.ruoyi.web.domain.vo.PersonInfoVO;
|
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -27,8 +34,19 @@ import java.util.stream.Collectors;
|
|
public class PersonInfoServiceImpl extends ServiceImpl<PersonInfoMapper, PersonInfo>
|
|
public class PersonInfoServiceImpl extends ServiceImpl<PersonInfoMapper, PersonInfo>
|
|
implements PersonInfoService {
|
|
implements PersonInfoService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private HouseInfoService houseInfoService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private HouseInfoMapper houseInfoMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private HouseholdInfoService householdInfoService;
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询人员信息列表
|
|
* 查询人员信息列表
|
|
|
|
+ *
|
|
* @param personInfoQueryRequest
|
|
* @param personInfoQueryRequest
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -49,15 +67,55 @@ public class PersonInfoServiceImpl extends ServiceImpl<PersonInfoMapper, PersonI
|
|
|
|
|
|
/**
|
|
/**
|
|
* 分页获取人员列表
|
|
* 分页获取人员列表
|
|
|
|
+ *
|
|
* @param personInfoQueryRequest
|
|
* @param personInfoQueryRequest
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Page<PersonInfo> getListPersonInfoByPage(PersonInfoQueryRequest personInfoQueryRequest) {
|
|
|
|
|
|
+ public Page<PersonInfoVO> getListPersonInfoByPage(PersonInfoQueryRequest personInfoQueryRequest) {
|
|
long current = personInfoQueryRequest.getCurrent();
|
|
long current = personInfoQueryRequest.getCurrent();
|
|
long size = personInfoQueryRequest.getPageSize();
|
|
long size = personInfoQueryRequest.getPageSize();
|
|
- return this.page(new Page<>(current, size),
|
|
|
|
|
|
+ Page<PersonInfo> personInfoPage = this.page(new Page<>(current, size),
|
|
getQueryWrapper(personInfoQueryRequest));
|
|
getQueryWrapper(personInfoQueryRequest));
|
|
|
|
+
|
|
|
|
+ // 2. 补充关联数据
|
|
|
|
+ Page<PersonInfoVO> resultPage = new Page<>();
|
|
|
|
+ BeanUtils.copyProperties(personInfoPage, resultPage, "records");
|
|
|
|
+
|
|
|
|
+ // 3. 处理每条记录
|
|
|
|
+ List<PersonInfoVO> viewList = personInfoPage.getRecords().stream().map(personInfo -> {
|
|
|
|
+ PersonInfoVO personInfoVO = new PersonInfoVO();
|
|
|
|
+ BeanUtils.copyProperties(personInfo, personInfoVO);
|
|
|
|
+
|
|
|
|
+ // 联表查询补充数据
|
|
|
|
+ if (personInfo.getHouseholdId() != null) {
|
|
|
|
+ // 查询户籍信息
|
|
|
|
+ HouseholdInfo household = householdInfoService.getById(personInfo.getHouseholdId());
|
|
|
|
+ if (household != null) {
|
|
|
|
+ //户主姓名
|
|
|
|
+ String householdHead = household.getHouseholdHead();
|
|
|
|
+ personInfoVO.setHouseHoldHead(householdHead);
|
|
|
|
+
|
|
|
|
+ // 查询房屋信息
|
|
|
|
+ if (StrUtil.isNotBlank(household.getHouseCode())) {
|
|
|
|
+ HouseInfo house = houseInfoMapper.selectOne(
|
|
|
|
+ new QueryWrapper<HouseInfo>()
|
|
|
|
+ .eq("house_code", household.getHouseCode())
|
|
|
|
+ .last("LIMIT 1"));
|
|
|
|
+ if (house != null) {
|
|
|
|
+ // 房屋编号
|
|
|
|
+ personInfoVO.setHouseCode(house.getHouseCode());
|
|
|
|
+ // 门牌号
|
|
|
|
+ personInfoVO.setDoorplateNumber(house.getDoorplateNumber());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return personInfoVO;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ resultPage.setRecords(viewList);
|
|
|
|
+ return resultPage;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -77,35 +135,31 @@ public class PersonInfoServiceImpl extends ServiceImpl<PersonInfoMapper, PersonI
|
|
// 从对象中取值
|
|
// 从对象中取值
|
|
Integer id = personInfoQueryRequest.getId();
|
|
Integer id = personInfoQueryRequest.getId();
|
|
String realname = personInfoQueryRequest.getRealname();
|
|
String realname = personInfoQueryRequest.getRealname();
|
|
- String idCard = personInfoQueryRequest.getIdCard();
|
|
|
|
String ethnic = personInfoQueryRequest.getEthnic();
|
|
String ethnic = personInfoQueryRequest.getEthnic();
|
|
- Integer age = personInfoQueryRequest.getAge();
|
|
|
|
- Integer gender = personInfoQueryRequest.getGender();
|
|
|
|
- Date birthDate = personInfoQueryRequest.getBirthDate();
|
|
|
|
- Integer populationCategory = personInfoQueryRequest.getPopulationCategory();
|
|
|
|
- String phone = personInfoQueryRequest.getPhone();
|
|
|
|
- List<String> populationTags = personInfoQueryRequest.getPopulationTags();
|
|
|
|
- String occupationId = personInfoQueryRequest.getOccupationId();
|
|
|
|
- Integer villageId = personInfoQueryRequest.getVillageId();
|
|
|
|
- String specialIdentityCode = personInfoQueryRequest.getSpecialIdentityCode();
|
|
|
|
|
|
+ String doorplateNumber = personInfoQueryRequest.getDoorplateNumber();
|
|
String specialIdentity = personInfoQueryRequest.getSpecialIdentity();
|
|
String specialIdentity = personInfoQueryRequest.getSpecialIdentity();
|
|
|
|
+ List<String> populationTags = personInfoQueryRequest.getPopulationTags();
|
|
String sortField = personInfoQueryRequest.getSortField();
|
|
String sortField = personInfoQueryRequest.getSortField();
|
|
String sortOrder = personInfoQueryRequest.getSortOrder();
|
|
String sortOrder = personInfoQueryRequest.getSortOrder();
|
|
|
|
|
|
|
|
+
|
|
// 姓名、民族、房屋门牌号、特殊身份、人口标签
|
|
// 姓名、民族、房屋门牌号、特殊身份、人口标签
|
|
queryWrapper.eq(ObjectUtil.isNotEmpty(id), "id", id);
|
|
queryWrapper.eq(ObjectUtil.isNotEmpty(id), "id", id);
|
|
- queryWrapper.eq(StrUtil.isNotBlank(realname), "realname", realname);
|
|
|
|
- queryWrapper.eq(StrUtil.isNotBlank(idCard), "id_card", idCard);
|
|
|
|
|
|
+ queryWrapper.like(StrUtil.isNotBlank(realname), "realname", realname);
|
|
queryWrapper.eq(StrUtil.isNotBlank(ethnic), "ethnic", ethnic);
|
|
queryWrapper.eq(StrUtil.isNotBlank(ethnic), "ethnic", ethnic);
|
|
- queryWrapper.eq(ObjectUtil.isNotEmpty(age), "age", age);
|
|
|
|
- queryWrapper.eq(ObjectUtil.isNotEmpty(gender), "gender", gender);
|
|
|
|
- queryWrapper.eq(ObjectUtil.isNotEmpty(populationCategory), "population_category", populationCategory);
|
|
|
|
- queryWrapper.eq(StrUtil.isNotBlank(phone), "phone", phone);
|
|
|
|
- queryWrapper.eq(StrUtil.isNotBlank(occupationId), "occupation_id", occupationId);
|
|
|
|
queryWrapper.eq(StrUtil.isNotBlank(specialIdentity), "special_identity", specialIdentity);
|
|
queryWrapper.eq(StrUtil.isNotBlank(specialIdentity), "special_identity", specialIdentity);
|
|
|
|
|
|
|
|
+
|
|
|
|
+ // 门牌号查询人员列表
|
|
|
|
+ if (StrUtil.isNotBlank(doorplateNumber)) {
|
|
|
|
+ String subQuery = "SELECT hd.id FROM household_info hd " +
|
|
|
|
+ "JOIN house_info hi ON hd.house_code = hi.house_code " +
|
|
|
|
+ "WHERE hi.doorplate_number = '" + doorplateNumber + "'";
|
|
|
|
+ queryWrapper.inSql("household_id", subQuery);
|
|
|
|
+ }
|
|
|
|
+
|
|
// 人口标签 JSON 数组查询
|
|
// 人口标签 JSON 数组查询
|
|
- if(CollUtil.isNotEmpty(populationTags)){
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(populationTags)) {
|
|
for (String tag : populationTags) {
|
|
for (String tag : populationTags) {
|
|
queryWrapper.like("population_tags", "\"" + tag + "\"");
|
|
queryWrapper.like("population_tags", "\"" + tag + "\"");
|
|
}
|
|
}
|