Browse Source

【政策】鱼烂接口修改bug

dev
wangxianzhang 3 years ago
parent
commit
3d221b45d6
  1. 24
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/IcHouseDao.java
  2. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java
  3. 39
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  4. 50
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/ResiServiceImpl.java
  5. 14
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/IcResiUserDao.xml
  6. 35
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/IcHouseDao.xml

24
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/IcHouseDao.java

@ -1,8 +1,12 @@
package com.epmet.dataaggre.dao.govorg; package com.epmet.dataaggre.dao.govorg;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.epmetuser.form.ResisByPolicyRulesFormDTO;
import com.epmet.dataaggre.entity.govorg.IcHouseEntity; import com.epmet.dataaggre.entity.govorg.IcHouseEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 房屋信息 * 房屋信息
@ -12,4 +16,24 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface IcHouseDao extends BaseDao<IcHouseEntity> { public interface IcHouseDao extends BaseDao<IcHouseEntity> {
/**
* 为政策-预览居民提供房屋id列表查询
* @param orgIdPath
* @param customerId
* @param neighborHoodId
* @param buildingId
* @param unitId
* @param houseId
* @param houseRule
* @param statRule
* @return
*/
List<String> listHouseIds4PolicyResis(@Param("orgIdPath") String orgIdPath,
@Param("customerId") String customerId,
@Param("neighborHoodId") String neighborHoodId,
@Param("buildingId") String buildingId,
@Param("unitId") String unitId,
@Param("houseId") String houseId,
@Param("houseRule") List<ResisByPolicyRulesFormDTO.HouseRule> houseRule,
@Param("statRule") List<ResisByPolicyRulesFormDTO.StatRule> statRule);
} }

2
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java

@ -218,7 +218,7 @@ public interface GovOrgService {
*/ */
CustomerAgencyEntity getRootAgencyByCustomerId(String customerId); CustomerAgencyEntity getRootAgencyByCustomerId(String customerId);
List<IcHouseEntity> listHousesByRules(String customerId, String orgIdPath, String orgId, String orgType, String neighborHoodId, String buildingId, List<String> listHouseIdsByRules(String customerId, String orgIdPath, String orgId, String orgType, String neighborHoodId, String buildingId,
String unitId, String houseId, List<ResisByPolicyRulesFormDTO.HouseRule> houseRule, String unitId, String houseId, List<ResisByPolicyRulesFormDTO.HouseRule> houseRule,
List<ResisByPolicyRulesFormDTO.StatRule> statRule, Integer pageNo, Integer pageSize); List<ResisByPolicyRulesFormDTO.StatRule> statRule, Integer pageNo, Integer pageSize);

39
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java

@ -1110,7 +1110,7 @@ public class GovOrgServiceImpl implements GovOrgService {
} }
@Override @Override
public List<IcHouseEntity> listHousesByRules(String customerId, String orgIdPath, String orgId, String orgType, String neighborHoodId, String buildingId, public List<String> listHouseIdsByRules(String customerId, String orgIdPath, String orgId, String orgType, String neighborHoodId, String buildingId,
String unitId, String houseId, List<ResisByPolicyRulesFormDTO.HouseRule> houseRule, String unitId, String houseId, List<ResisByPolicyRulesFormDTO.HouseRule> houseRule,
List<ResisByPolicyRulesFormDTO.StatRule> statRule, Integer pageNo, Integer pageSize) { List<ResisByPolicyRulesFormDTO.StatRule> statRule, Integer pageNo, Integer pageSize) {
@ -1118,47 +1118,12 @@ public class GovOrgServiceImpl implements GovOrgService {
return new ArrayList<>(); return new ArrayList<>();
} }
QueryWrapper<IcHouseEntity> query = new QueryWrapper<>();
// 如果参数里面选了,就用参数选择的来查询,没有选择的话,就查询当前工作人员所属组织的本级及下级
if (StringUtils.isNotBlank(orgId) && StringUtils.isNotBlank(orgType)) { if (StringUtils.isNotBlank(orgId) && StringUtils.isNotBlank(orgType)) {
orgIdPath = getOrgIdPath(orgId, orgType); orgIdPath = getOrgIdPath(orgId, orgType);
} }
query.likeRight(StringUtils.isNotBlank(orgIdPath), "ORG_ID_PATH", orgIdPath);
if (StringUtils.isNotBlank(customerId)) {
query.eq("CUSTOMER_ID", customerId);
}
if (StringUtils.isNotBlank(neighborHoodId)) {
query.eq("NEIGHBOR_HOOD_ID", neighborHoodId);
}
if (StringUtils.isNotBlank(buildingId)) {
query.eq("BUILDING_ID", buildingId);
}
if (StringUtils.isNotBlank(unitId)) {
query.eq("BUILDING_UNIT_ID", unitId);
}
if (StringUtils.isNotBlank(houseId)) {
query.eq("ID", houseId);
}
// 房屋属性
if (CollectionUtils.isNotEmpty(houseRule)) {
for (ResisByPolicyRulesFormDTO.HouseRule rule : houseRule) {
query.eq(rule.getColKey(), rule.getColVal());
}
}
// 房屋的统计属性
if (CollectionUtils.isNotEmpty(statRule)) {
for (ResisByPolicyRulesFormDTO.StatRule rule : statRule) {
query.eq(rule.getColKey(), rule.getColVal());
}
}
PageHelper.startPage(pageNo, pageSize); PageHelper.startPage(pageNo, pageSize);
return houseDao.selectList(query); return houseDao.listHouseIds4PolicyResis(orgIdPath, customerId, neighborHoodId, buildingId, unitId, houseId, houseRule, statRule);
} }
@Override @Override

50
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/ResiServiceImpl.java

@ -31,11 +31,15 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
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 org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.time.*; import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -65,6 +69,9 @@ public class ResiServiceImpl implements ResiService, ResultDataResolver {
String client = EpmetRequestHolder.getLoginUserClient(); String client = EpmetRequestHolder.getLoginUserClient();
String customerId = EpmetRequestHolder.getLoginUserCustomerId(); String customerId = EpmetRequestHolder.getLoginUserCustomerId();
// 对特殊规则进行转换。
specificRuleConvert(resiRule);
// 查询当前组织及下级id路径 // 查询当前组织及下级id路径
LoginUserDetailsResultDTO userDetail = getResultDataOrThrowsException(userOpenFeignClient.getLoginUserDetails(new LoginUserDetailsFormDTO(app, client, userId)), LoginUserDetailsResultDTO userDetail = getResultDataOrThrowsException(userOpenFeignClient.getLoginUserDetails(new LoginUserDetailsFormDTO(app, client, userId)),
ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null);
@ -87,9 +94,8 @@ public class ResiServiceImpl implements ResiService, ResultDataResolver {
int total = 0; int total = 0;
do { do {
// 拿到房屋id列表,去查询居民列表 // 拿到房屋id列表,去查询居民列表
List<IcHouseEntity> houseEntities = govOrgService.listHousesByRules(customerId, orgIdPath, orgId, orgType, neighborHoodId, buildingId, unitId, List<String> houseIds = govOrgService.listHouseIdsByRules(customerId, orgIdPath, orgId, orgType, neighborHoodId, buildingId, unitId,
houseId, houseRule, statRule, housePageNo, 50); houseId, houseRule, statRule, housePageNo, 50);
List<String> houseIds = houseEntities.stream().map(icHouseEntity -> icHouseEntity.getId()).collect(Collectors.toList());
if (houseIds.size() == 0) { if (houseIds.size() == 0) {
// 用户使用了房屋和统计相关的条件,但是没查到房屋,我看就没有走下去了的必要了吧.. // 用户使用了房屋和统计相关的条件,但是没查到房屋,我看就没有走下去了的必要了吧..
@ -125,6 +131,46 @@ public class ResiServiceImpl implements ResiService, ResultDataResolver {
return new PageData<>(resultResis, total); return new PageData<>(resultResis, total);
} }
/**
* 为特定的规则进行转换
* @param resiRule
*/
private void specificRuleConvert(List<ResisByPolicyRulesFormDTO.ResiRule> resiRule) {
// 使用年龄计算出生日期
resiRule.stream().forEach((r) -> {
if ("BIRTHDAY".equals(r.getColKey())) {
LocalDate birthday = LocalDate.now().minus(Long.valueOf(r.getColVal()), ChronoUnit.YEARS);
r.setQueryType(revertQueryType(r.getQueryType()));
r.setColVal(birthday.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
}
});
}
/**
* 翻转逻辑操作符
* @param oldRel
* @return
*/
private String revertQueryType(String oldRel) {
if (">".equals(oldRel)) {
return "<";
}
if (">=".equals(oldRel)) {
return "<=";
}
if ("<".equals(oldRel)) {
return ">";
}
if ("<=".equals(oldRel)) {
return ">=";
}
return "";
}
/** /**
* 补充额外信息 * 补充额外信息
* @param resultResis * @param resultResis

14
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/IcResiUserDao.xml

@ -124,13 +124,13 @@
<!--政策查找--> <!--政策查找-->
<select id="listByPolicyRules" resultType="com.epmet.dataaggre.dto.epmetuser.result.ResiByPolicyInfoResultDTO"> <select id="listByPolicyRules" resultType="com.epmet.dataaggre.dto.epmetuser.result.ResiByPolicyInfoResultDTO">
select `ID` as icResiUserId, select ic_resi_user.`ID` as icResiUserId,
`GRID_ID`, ic_resi_user.`GRID_ID`,
`NAME`, ic_resi_user.`NAME`,
`MOBILE`, ic_resi_user.`MOBILE`,
`ID_CARD`, ic_resi_user.`ID_CARD`,
`VILLAGE_ID` as neighborhoodId, ic_resi_user.`VILLAGE_ID` as neighborhoodId,
`BIRTHDAY` ic_resi_user.`BIRTHDAY`
from ic_resi_user from ic_resi_user
<foreach collection="resiRules" item="rule"> <foreach collection="resiRules" item="rule">
<if test="rule.colTable != 'ic_resi_user'"> inner join #{rule.colTable}</if> <if test="rule.colTable != 'ic_resi_user'"> inner join #{rule.colTable}</if>

35
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/IcHouseDao.xml

@ -3,4 +3,39 @@
<mapper namespace="com.epmet.dataaggre.dao.govorg.IcHouseDao"> <mapper namespace="com.epmet.dataaggre.dao.govorg.IcHouseDao">
<!--为政策-预览居民,提供房屋id列表查询-->
<select id="listHouseIds4PolicyResis" resultType="java.lang.String">
select ic_house.ID
from ic_house
<where>
DEL_FLAG = '0'
and ic_house.CUSTOMER_ID = #{customerId}
and ic_house.ORG_ID_PATH like CONCAT(#{orgIdPath}, '%')
<if test="neighborHoodId != null and neighborHoodId != ''">
and ic_house.NEIGHBOR_HOOD_ID = #{neighborHoodId}
</if>
<if test="buildingId != null and buildingId != ''">
and ic_house.BUILDING_ID = #{buildingId}
</if>
<if test="unitId != null and unitId != ''">
and ic_house.BUILDING_UNIT_ID = #{unitId}
</if>
<if test="houseId != null and houseId != ''">
and ic_house.ID = #{houseId}
</if>
<if test="houseRule != null and houseRule.size() > 0">
and
<foreach collection="houseRule" item="rule" open="(" close=")">
${rule.colTable}.${rule.colKey} ${rule.queryType} #{rule.colVal} ${rule.nextLogicalRel}
</foreach>
</if>
<if test="statRule != null and statRule.size() > 0">
and
<foreach collection="statRule" item="rule" open="(" close=")">
${rule.colTable}.${rule.colKey} ${rule.queryType} #{rule.colVal} ${rule.nextLogicalRel}
</foreach>
</if>
</where>
</select>
</mapper> </mapper>

Loading…
Cancel
Save