42 changed files with 1229 additions and 67 deletions
@ -0,0 +1,18 @@ |
|||
package com.epmet.dto.customize; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
|
|||
|
|||
@Data |
|||
public class IcResiCategoryConfigDTO implements Serializable { |
|||
private String configId; |
|||
/** |
|||
* 列名 |
|||
*/ |
|||
private String columnName; |
|||
|
|||
private String itemLabel; |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.epmet.dto.extract.form; |
|||
|
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 数字社区-人员类别分析,按天计算,入参 |
|||
* 以下参数都可以为空 |
|||
*/ |
|||
@Data |
|||
public class IcUserCategoryAnalysisDailyFormDTO implements Serializable { |
|||
public interface AddUserInternalGroup { |
|||
} |
|||
|
|||
private String customerId; |
|||
@Length(max = 8, message = "日期格式:yyyyMMdd", groups = AddUserInternalGroup.class) |
|||
private String dateId; |
|||
|
|||
/** |
|||
* 开始时间 |
|||
*/ |
|||
@Length(max = 8, message = "开始日期日期格式:yyyyMMdd", groups = AddUserInternalGroup.class) |
|||
private String startDate; |
|||
/** |
|||
* 结束时间 |
|||
*/ |
|||
@Length(max = 8, message = "截止日期格式:yyyyMMdd", groups = AddUserInternalGroup.class) |
|||
private String endDate; |
|||
|
|||
} |
@ -0,0 +1,12 @@ |
|||
package com.epmet.dto.user.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Data |
|||
public class OrgIcUserTotalDTO implements Serializable { |
|||
private String orgId; |
|||
private Integer total; |
|||
private String columnName; |
|||
} |
@ -0,0 +1,76 @@ |
|||
package com.epmet.controller; |
|||
|
|||
|
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.utils.DateUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.dto.extract.form.IcUserCategoryAnalysisDailyFormDTO; |
|||
import com.epmet.service.stats.DimCustomerService; |
|||
import com.epmet.service.stats.FactIcuserCategoryAnalysisDailyService; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 数字社区相关统计任务可以放这,目前只有人员类别分析 |
|||
* @Author yinzuomei |
|||
* @Date 2022/01/17 |
|||
* @Version 1.0 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("ic") |
|||
public class IcController { |
|||
|
|||
@Autowired |
|||
private FactIcuserCategoryAnalysisDailyService userCategoryAnalysisDailyService; |
|||
@Autowired |
|||
private DimCustomerService dimCustomerService; |
|||
|
|||
/** |
|||
* 数字社区-基础信息-人员类别分析-每个类别的人员总数、较上月迁入迁出人数 |
|||
* 说明:安调统计,截止到当前dateId的党员总数;+30:迁入党员+之前的居民在本月内变更为党员身份的;-10:在本月丢失党员身份的人+迁出的人 |
|||
* @return |
|||
*/ |
|||
@PostMapping("/user/category-analysis-daily") |
|||
public Result statUserCategoryDaily(@RequestBody IcUserCategoryAnalysisDailyFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO, IcUserCategoryAnalysisDailyFormDTO.AddUserInternalGroup.class); |
|||
List<String> customerIds = new ArrayList<>(); |
|||
if (StringUtils.isNotBlank(formDTO.getCustomerId())) { |
|||
customerIds.add(formDTO.getCustomerId()); |
|||
} else { |
|||
//未指定客户,则查询dim_customer表
|
|||
customerIds = dimCustomerService.selectCustomerIdPage(NumConstant.ONE, NumConstant.ONE_THOUSAND); |
|||
} |
|||
if (CollectionUtils.isNotEmpty(customerIds)) { |
|||
customerIds.forEach(customerId -> { |
|||
if (StringUtils.isNotBlank(formDTO.getStartDate()) && StringUtils.isNotBlank(formDTO.getEndDate())) { |
|||
//[a,b]yyyyMMdd
|
|||
List<String> daysBetween = DateUtils.getDaysBetween(formDTO.getStartDate(), formDTO.getEndDate()); |
|||
daysBetween.forEach(dateId -> { |
|||
//计算网格维度的数据
|
|||
userCategoryAnalysisDailyService.statUserCategoryGridDaily(customerId, dateId); |
|||
}); |
|||
} else if (StringUtils.isNotBlank(formDTO.getDateId())) { |
|||
//计算网格维度的数据
|
|||
userCategoryAnalysisDailyService.statUserCategoryGridDaily(customerId, formDTO.getDateId()); |
|||
} else { |
|||
//计算网格维度的数据
|
|||
//当前时间的前一天yyyyMMdd
|
|||
String dateId = LocalDate.now().minusDays(NumConstant.ONE).toString().replace("-", ""); |
|||
userCategoryAnalysisDailyService.statUserCategoryGridDaily(customerId, dateId); |
|||
} |
|||
}); |
|||
} |
|||
return new Result(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,101 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.constant.StrConstant; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.redis.RedisKeys; |
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import com.epmet.commons.tools.utils.DateUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.StatsFormDTO; |
|||
import com.epmet.dto.extract.form.ExtractOriginFormDTO; |
|||
import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO; |
|||
import com.epmet.service.StatsProjectService; |
|||
import com.epmet.service.evaluationindex.extract.toscreen.ScreenGrassrootsGovernDataAbsorptionService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.LinkedHashSet; |
|||
import java.util.List; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* desc:市北数字社区 单独部署 job入口 【用户积分排名及项目状态数据】 |
|||
*/ |
|||
@RequestMapping("shibeiICJob") |
|||
@RestController |
|||
@Slf4j |
|||
public class ShiBeiICJobController { |
|||
@Autowired |
|||
private ScreenGrassrootsGovernDataAbsorptionService screenGrassrootsGovernDataAbsorptionService; |
|||
@Autowired |
|||
private StatsProjectService statsProjectService; |
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
@PostMapping("userPointAndProjectStatus") |
|||
public Result<String> userPointAndProjectStatus(@RequestBody ExtractOriginFormDTO formDTO) { |
|||
if (StringUtils.isBlank(formDTO.getCustomerId())){ |
|||
return new Result<String>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误cid不能为空"); |
|||
} |
|||
long start = System.currentTimeMillis(); |
|||
Set<String> result = new LinkedHashSet<>(); |
|||
if (StringUtils.isNotBlank(formDTO.getStartDate()) && StringUtils.isNotBlank(formDTO.getEndDate())) { |
|||
List<String> daysBetween = DateUtils.getDaysBetween(formDTO.getStartDate(), formDTO.getEndDate()); |
|||
daysBetween.forEach(d -> { |
|||
this.extractUserPointData(formDTO.getCustomerId(), d); |
|||
this.agencyProjectStats(formDTO.getCustomerId(), formDTO.getDateId()); |
|||
result.add(d); |
|||
redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus"), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L); |
|||
}); |
|||
} else { |
|||
if (StringUtils.isBlank(formDTO.getDateId())){ |
|||
formDTO.setDateId(DateUtils.getBeforeNDay(NumConstant.ONE)); |
|||
} |
|||
this.extractUserPointData(formDTO.getCustomerId(), formDTO.getDateId()); |
|||
this.agencyProjectStats(formDTO.getCustomerId(), formDTO.getDateId()); |
|||
result.add(formDTO.getDateId()); |
|||
redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus"), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L); |
|||
} |
|||
long end = System.currentTimeMillis(); |
|||
long l = (end - start) / 1000; |
|||
return new Result<String>().ok("userPointAndProjectStatus耗时" + l + "s"); |
|||
} |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 数据-项目-机关日(月)统计 |
|||
**/ |
|||
private Result agencyProjectStats(String customerId, String dateId) { |
|||
try { |
|||
if (StringUtils.isNotBlank(dateId)) { |
|||
dateId = DateUtils.format(DateUtils.parseDate(dateId, DateUtils.DATE_PATTERN_YYYYMMDD)); |
|||
} |
|||
StatsFormDTO formDTO = new StatsFormDTO(); |
|||
formDTO.setCustomerId(customerId); |
|||
formDTO.setDate(dateId); |
|||
|
|||
statsProjectService.agencyProjectStats(formDTO); |
|||
} catch (Exception e) { |
|||
log.error("市北-项目状态数据写入失败,参数为:{}" + customerId + StrConstant.HYPHEN + dateId, e); |
|||
} |
|||
return new Result(); |
|||
} |
|||
|
|||
private void extractUserPointData(String customerId, String dateId) { |
|||
try { |
|||
//基层治理 - 热心市民 screen_party_user_rank_data
|
|||
ScreenCentralZoneDataFormDTO param = new ScreenCentralZoneDataFormDTO(); |
|||
param.setCustomerId(customerId); |
|||
param.setDateId(dateId); |
|||
screenGrassrootsGovernDataAbsorptionService.userScoreDataHub(param); |
|||
} catch (Exception e) { |
|||
log.error("市北-热心市民/党员得分数据写入失败,参数为:{}" + customerId + StrConstant.HYPHEN + dateId, e); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.epmet.dao.customize; |
|||
|
|||
|
|||
import com.epmet.dto.customize.IcResiCategoryConfigDTO; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface IcResiCategoryStatsConfigDao { |
|||
|
|||
|
|||
List<IcResiCategoryConfigDTO> queryDataColumn(String customerId); |
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.dao.stats; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.entity.stats.FactIcuserCategoryAnalysisDailyEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
/** |
|||
* 人员类别分析 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-01-17 |
|||
*/ |
|||
@Mapper |
|||
public interface FactIcuserCategoryAnalysisDailyDao extends BaseDao<FactIcuserCategoryAnalysisDailyEntity> { |
|||
|
|||
int limitDelete(@Param("customerId")String customerId, |
|||
@Param("dateId")String dateId, |
|||
@Param("orgType")String orgType); |
|||
} |
@ -0,0 +1,74 @@ |
|||
package com.epmet.entity.stats; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 人员类别分析 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-01-17 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("fact_icuser_category_analysis_daily") |
|||
public class FactIcuserCategoryAnalysisDailyEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 预警配置ID |
|||
*/ |
|||
private String configId; |
|||
/** |
|||
* 类别列名,对个数据太麻烦了,在这个表存一下 |
|||
*/ |
|||
private String columnName; |
|||
/** |
|||
* 当前数据是截止到XXX的:yyyyMMdd |
|||
*/ |
|||
private String dateId; |
|||
|
|||
/** |
|||
* 网格id或者组织id |
|||
*/ |
|||
private String orgId; |
|||
|
|||
/** |
|||
* grid或者agency |
|||
*/ |
|||
private String orgType; |
|||
|
|||
/** |
|||
* orgid的上级 |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* orgid的所有上级 |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 当前类别总人数 |
|||
*/ |
|||
private Integer total; |
|||
|
|||
/** |
|||
* 较上月迁出 |
|||
*/ |
|||
private Integer qcIncr; |
|||
|
|||
/** |
|||
* 较上月迁入 |
|||
*/ |
|||
private Integer qrIncr; |
|||
|
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.epmet.service.customize; |
|||
|
|||
|
|||
import com.epmet.dto.customize.IcResiCategoryConfigDTO; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 居民类别配置表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-11-04 |
|||
*/ |
|||
public interface IcResiCategoryStatsConfigService { |
|||
|
|||
/** |
|||
* 返回用于数据分析的列名+居民类别配置表的id |
|||
* @param customerId |
|||
* @return |
|||
*/ |
|||
List<IcResiCategoryConfigDTO> queryDataColumn(String customerId); |
|||
} |
@ -0,0 +1,40 @@ |
|||
package com.epmet.service.customize.impl; |
|||
|
|||
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|||
import com.epmet.constant.DataSourceConstant; |
|||
import com.epmet.dao.customize.IcResiCategoryStatsConfigDao; |
|||
import com.epmet.dto.customize.IcResiCategoryConfigDTO; |
|||
import com.epmet.service.customize.IcResiCategoryStatsConfigService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 居民类别配置表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-11-04 |
|||
*/ |
|||
@Slf4j |
|||
@DataSource(DataSourceConstant.OPER_CUSTOMIZE) |
|||
@Service |
|||
public class IcResiCategoryStatsConfigServiceImpl implements IcResiCategoryStatsConfigService{ |
|||
|
|||
@Autowired |
|||
private IcResiCategoryStatsConfigDao baseDao; |
|||
|
|||
|
|||
/** |
|||
* 返回用于数据分析的列名+居民类别配置表的id |
|||
* |
|||
* @param customerId |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<IcResiCategoryConfigDTO> queryDataColumn(String customerId) { |
|||
return baseDao.queryDataColumn(customerId); |
|||
} |
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.service.stats; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.entity.stats.FactIcuserCategoryAnalysisDailyEntity; |
|||
|
|||
/** |
|||
* 人员类别分析 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-01-17 |
|||
*/ |
|||
public interface FactIcuserCategoryAnalysisDailyService extends BaseService<FactIcuserCategoryAnalysisDailyEntity> { |
|||
/** |
|||
* 数字社区-基础信息-人员类别分析-每个类别的人员总数、较上月迁入迁出人数 |
|||
* 网格 |
|||
* @param customerId |
|||
* @param dateId |
|||
*/ |
|||
void statUserCategoryGridDaily(String customerId, String dateId); |
|||
} |
@ -0,0 +1,198 @@ |
|||
package com.epmet.service.stats.impl; |
|||
|
|||
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.enums.OrgTypeEnum; |
|||
import com.epmet.constant.DataSourceConstant; |
|||
import com.epmet.dao.stats.FactIcuserCategoryAnalysisDailyDao; |
|||
import com.epmet.dto.customize.IcResiCategoryConfigDTO; |
|||
import com.epmet.dto.user.result.OrgIcUserTotalDTO; |
|||
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity; |
|||
import com.epmet.entity.stats.FactIcuserCategoryAnalysisDailyEntity; |
|||
import com.epmet.service.customize.IcResiCategoryStatsConfigService; |
|||
import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; |
|||
import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService; |
|||
import com.epmet.service.stats.FactIcuserCategoryAnalysisDailyService; |
|||
import com.epmet.service.user.UserService; |
|||
import com.google.common.collect.Lists; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.apache.commons.collections4.MapUtils; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 人员类别分析 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-01-17 |
|||
*/ |
|||
@Service |
|||
@Slf4j |
|||
@DataSource(DataSourceConstant.STATS) |
|||
public class FactIcuserCategoryAnalysisDailyServiceImpl extends BaseServiceImpl<FactIcuserCategoryAnalysisDailyDao, FactIcuserCategoryAnalysisDailyEntity> implements FactIcuserCategoryAnalysisDailyService { |
|||
|
|||
@Autowired |
|||
private IcResiCategoryStatsConfigService icResiCategoryStatsConfigService; |
|||
@Autowired |
|||
private ScreenCustomerAgencyService agencyService; |
|||
@Autowired |
|||
private ScreenCustomerGridService gridService; |
|||
@Autowired |
|||
private UserService userService; |
|||
|
|||
/** |
|||
* 数字社区-基础信息-人员类别分析-每个类别的人员总数、较上月迁入迁出人数 |
|||
* |
|||
* @param customerId |
|||
* @param dateId |
|||
*/ |
|||
@Override |
|||
public void statUserCategoryGridDaily(String customerId, String dateId) { |
|||
//查询出所有用语数据分析的类别column_name,没有则不计算
|
|||
List<IcResiCategoryConfigDTO> columnList = icResiCategoryStatsConfigService.queryDataColumn(customerId); |
|||
if (CollectionUtils.isEmpty(columnList)) { |
|||
return; |
|||
} |
|||
//所有网格查询出来
|
|||
List<ScreenCustomerGridEntity> gridDTOList = gridService.getByCustomerId(customerId); |
|||
if (CollectionUtils.isEmpty(gridDTOList)) { |
|||
return; |
|||
} |
|||
//网格维度、组织维度初始好数据
|
|||
List<FactIcuserCategoryAnalysisDailyEntity> initList = constructInitValue(customerId, dateId, gridDTOList, columnList); |
|||
if (CollectionUtils.isEmpty(initList)) { |
|||
return; |
|||
} |
|||
//当这3个数都为0的时候不插入数据库了
|
|||
List<FactIcuserCategoryAnalysisDailyEntity> insertList = initList.stream().filter(entity -> (null != entity.getTotal() && entity.getTotal() > 0) |
|||
|| (null != entity.getQcIncr() && entity.getQcIncr() > 0) |
|||
|| (null != entity.getQrIncr() && entity.getQrIncr() > 0)).collect(Collectors.toList()); |
|||
//删除旧数据
|
|||
clearOldDatas(customerId, dateId, OrgTypeEnum.GRID.getCode()); |
|||
// 批量插入数据
|
|||
Lists.partition(insertList, NumConstant.ONE_HUNDRED).forEach(list -> { |
|||
insertBatch(list); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* 删除旧数据 |
|||
* |
|||
* @param customerId |
|||
* @param dateId |
|||
* @param orgType grid、agency |
|||
*/ |
|||
private void clearOldDatas(String customerId, String dateId, String orgType) { |
|||
int deleteNum; |
|||
do { |
|||
//每次删除1000条
|
|||
deleteNum = baseDao.limitDelete(customerId, dateId, orgType); |
|||
} while (deleteNum != NumConstant.ZERO); |
|||
} |
|||
|
|||
/** |
|||
* @param customerId |
|||
* @param dateId yyyyMMdd |
|||
* @param gridDTOList 当前客户下所有的网格 |
|||
* @param columnList 所有需要分析的类别对应的ic_resi_user的列名,目前只有18类 |
|||
* @return |
|||
*/ |
|||
private List<FactIcuserCategoryAnalysisDailyEntity> constructInitValue(String customerId, String dateId, List<ScreenCustomerGridEntity> gridDTOList, List<IcResiCategoryConfigDTO> columnList) { |
|||
List<FactIcuserCategoryAnalysisDailyEntity> list = new ArrayList<>(); |
|||
|
|||
//1、total
|
|||
// 查询明细ic_user_change_detailed变更明细表,各个网格的各个分类的总人数
|
|||
Map<String, List<OrgIcUserTotalDTO>> totalMapList = userService.calGridIcUserTotal(customerId, dateId); |
|||
|
|||
String monthId = dateId.substring(NumConstant.ZERO, NumConstant.SIX); |
|||
String startDate = monthId.concat("01"); |
|||
String endDate = dateId; |
|||
|
|||
//2、迁入+30:eg:dateId:20211226, [20211201,20211226],类别sum值=1的
|
|||
Map<String, List<OrgIcUserTotalDTO>> qrList = userService.calGridIcUserIncr(customerId, startDate, endDate, "qr"); |
|||
|
|||
//3、迁出 -10 :eg:dateId:20211226, [20211201,20211226],类别sum值 !=1的
|
|||
Map<String, List<OrgIcUserTotalDTO>> qcList = userService.calGridIcUserIncr(customerId, startDate, endDate, "qc"); |
|||
|
|||
for (IcResiCategoryConfigDTO config : columnList) { |
|||
gridDTOList.forEach(grid -> { |
|||
FactIcuserCategoryAnalysisDailyEntity gridData = new FactIcuserCategoryAnalysisDailyEntity(); |
|||
gridData.setCustomerId(customerId); |
|||
gridData.setConfigId(config.getConfigId()); |
|||
gridData.setColumnName(config.getColumnName()); |
|||
gridData.setDateId(dateId); |
|||
gridData.setOrgId(grid.getGridId()); |
|||
gridData.setOrgType(OrgTypeEnum.GRID.getCode()); |
|||
gridData.setPid(StringUtils.isNotBlank(grid.getParentAgencyId()) ? grid.getParentAgencyId() : NumConstant.ZERO_STR); |
|||
gridData.setPids(grid.getAllParentIds()); |
|||
|
|||
//截止到目前累计值
|
|||
boolean totalZeroFlag = true; |
|||
if (MapUtils.isNotEmpty(totalMapList) && totalMapList.containsKey(grid.getGridId())) { |
|||
//当前网格下,有的类别
|
|||
List<OrgIcUserTotalDTO> crrentGrid = totalMapList.get(grid.getGridId()); |
|||
if (CollectionUtils.isNotEmpty(crrentGrid)) { |
|||
//各个类别对应的数
|
|||
Map<String, Integer> categoryTotalMap = crrentGrid.stream().collect(Collectors.toMap(OrgIcUserTotalDTO::getColumnName, OrgIcUserTotalDTO::getTotal, (key1, key2) -> key2)); |
|||
if (MapUtils.isNotEmpty(categoryTotalMap) && categoryTotalMap.containsKey(config.getColumnName())) { |
|||
totalZeroFlag = false; |
|||
gridData.setTotal(categoryTotalMap.get(config.getColumnName())); |
|||
} |
|||
} |
|||
} |
|||
if (totalZeroFlag) { |
|||
gridData.setTotal(NumConstant.ZERO); |
|||
} |
|||
|
|||
//较上月迁入
|
|||
boolean incrZeroFlag = true; |
|||
if (MapUtils.isNotEmpty(qrList) && qrList.containsKey(grid.getGridId())) { |
|||
//当前网格下,有的类别
|
|||
List<OrgIcUserTotalDTO> crrentGrid = qrList.get(grid.getGridId()); |
|||
if (CollectionUtils.isNotEmpty(crrentGrid)) { |
|||
//各个类别对应的数
|
|||
Map<String, Integer> categoryTotalMap = crrentGrid.stream().collect(Collectors.toMap(OrgIcUserTotalDTO::getColumnName, OrgIcUserTotalDTO::getTotal, (key1, key2) -> key2)); |
|||
if (MapUtils.isNotEmpty(categoryTotalMap) && categoryTotalMap.containsKey(config.getColumnName())) { |
|||
incrZeroFlag = false; |
|||
gridData.setQrIncr(categoryTotalMap.get(config.getColumnName())); |
|||
} |
|||
} |
|||
} |
|||
if (incrZeroFlag) { |
|||
gridData.setQrIncr(NumConstant.ZERO); |
|||
} |
|||
|
|||
// 较上月迁出:
|
|||
boolean qcZeroFlag = true; |
|||
if (MapUtils.isNotEmpty(qcList) && qcList.containsKey(grid.getGridId())) { |
|||
//当前网格下,有的类别
|
|||
List<OrgIcUserTotalDTO> crrentGridQc = qcList.get(grid.getGridId()); |
|||
if (CollectionUtils.isNotEmpty(crrentGridQc)) { |
|||
//各个类别对应的数
|
|||
Map<String, Integer> categoryTotalMap = crrentGridQc.stream().collect(Collectors.toMap(OrgIcUserTotalDTO::getColumnName, OrgIcUserTotalDTO::getTotal, (key1, key2) -> key2)); |
|||
if (MapUtils.isNotEmpty(categoryTotalMap) && categoryTotalMap.containsKey(config.getColumnName())) { |
|||
qcZeroFlag = false; |
|||
gridData.setQcIncr(categoryTotalMap.get(config.getColumnName())); |
|||
} |
|||
} |
|||
} |
|||
if (qcZeroFlag) { |
|||
gridData.setQcIncr(NumConstant.ZERO); |
|||
} |
|||
|
|||
list.add(gridData); |
|||
}); |
|||
} |
|||
return list; |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,23 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.customize.IcResiCategoryStatsConfigDao"> |
|||
|
|||
<select id="queryDataColumn" parameterType="java.lang.String" resultType="com.epmet.dto.customize.IcResiCategoryConfigDTO"> |
|||
SELECT |
|||
m.COLUMN_NAME as columnName, |
|||
c.id as configId, |
|||
m.LABEL as itemLabel |
|||
FROM |
|||
ic_form_item m |
|||
INNER JOIN ic_resi_category_stats_config c ON ( m.CUSTOMER_ID = c.CUSTOMER_ID AND m.COLUMN_NAME = c.COLUMN_NAME AND c.DEL_FLAG = '0' ) |
|||
WHERE |
|||
m.DEL_FLAG = '0' |
|||
AND m.DATA_ANALYSE = '1' |
|||
AND m.CUSTOMER_ID = #{customerId} |
|||
ORDER BY |
|||
m.SORT ASC |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
@ -0,0 +1,13 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.stats.FactIcuserCategoryAnalysisDailyDao"> |
|||
|
|||
<delete id="limitDelete" parameterType="map"> |
|||
delete from fact_icuser_category_analysis_daily |
|||
where CUSTOMER_ID = #{customerId} |
|||
and date_id=#{dateId} |
|||
and org_type=#{orgType} |
|||
limit 1000 |
|||
</delete> |
|||
</mapper> |
@ -0,0 +1,31 @@ |
|||
package com.epmet.task; |
|||
|
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.extract.form.ExtractOriginFormDTO; |
|||
import com.epmet.feign.DataStatisticalOpenFeignClient; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* desc:数字社区私有化部署 任务之一还有【autoEvaluateDemandTask,statsDemandTask,dailyStatisticalVoteTask】 |
|||
*/ |
|||
@Slf4j |
|||
@Component("icPrivateDeploySupportTask") |
|||
public class IcPrivateDeploySupportTask implements ITask { |
|||
@Autowired |
|||
private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; |
|||
|
|||
@Override |
|||
public void run(String params) { |
|||
ExtractOriginFormDTO formDTO = new ExtractOriginFormDTO(); |
|||
if (StringUtils.isNotBlank(params)) { |
|||
formDTO = JSON.parseObject(params, ExtractOriginFormDTO.class); |
|||
} |
|||
Result result = dataStatisticalOpenFeignClient.userPointAndProjectStatus(formDTO); |
|||
log.info("IcPrivateDeploySupportTask excute end,param:{},result:{}",params,result); |
|||
} |
|||
} |
@ -0,0 +1,96 @@ |
|||
|
|||
ALTER TABLE `ic_resi_user` |
|||
ADD COLUMN `STATUS` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '用户状态【0:正常 1:转出】' AFTER `JTXX_REMAKES`; |
|||
|
|||
ALTER TABLE `ic_resi_user` |
|||
DROP INDEX `customer_idcard_unique`; |
|||
|
|||
CREATE TABLE `ic_user_transfer_record` ( |
|||
`ID` varchar(64) NOT NULL COMMENT '唯一标识', |
|||
`IC_USER_ID` varchar(64) NOT NULL COMMENT '被调动人Id【ic_resi_user表id】', |
|||
`OPERATOR_ID` varchar(64) NOT NULL COMMENT '调动(工作)人员Id【customer_staff表userId】', |
|||
`IC_USER_NAME` varchar(64) NOT NULL COMMENT '被调动人名称【ic_resi_user表name】', |
|||
`OPERATOR_NAME` varchar(64) NOT NULL COMMENT '调动(工作)人员名称【customer_staff表real_name】', |
|||
`OLD_CUSTOMER_ID` varchar(64) NOT NULL COMMENT '调动前客户Id', |
|||
`NEW_CUSTOMER_ID` varchar(64) DEFAULT NULL COMMENT '调动后客户Id', |
|||
`OLD_AGENCY_ID` varchar(64) DEFAULT NULL COMMENT '调动前组织Id', |
|||
`NEW_AGENCY_ID` varchar(64) DEFAULT NULL COMMENT '调动后组织Id', |
|||
`OLD_AGENCY_NAME` varchar(64) DEFAULT NULL COMMENT '调动前组织名称', |
|||
`NEW_AGENCY_NAME` varchar(255) DEFAULT NULL COMMENT '调动后组织名称', |
|||
`OLD_GRID_ID` varchar(64) DEFAULT NULL COMMENT '调动前网格Id', |
|||
`NEW_GRID_ID` varchar(64) DEFAULT NULL COMMENT '调动后网格Id', |
|||
`OLD_GRID_NAME` varchar(255) DEFAULT NULL COMMENT '调动前网格名称', |
|||
`NEW_GRID_NAME` varchar(255) DEFAULT NULL COMMENT '调动后网格名称', |
|||
`OLD_NEIGHBOR_HOOD_ID` varchar(64) DEFAULT NULL COMMENT '调动前小区Id', |
|||
`NEW_NEIGHBOR_HOOD_ID` varchar(64) DEFAULT NULL COMMENT '调动后小区Id', |
|||
`OLD_NEIGHBOR_HOOD_NAME` varchar(255) DEFAULT NULL COMMENT '调动前小区名称', |
|||
`NEW_NEIGHBOR_HOOD_NAME` varchar(255) DEFAULT NULL COMMENT '调动后小区名称', |
|||
`OLD_BUILDING_ID` varchar(64) DEFAULT NULL COMMENT '调动前楼栋Id', |
|||
`NEW_BUILDING_ID` varchar(64) DEFAULT NULL COMMENT '调动后楼栋Id', |
|||
`OLD_BUILDING_NAME` varchar(255) DEFAULT NULL COMMENT '调动前楼栋名称', |
|||
`NEW_BUILDING_NAME` varchar(255) DEFAULT NULL COMMENT '调动后楼栋名称', |
|||
`OLD_BUILDING_UNIT_ID` varchar(64) DEFAULT NULL COMMENT '调动前单元Id', |
|||
`NEW_BUILDING_UNIT_ID` varchar(64) DEFAULT NULL COMMENT '调动后单元Id', |
|||
`OLD_BUILDING_UNIT_NAME` varchar(255) DEFAULT NULL COMMENT '调动前单元名称', |
|||
`NEW_BUILDING_UNIT_NAME` varchar(255) DEFAULT NULL COMMENT '调动后单元名称', |
|||
`OLD_HOUSE_ID` varchar(64) DEFAULT NULL COMMENT '调动前房屋Id', |
|||
`NEW_HOUSE_ID` varchar(64) DEFAULT NULL COMMENT '调动后房屋Id', |
|||
`OLD_HOUSE_NAME` varchar(255) DEFAULT NULL COMMENT '调动前房屋名称', |
|||
`NEW_HOUSE_NAME` varchar(255) DEFAULT NULL COMMENT '调动后房屋名称', |
|||
`TRANSFER_TIME` datetime NOT NULL COMMENT '调动时间', |
|||
`REMARK` varchar(512) DEFAULT NULL COMMENT '备注说明', |
|||
`DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标识', |
|||
`REVISION` int(10) NOT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', |
|||
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', |
|||
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`) USING BTREE |
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='居民调动记录表'; |
|||
|
|||
CREATE TABLE `ic_user_change_record` ( |
|||
`ID` varchar(64) NOT NULL COMMENT '唯一标识', |
|||
`IC_USER_TRANSFER_RECORD_ID` varchar(64) DEFAULT NULL COMMENT '调动表Id【只有调动记录此列才有值】', |
|||
`CUSTOMER_ID` varchar(64) DEFAULT NULL COMMENT '当前所属客户Id[迁出客户的此列没值]', |
|||
`OPERATOR_ID` varchar(64) NOT NULL COMMENT '操作人Id【customer_staff表userId】', |
|||
`IC_USER_ID` varchar(64) NOT NULL COMMENT '被操作人Id【ic_resi_user表id】', |
|||
`OPERATOR_NAME` varchar(64) NOT NULL COMMENT '操作人名称【customer_staff表real_name】', |
|||
`IC_USER_NAME` varchar(64) NOT NULL COMMENT '被操作人名称【ic_resi_user表name】', |
|||
`TYPE` varchar(64) NOT NULL COMMENT '操作类型【add:新增 category:类别 transfer:调动】', |
|||
`TYPE_NAME` varchar(64) NOT NULL COMMENT '操作类型名称【add:新增 category:类别 transfer:调动】', |
|||
`BEFORE_CHANGE_NAME` varchar(512) DEFAULT NULL COMMENT '变更前文字描述', |
|||
`AFTER_CHANGE_NAME` varchar(512) DEFAULT NULL COMMENT '变更后文字描述', |
|||
`CHANGE_TIME` datetime NOT NULL COMMENT '调整时间', |
|||
`REMARK` varchar(512) DEFAULT NULL COMMENT '备注说明', |
|||
`DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标识', |
|||
`REVISION` int(10) NOT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', |
|||
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', |
|||
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`) USING BTREE |
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='居民变更记录表'; |
|||
|
|||
CREATE TABLE `ic_user_change_detailed` ( |
|||
`ID` varchar(64) NOT NULL COMMENT '唯一标识', |
|||
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id', |
|||
`IC_USER_CHANGE_RECORD_ID` varchar(64) NOT NULL COMMENT '变更记录表主键【ic_user_change_record.id】', |
|||
`AGENCY_ID` varchar(64) NOT NULL COMMENT '组织Id', |
|||
`GRID_ID` varchar(64) NOT NULL COMMENT '网格Id', |
|||
`NEIGHBOR_HOOD_ID` varchar(64) NOT NULL COMMENT '小区Id', |
|||
`BUILDING_ID` varchar(64) NOT NULL COMMENT '楼栋Id', |
|||
`BUILDING_UNIT_ID` varchar(64) NOT NULL COMMENT '单元Id', |
|||
`HOUSE_ID` varchar(64) NOT NULL COMMENT '房屋Id', |
|||
`IC_USER_ID` varchar(64) NOT NULL COMMENT '变更人Id', |
|||
`TYPE` varchar(255) NOT NULL COMMENT '操作类型【add:新增 category:类别 in:迁入 out:迁出】', |
|||
`TYPE_NAME` varchar(255) NOT NULL COMMENT '操作类型名称【add:新增 category:类别 in:迁入 out:迁出】', |
|||
`FIELD_NAME` varchar(64) NOT NULL COMMENT '字段名【18类对应的ic_resi_user表字段名】', |
|||
`VALUE` int(3) NOT NULL COMMENT '当前类别的值', |
|||
`DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标识', |
|||
`REVISION` int(10) NOT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', |
|||
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', |
|||
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`) USING BTREE |
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='变更明细表\r\n[一条变更记录对应多条人员类别数据]'; |
Loading…
Reference in new issue