58 changed files with 726 additions and 227 deletions
			
			
		@ -0,0 +1,106 @@ | 
				
			|||
package com.epmet.controller; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.constant.NumConstant; | 
				
			|||
import com.epmet.commons.tools.constant.StrConstant; | 
				
			|||
import com.epmet.commons.tools.enums.BizTypeEnum; | 
				
			|||
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.*; | 
				
			|||
 | 
				
			|||
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/{bizType}") | 
				
			|||
    public Result<String> userPointAndProjectStatus(@PathVariable("bizType") String bizType, @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 -> { | 
				
			|||
                executeMethod(bizType, formDTO.getCustomerId(), d); | 
				
			|||
                result.add(d); | 
				
			|||
                redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus-"+bizType), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L); | 
				
			|||
            }); | 
				
			|||
        } else { | 
				
			|||
            if (StringUtils.isBlank(formDTO.getDateId())){ | 
				
			|||
                formDTO.setDateId(DateUtils.getBeforeNDay(NumConstant.ONE)); | 
				
			|||
            } | 
				
			|||
            executeMethod(bizType, formDTO.getCustomerId(), formDTO.getDateId()); | 
				
			|||
            result.add(formDTO.getDateId()); | 
				
			|||
            redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus-"+bizType), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L); | 
				
			|||
        } | 
				
			|||
        long end = System.currentTimeMillis(); | 
				
			|||
        long l = (end - start) / 1000; | 
				
			|||
        return new Result<String>().ok("userPointAndProjectStatus耗时-"+bizType + l + "s"); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    private void executeMethod(String bizType, String customerId, String d) { | 
				
			|||
        if (bizType.equals(BizTypeEnum.USER.getType())){ | 
				
			|||
            this.extractUserPointData(customerId, d); | 
				
			|||
        } | 
				
			|||
        if (bizType.equals(BizTypeEnum.PROJECT.getType())) { | 
				
			|||
            this.agencyProjectStats(customerId, d); | 
				
			|||
        } | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Author sun | 
				
			|||
     * @Description 数据-项目-机关日(月)统计 | 
				
			|||
     **/ | 
				
			|||
    private void 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); | 
				
			|||
        } | 
				
			|||
        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,33 @@ | 
				
			|||
package com.epmet.task.ic; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
import com.alibaba.fastjson.JSON; | 
				
			|||
import com.epmet.commons.tools.enums.BizTypeEnum; | 
				
			|||
import com.epmet.commons.tools.utils.Result; | 
				
			|||
import com.epmet.dto.extract.form.ExtractOriginFormDTO; | 
				
			|||
import com.epmet.feign.DataStatisticalOpenFeignClient; | 
				
			|||
import com.epmet.task.ITask; | 
				
			|||
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,IcPrivateDeploySupportUserPointTask】 | 
				
			|||
 */ | 
				
			|||
@Slf4j | 
				
			|||
@Component("icPrivateDeploySupportProjectTask") | 
				
			|||
public class IcPrivateDeploySupportProjectTask 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(BizTypeEnum.PROJECT.getType(), formDTO); | 
				
			|||
        log.info("icPrivateDeploySupportProjectTask excute end,param:{},result:{}",params,result); | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,33 @@ | 
				
			|||
package com.epmet.task.ic; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
import com.alibaba.fastjson.JSON; | 
				
			|||
import com.epmet.commons.tools.enums.BizTypeEnum; | 
				
			|||
import com.epmet.commons.tools.utils.Result; | 
				
			|||
import com.epmet.dto.extract.form.ExtractOriginFormDTO; | 
				
			|||
import com.epmet.feign.DataStatisticalOpenFeignClient; | 
				
			|||
import com.epmet.task.ITask; | 
				
			|||
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,icPrivateDeploySupportProjectTask】 | 
				
			|||
 */ | 
				
			|||
@Slf4j | 
				
			|||
@Component("icPrivateDeploySupportUserPointTask") | 
				
			|||
public class IcPrivateDeploySupportUserPointTask 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(BizTypeEnum.USER.getType(), formDTO); | 
				
			|||
        log.info("icPrivateDeploySupportUserPointTask excute end,param:{},result:{}",params,result); | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,32 @@ | 
				
			|||
package com.epmet.dto.result; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * desc:客户下网格工作人员结果 | 
				
			|||
 * @Author zxc | 
				
			|||
 * @DateTime 2021/6/8 3:23 下午 | 
				
			|||
 * @DESC | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class CustomerGridStaffResultDTO implements Serializable { | 
				
			|||
 | 
				
			|||
    private static final long serialVersionUID = -5910427385795368242L; | 
				
			|||
 | 
				
			|||
    private String userId; | 
				
			|||
 | 
				
			|||
    private String userName; | 
				
			|||
 | 
				
			|||
    private String mobile; | 
				
			|||
 | 
				
			|||
    private Integer gender; | 
				
			|||
 | 
				
			|||
    private String gridId; | 
				
			|||
 | 
				
			|||
    private String gridName; | 
				
			|||
 | 
				
			|||
    private String agencyId; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,32 @@ | 
				
			|||
package com.epmet.dto.result; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author 在网格中的工作人员 | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/4/23 16:08 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class CustomerStaffGridResultDTO implements Serializable { | 
				
			|||
	private static final long serialVersionUID = 1301415104939403933L; | 
				
			|||
	/** | 
				
			|||
	 * 用户ID | 
				
			|||
	 */ | 
				
			|||
	private String userId; | 
				
			|||
	/** | 
				
			|||
	 * 网格Id | 
				
			|||
	 */ | 
				
			|||
	private String gridId; | 
				
			|||
	/** | 
				
			|||
	 * 网格名称 | 
				
			|||
	 */ | 
				
			|||
	private String gridName; | 
				
			|||
	/** | 
				
			|||
	 * 组织Id | 
				
			|||
	 */ | 
				
			|||
	private String agencyId; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,13 @@ | 
				
			|||
package com.epmet.dto.result; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
@Data | 
				
			|||
public class SubTableJoinDTO implements Serializable { | 
				
			|||
    private static final long serialVersionUID = 8243764437194993736L; | 
				
			|||
    private String tableName; | 
				
			|||
    private String joinTableSql; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,56 @@ | 
				
			|||
package com.epmet.dto.form; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.dto.form.PageFormDTO; | 
				
			|||
import com.epmet.commons.tools.validator.group.DefaultGroup; | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import javax.validation.constraints.NotBlank; | 
				
			|||
import javax.validation.constraints.NotEmpty; | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * DESC:网格下的工作人员 查询 | 
				
			|||
 * @author liujianjun | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class GridStaffFormDTO extends PageFormDTO { | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 客户Id | 
				
			|||
     */ | 
				
			|||
    @NotBlank(message = "客户Id不能为空", groups = {DefaultGroup.class}) | 
				
			|||
    private String customerId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 工作人员Id | 
				
			|||
     */ | 
				
			|||
    private String userId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 工作人员姓名 | 
				
			|||
     */ | 
				
			|||
    private String userName; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 手机号 | 
				
			|||
     */ | 
				
			|||
    private String mobile; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 角色key | 
				
			|||
     */ | 
				
			|||
    @NotEmpty(message = "角色Key不能为空", groups = {DefaultGroup.class}) | 
				
			|||
    private List<String> roleKeyList; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 组织ID | 
				
			|||
     */ | 
				
			|||
    @NotBlank(message = "组织ID不能为空", groups = {DefaultGroup.class}) | 
				
			|||
    private String orgId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 组织类型 agency or grid | 
				
			|||
     */ | 
				
			|||
    @NotBlank(message = "组织类型不能为空", groups = {DefaultGroup.class}) | 
				
			|||
    private String orgType; | 
				
			|||
} | 
				
			|||
					Loading…
					
					
				
		Reference in new issue