Browse Source
			
			
			
			
				
		# Conflicts: # epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenUserTotalDataDao.xmldev
				 43 changed files with 1109 additions and 155 deletions
			
			
		| @ -0,0 +1,43 @@ | |||
| /** | |||
|  * Copyright 2018 人人开源 https://www.renren.io
 | |||
|  * <p> | |||
|  * This program is free software: you can redistribute it and/or modify | |||
|  * it under the terms of the GNU General Public License as published by | |||
|  * the Free Software Foundation, either version 3 of the License, or | |||
|  * (at your option) any later version. | |||
|  * <p> | |||
|  * This program is distributed in the hope that it will be useful, | |||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | |||
|  * GNU General Public License for more details. | |||
|  * <p> | |||
|  * You should have received a copy of the GNU General Public License | |||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |||
|  */ | |||
| 
 | |||
| package com.epmet.datareport.dao.screen; | |||
| 
 | |||
| import com.epmet.commons.mybatis.dao.BaseDao; | |||
| import com.epmet.screen.dto.result.PublicPartiRankResultDTO; | |||
| import org.apache.ibatis.annotations.Mapper; | |||
| import org.apache.ibatis.annotations.Param; | |||
| 
 | |||
| import java.util.List; | |||
| 
 | |||
| /** | |||
|  * 公众参与-各类(话题|议题|项目|注册人数|参与人数)总数 | |||
|  * | |||
|  * @author generator generator@elink-cn.com | |||
|  * @since v1.0.0 2020-08-24 | |||
|  */ | |||
| @Mapper | |||
| public interface ScreenPublicPartiTotalDataDao{ | |||
|     /** | |||
|      * @Description 查询公众参与各类总数 | |||
|      * @param agencyId | |||
|      * @return | |||
|      * @author wangc | |||
|      * @date 2020.08.20 16:00 | |||
|      **/ | |||
|     List<PublicPartiRankResultDTO> selectPublicPartiTotal(@Param("agencyId") String agencyId); | |||
| } | |||
| @ -0,0 +1,29 @@ | |||
| <?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.datareport.dao.screen.ScreenPublicPartiTotalDataDao"> | |||
| 
 | |||
|     <!-- 查询公众参与各类总数 --> | |||
|     <select id="selectPublicPartiTotal" resultType="com.epmet.screen.dto.result.PublicPartiRankResultDTO"> | |||
|         SELECT | |||
|             ORG_NAME AS NAME, | |||
|             REG_USER_TOTAL AS regNum, | |||
|             JOIN_USER_TOTAL AS joinNum, | |||
|             TOPIC_TOTAL AS topicNum, | |||
|             ISSUE_TOTAL AS issueNum, | |||
|             PROJECT_TOTAL AS projectNum | |||
|         FROM | |||
|                 screen_public_parti_total_data | |||
|         WHERE | |||
|                 DEL_FLAG = '0' | |||
|                 AND PARENT_ID =  #{agencyId} | |||
|          ORDER BY | |||
|          (REG_USER_TOTAL + JOIN_USER_TOTAL + TOPIC_TOTAL + ISSUE_TOTAL + PROJECT_TOTAL) DESC, | |||
|                 REG_USER_TOTAL desc, | |||
|                 JOIN_USER_TOTAL desc, | |||
|                 TOPIC_TOTAL desc, | |||
|                 ISSUE_TOTAL desc, | |||
|                 PROJECT_TOTAL desc | |||
|     </select> | |||
| 
 | |||
| </mapper> | |||
| @ -0,0 +1,23 @@ | |||
| package com.epmet.dto.screen.form; | |||
| 
 | |||
| import lombok.Data; | |||
| 
 | |||
| import java.io.Serializable; | |||
| 
 | |||
| /** | |||
|  * desc:初始化客户指标权重参数实体类 | |||
|  * @author liujianjun | |||
|  */ | |||
| @Data | |||
| public class IndexCalculateForm implements Serializable { | |||
|     private static final long serialVersionUID = 3280392511156378209L; | |||
|     /** | |||
|      * desc:客户id | |||
|      */ | |||
|     private String customerId; | |||
| 
 | |||
|     /** | |||
|      * desc:月份id | |||
|      */ | |||
|     private String monthId; | |||
| } | |||
| @ -0,0 +1,67 @@ | |||
| package com.epmet.dto.screencoll.form; | |||
| 
 | |||
| import lombok.Data; | |||
| 
 | |||
| import java.io.Serializable; | |||
| 
 | |||
| /** | |||
|  * 18、公众参与各类总数 入参 | |||
|  * 公众参与-各类(用户|党员|党群|话题|议题|项目|注册人数|参与人数)总数 | |||
|  * @Auther: zhangyong | |||
|  * @Date: 2020-08-18 09:59 | |||
|  */ | |||
| @Data | |||
| public class PublicPartiTotalDataFormDTO implements Serializable { | |||
| 
 | |||
|     private static final long serialVersionUID = 1L; | |||
| 
 | |||
|     /** | |||
|      * 组织类别 agency:组织;网格:grid | |||
|      */ | |||
|     private String orgType; | |||
| 
 | |||
|     /** | |||
|      * 组织Id 可以为网格,机关id | |||
|      */ | |||
|     private String orgId; | |||
| 
 | |||
|     /** | |||
|      * 上级组织Id,如果是网格,传入网格所属的组织id | |||
|      */ | |||
|     private String parentId; | |||
| 
 | |||
|     /** | |||
|      * 组织名称(可以是网格名称,也可以是组织名称) | |||
|      */ | |||
|     private String orgName; | |||
| 
 | |||
|     /** | |||
|      * 话题总数 | |||
|      */ | |||
|     private Integer topicTotal; | |||
| 
 | |||
|     /** | |||
|      * 议题总数 | |||
|      */ | |||
|     private Integer issueTotal; | |||
| 
 | |||
|     /** | |||
|      * 注册人数 | |||
|      */ | |||
|     private Integer regUserTotal; | |||
| 
 | |||
|     /** | |||
|      * 项目总数 | |||
|      */ | |||
|     private Integer projectTotal; | |||
| 
 | |||
|     /** | |||
|      * 参与人数 | |||
|      */ | |||
|     private Integer joinUserTotal; | |||
| 
 | |||
|     /** | |||
|      * 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增) | |||
|      */ | |||
|     private String dataEndTime; | |||
| } | |||
| @ -0,0 +1,154 @@ | |||
| package com.epmet.controller; | |||
| 
 | |||
| import com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth; | |||
| import com.epmet.commons.extappauth.bean.ExternalAppRequestParam; | |||
| import com.epmet.commons.tools.utils.Result; | |||
| import com.epmet.dto.screen.form.IndexCalculateForm; | |||
| import com.epmet.service.screen.IndexCalculateService; | |||
| 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; | |||
| 
 | |||
| /** | |||
|  * 指标计算controller | |||
|  * | |||
|  * @author liujianjun@elink-cn.com | |||
|  * @date 2020/8/24 14:38 | |||
|  */ | |||
| @RestController | |||
| @RequestMapping("indexcalculate") | |||
| public class IndexCalculateController { | |||
| 
 | |||
|     @Autowired | |||
|     private IndexCalculateService indexCalculateService; | |||
| 
 | |||
|     /** | |||
|      * 1、党建能力-党员相关指标计算(按照月份) | |||
|      * | |||
|      * @param externalAppRequestParam | |||
|      * @param formDTO | |||
|      * @return com.epmet.commons.tools.utils.Result | |||
|      * @Author zhangyong | |||
|      * @Date 10:52 2020-08-20 | |||
|      **/ | |||
|     @ExternalAppRequestAuth | |||
|     @PostMapping("cpc") | |||
|     public Result cpcIndexCalculate(ExternalAppRequestParam externalAppRequestParam, @RequestBody IndexCalculateForm formDTO) { | |||
|         indexCalculateService.cpcIndexCalculate(formDTO); | |||
|         return new Result(); | |||
|     } | |||
| 
 | |||
|    /* *//** | |||
|      * 2、党建能力-网格相关指标上报(按照月份) | |||
|      * | |||
|      * @param externalAppRequestParam | |||
|      * @param formDTO | |||
|      * @return com.epmet.commons.tools.utils.Result | |||
|      * @Author zhangyong | |||
|      * @Date 10:52 2020-08-20 | |||
|      **//*
 | |||
|     @ExternalAppRequestAuth | |||
|     @PostMapping("gridpartyability") | |||
|     public Result gridPartyAbility(ExternalAppRequestParam externalAppRequestParam, @RequestBody List<GridPartyAbilityFormDTO> formDTO) { | |||
|         factIndexCollectService.insertGridPartyAbility(formDTO, externalAppRequestParam.getCustomerId()); | |||
|         return new Result(); | |||
|     } | |||
| 
 | |||
|     *//**
 | |||
|      * 3、党建能力-街道及社区相关指标 | |||
|      * | |||
|      * @param externalAppRequestParam | |||
|      * @param formDTO | |||
|      * @return com.epmet.commons.tools.utils.Result | |||
|      * @Author zhangyong | |||
|      * @Date 10:52 2020-08-20 | |||
|      **//*
 | |||
|     @ExternalAppRequestAuth | |||
|     @PostMapping("orgpartyability") | |||
|     public Result orgPartyAbility(ExternalAppRequestParam externalAppRequestParam, @RequestBody List<OrgPartyAbilityFormDTO> formDTO) { | |||
|         factIndexCollectService.insertOrgPartyAbility(formDTO, externalAppRequestParam.getCustomerId()); | |||
|         return new Result(); | |||
|     } | |||
| 
 | |||
|     *//**
 | |||
|      * 4、服务能力-网格相关指标 | |||
|      * | |||
|      * @param externalAppRequestParam | |||
|      * @param formDTO | |||
|      * @return com.epmet.commons.tools.utils.Result | |||
|      * @Author zhangyong | |||
|      * @Date 10:52 2020-08-20 | |||
|      **//*
 | |||
|     @ExternalAppRequestAuth | |||
|     @PostMapping("gridserviceability") | |||
|     public Result gridServiceAbility(ExternalAppRequestParam externalAppRequestParam, @RequestBody List<GridServiceAbilityFormDTO> formDTO) { | |||
|         factIndexCollectService.insertGridServiceAbility(formDTO, externalAppRequestParam.getCustomerId()); | |||
|         return new Result(); | |||
|     } | |||
| 
 | |||
|     *//**
 | |||
|      * 5、服务能力-组织(街道|社区|全区)相关指标 | |||
|      * | |||
|      * @param externalAppRequestParam | |||
|      * @param formDTO | |||
|      * @return com.epmet.commons.tools.utils.Result | |||
|      * @Author zhangyong | |||
|      * @Date 10:52 2020-08-20 | |||
|      **//*
 | |||
|     @ExternalAppRequestAuth | |||
|     @PostMapping("orgserviceability") | |||
|     public Result orgServiceAbility(ExternalAppRequestParam externalAppRequestParam, @RequestBody List<OrgServiceAbilityFormDTO> formDTO) { | |||
|         factIndexCollectService.insertOrgServiceAbility(formDTO, externalAppRequestParam.getCustomerId()); | |||
|         return new Result(); | |||
|     } | |||
| 
 | |||
|     *//**
 | |||
|      * 6、治理能力-网格相关指标 | |||
|      * | |||
|      * @param externalAppRequestParam | |||
|      * @param formDTO | |||
|      * @return com.epmet.commons.tools.utils.Result | |||
|      * @Author zhangyong | |||
|      * @Date 10:52 2020-08-20 | |||
|      **//*
 | |||
|     @ExternalAppRequestAuth | |||
|     @PostMapping("gridgovrnability") | |||
|     public Result gridGovrnAbility(ExternalAppRequestParam externalAppRequestParam, @RequestBody List<GridGovrnAbilityFormDTO> formDTO) { | |||
|         factIndexCollectService.insertGridGovrnAbility(formDTO, externalAppRequestParam.getCustomerId()); | |||
|         return new Result(); | |||
|     } | |||
| 
 | |||
|     *//**
 | |||
|      * 7、治理能力-街道及社区相关指标 | |||
|      * | |||
|      * @param externalAppRequestParam | |||
|      * @param formDTO | |||
|      * @return com.epmet.commons.tools.utils.Result | |||
|      * @Author zhangyong | |||
|      * @Date 10:52 2020-08-20 | |||
|      **//*
 | |||
|     @ExternalAppRequestAuth | |||
|     @PostMapping("orggovrnability") | |||
|     public Result orgGovrnAbility(ExternalAppRequestParam externalAppRequestParam, @RequestBody List<OrgGovrnAbilityFormDTO> formDTO) { | |||
|         factIndexCollectService.insertOrgGovrnAbility(formDTO, externalAppRequestParam.getCustomerId()); | |||
|         return new Result(); | |||
|     } | |||
| 
 | |||
|     *//**
 | |||
|      * 8、治理能力-部门相关指标 | |||
|      * | |||
|      * @param externalAppRequestParam | |||
|      * @param formDTO | |||
|      * @return com.epmet.commons.tools.utils.Result | |||
|      * @Author zhangyong | |||
|      * @Date 10:52 2020-08-20 | |||
|      **//*
 | |||
|     @ExternalAppRequestAuth | |||
|     @PostMapping("deptgovrnability") | |||
|     public Result deptGovrnAbility(ExternalAppRequestParam externalAppRequestParam, @RequestBody List<DeptGovrnAbilityFormDTO> formDTO) { | |||
|         factIndexCollectService.insertDeptGovrnAbility(formDTO, externalAppRequestParam.getCustomerId()); | |||
|         return new Result(); | |||
|     }*/ | |||
| } | |||
| @ -0,0 +1,60 @@ | |||
| /** | |||
|  * Copyright 2018 人人开源 https://www.renren.io
 | |||
|  * <p> | |||
|  * This program is free software: you can redistribute it and/or modify | |||
|  * it under the terms of the GNU General Public License as published by | |||
|  * the Free Software Foundation, either version 3 of the License, or | |||
|  * (at your option) any later version. | |||
|  * <p> | |||
|  * This program is distributed in the hope that it will be useful, | |||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | |||
|  * GNU General Public License for more details. | |||
|  * <p> | |||
|  * You should have received a copy of the GNU General Public License | |||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |||
|  */ | |||
| 
 | |||
| package com.epmet.dao.screen; | |||
| 
 | |||
| import com.epmet.commons.mybatis.dao.BaseDao; | |||
| import com.epmet.dto.screencoll.form.PublicPartiTotalDataFormDTO; | |||
| import com.epmet.entity.screen.ScreenPublicPartiTotalDataEntity; | |||
| import org.apache.ibatis.annotations.Mapper; | |||
| import org.apache.ibatis.annotations.Param; | |||
| 
 | |||
| import java.util.List; | |||
| 
 | |||
| /** | |||
|  * 公众参与-各类(话题|议题|项目|注册人数|参与人数)总数 | |||
|  * | |||
|  * @author generator generator@elink-cn.com | |||
|  * @since v1.0.0 2020-08-24 | |||
|  */ | |||
| @Mapper | |||
| public interface ScreenPublicPartiTotalDataDao extends BaseDao<ScreenPublicPartiTotalDataEntity> { | |||
| 
 | |||
|     /** | |||
|      * 18、公众参与各类总数 | |||
|      *     公众参与-各类(用户|党员|党群|话题|议题|项目|注册人数|参与人数)总数 | |||
|      *     1)  根据CUSTOMER_ID、ORG_ID进行查询,如果有数据,则先进行物理删除 | |||
|      * | |||
|      * @param customerId | |||
|      * @param orgIds  组织Id集合 | |||
|      * @Author zhangyong | |||
|      * @Date 10:52 2020-08-25 | |||
|      **/ | |||
|     void deletePublicPartiTotalData(@Param("customerId") String customerId, | |||
|                            @Param("orgIds") String[] orgIds); | |||
| 
 | |||
|     /** | |||
|      * 18、公众参与各类总数 | |||
|      *    2) 在批量新增 | |||
|      * | |||
|      * @param list | |||
|      * @param customerId | |||
|      * @Author zhangyong | |||
|      * @Date 10:52 2020-08-25 | |||
|      **/ | |||
|     void batchInsertPublicPartiTotalData(@Param("list") List<PublicPartiTotalDataFormDTO> list, @Param("customerId")String customerId); | |||
| } | |||
| @ -0,0 +1,96 @@ | |||
| /** | |||
|  * Copyright 2018 人人开源 https://www.renren.io
 | |||
|  * <p> | |||
|  * This program is free software: you can redistribute it and/or modify | |||
|  * it under the terms of the GNU General Public License as published by | |||
|  * the Free Software Foundation, either version 3 of the License, or | |||
|  * (at your option) any later version. | |||
|  * <p> | |||
|  * This program is distributed in the hope that it will be useful, | |||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | |||
|  * GNU General Public License for more details. | |||
|  * <p> | |||
|  * You should have received a copy of the GNU General Public License | |||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |||
|  */ | |||
| 
 | |||
| package com.epmet.entity.screen; | |||
| 
 | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| 
 | |||
| import com.epmet.commons.mybatis.entity.BaseEpmetEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| 
 | |||
| import java.util.Date; | |||
| 
 | |||
| /** | |||
|  * 公众参与-各类(话题|议题|项目|注册人数|参与人数)总数 | |||
|  * | |||
|  * @author generator generator@elink-cn.com | |||
|  * @since v1.0.0 2020-08-24 | |||
|  */ | |||
| @Data | |||
| @EqualsAndHashCode(callSuper=false) | |||
| @TableName("screen_public_parti_total_data") | |||
| public class ScreenPublicPartiTotalDataEntity extends BaseEpmetEntity { | |||
| 
 | |||
| 	private static final long serialVersionUID = 1L; | |||
| 
 | |||
|     /** | |||
|      * 客户Id | |||
|      */ | |||
| 	private String customerId; | |||
| 
 | |||
|     /** | |||
|      * 组织类别 agency:组织;网格:grid;部门:department; | |||
|      */ | |||
| 	private String orgType; | |||
| 
 | |||
|     /** | |||
|      * 组织Id 可以为网格,机关id | |||
|      */ | |||
| 	private String orgId; | |||
| 
 | |||
|     /** | |||
|      * 上级组织Id,如果是网格,传入网格所属组织id | |||
|      */ | |||
| 	private String parentId; | |||
| 
 | |||
|     /** | |||
|      * 组织名称,也可能是网格名称 | |||
|      */ | |||
| 	private String orgName; | |||
| 
 | |||
|     /** | |||
|      * 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增) | |||
|      */ | |||
| 	private String dataEndTime; | |||
| 
 | |||
|     /** | |||
|      * 话题总数 | |||
|      */ | |||
| 	private Integer topicTotal; | |||
| 
 | |||
|     /** | |||
|      * 议题总数 | |||
|      */ | |||
| 	private Integer issueTotal; | |||
| 
 | |||
|     /** | |||
|      * 项目总数 | |||
|      */ | |||
| 	private Integer projectTotal; | |||
| 
 | |||
|     /** | |||
|      * 注册人数 | |||
|      */ | |||
| 	private Integer regUserTotal; | |||
| 
 | |||
|     /** | |||
|      * 参与人数 | |||
|      */ | |||
| 	private Integer joinUserTotal; | |||
| 
 | |||
| } | |||
| @ -0,0 +1,17 @@ | |||
| package com.epmet.service.screen; | |||
| 
 | |||
| import com.epmet.dto.screen.form.IndexCalculateForm; | |||
| 
 | |||
| /** | |||
|  * 指标计算service | |||
|  * | |||
|  * @author liujianjun@elink-cn.com | |||
|  * @date 2020/8/18 10:25 | |||
|  */ | |||
| public interface IndexCalculateService { | |||
|     /** | |||
|      * desc:计算党员相关指标 | |||
|      * @param formDTO | |||
|      */ | |||
|     void cpcIndexCalculate(IndexCalculateForm formDTO); | |||
| } | |||
| @ -0,0 +1,16 @@ | |||
| package com.epmet.service.screen.impl; | |||
| 
 | |||
| import com.epmet.dto.screen.form.IndexCalculateForm; | |||
| import com.epmet.service.screen.IndexCalculateService; | |||
| import org.springframework.stereotype.Service; | |||
| 
 | |||
| /** | |||
|  * @author liujianjun | |||
|  */ | |||
| @Service | |||
| public class IndexCalculateServiceImpl implements IndexCalculateService { | |||
|     @Override | |||
|     public void cpcIndexCalculate(IndexCalculateForm formDTO) { | |||
| 
 | |||
|     } | |||
| } | |||
| @ -0,0 +1,17 @@ | |||
| package com.epmet.support.normalizing; | |||
| 
 | |||
| /** | |||
|  * 指标正负相关枚举 | |||
|  */ | |||
| public enum Correlation { | |||
|     POSITIVE("positive","正相关"), | |||
|     NEGATIVE("negative","负相关"), | |||
|     ; | |||
| 
 | |||
|     private String code; | |||
|     private String desc; | |||
|     Correlation(String code,String desc){ | |||
|         this.code = code; | |||
|         this.desc = desc; | |||
|     } | |||
| } | |||
| @ -0,0 +1,52 @@ | |||
| package com.epmet.support.normalizing; | |||
| 
 | |||
| import java.math.BigDecimal; | |||
| import java.util.List; | |||
| 
 | |||
| /** | |||
|  * Double的分值计算 | |||
|  * 每一种数据类型的计算都要继承ScoreCalculator并且实现其抽象方法,实现数据类型的转换 | |||
|  */ | |||
| public class DoubleScoreCalculator extends ScoreCalculator { | |||
| 
 | |||
|     /** | |||
|      * 初始化double类型分值计算 | |||
|      * ☆☆☆ 务必在该构造方法最后调用父类的prepare()方法 ☆☆☆ | |||
|      * @param sourceArray 数据所在的数组 | |||
|      * @param minScore 分值区间的左边界 | |||
|      * @param maxScore 分值区间的右边界 | |||
|      * @param correlation 相关性 | |||
|      */ | |||
|     public DoubleScoreCalculator(Double[] sourceArray, BigDecimal minScore, BigDecimal maxScore, Correlation correlation) { | |||
|         this.sourceArrary = sourceArray.clone(); | |||
|         this.minScore = minScore; | |||
|         this.maxScore = maxScore; | |||
|         this.correlation = correlation; | |||
|         this.prepare(); | |||
|     } | |||
| 
 | |||
|     public DoubleScoreCalculator(List<Double> sourceArray, BigDecimal minScore, BigDecimal maxScore, Correlation correlation) { | |||
|         this.sourceArrary = sourceArray.toArray(); | |||
|         this.minScore = minScore; | |||
|         this.maxScore = maxScore; | |||
|         this.correlation = correlation; | |||
|         this.prepare(); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public BigDecimal getMaxFromSourceArray() { | |||
|         Double[] doubleSourceArrary = (Double[]) this.sourceArrary; | |||
|         return new BigDecimal(doubleSourceArrary[doubleSourceArrary.length - 1]); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public BigDecimal getMinFromSourceArray() { | |||
|         Double[] intSourceArrary = (Double[]) this.sourceArrary; | |||
|         return new BigDecimal(intSourceArrary[0]); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public BigDecimal convertValue2BigDecimal(Object sourceValue) { | |||
|         return new BigDecimal((Double) sourceValue); | |||
|     } | |||
| } | |||
| @ -0,0 +1,55 @@ | |||
| package com.epmet.support.normalizing; | |||
| 
 | |||
| import java.math.BigDecimal; | |||
| import java.util.List; | |||
| 
 | |||
| /** | |||
|  * Integer的分值计算 | |||
|  * 每一种数据类型的计算都要继承ScoreCalculator并且实现其抽象方法,实现数据类型的转换 | |||
|  */ | |||
| public class IntegerScoreCalculator extends ScoreCalculator { | |||
| 
 | |||
|     /** | |||
|      * 初始化整数分值计算 | |||
|      * ☆☆☆ 务必在该构造方法最后调用父类的prepare()方法 ☆☆☆ | |||
|      * @param sourceArray 数据所在的数组 | |||
|      * @param minScore 分值区间的左边界 | |||
|      * @param maxScore 分值区间的右边界 | |||
|      * @param correlation 相关性 | |||
|      */ | |||
|     public IntegerScoreCalculator(Integer[] sourceArray, BigDecimal minScore, BigDecimal maxScore, Correlation correlation) { | |||
|         this.sourceArrary = sourceArray.clone(); | |||
|         this.minScore = minScore; | |||
|         this.maxScore = maxScore; | |||
|         this.correlation = correlation; | |||
|         this.prepare(); | |||
|         System.out.println("最小值:"+minScore+";最大值:"+maxScore); | |||
| 
 | |||
|     } | |||
| 
 | |||
|     public IntegerScoreCalculator(List<Integer> sourceList, BigDecimal minScore, BigDecimal maxScore, Correlation correlation) { | |||
|         this.sourceArrary = sourceList.toArray(); | |||
|         this.minScore = minScore; | |||
|         this.maxScore = maxScore; | |||
|         this.correlation = correlation; | |||
|         this.prepare(); | |||
|         System.out.println("最小值:"+minScore+";最大值:"+maxScore); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public BigDecimal getMaxFromSourceArray() { | |||
|         Integer[] intSourceArrary = (Integer[]) this.sourceArrary; | |||
|         return new BigDecimal(intSourceArrary[intSourceArrary.length - 1]); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public BigDecimal getMinFromSourceArray() { | |||
|         Integer[] intSourceArrary = (Integer[]) this.sourceArrary; | |||
|         return new BigDecimal(intSourceArrary[0]); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public BigDecimal convertValue2BigDecimal(Object sourceValue) { | |||
|         return new BigDecimal((Integer) sourceValue); | |||
|     } | |||
| } | |||
| @ -0,0 +1,178 @@ | |||
| package com.epmet.support.normalizing; | |||
| 
 | |||
| import java.math.BigDecimal; | |||
| import java.math.MathContext; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| 
 | |||
| /** | |||
|  * 所有数据类型计算器的父类,实现算法骨架,数据类型转换方法则由子类实现 | |||
|  * ☆☆☆ 如果需要保持传入的数组元素顺序不变,请在实现类的构造方法中将传入数组进行克隆 ☆☆☆ | |||
|  * @param <T> 数据类型泛型 | |||
|  */ | |||
| public abstract class ScoreCalculator<T> { | |||
| 
 | |||
|     protected T[] sourceArrary; | |||
| 
 | |||
|     protected BigDecimal minScore; | |||
|     protected BigDecimal maxScore; | |||
| 
 | |||
|     protected Correlation correlation; | |||
| 
 | |||
|     private BigDecimal maxValue; | |||
|     private BigDecimal minValue; | |||
|     private BigDecimal coefficient; | |||
| 
 | |||
|     /** | |||
|      * 计算准备 | |||
|      */ | |||
|     protected void prepare() { | |||
|         // 校验数组
 | |||
|         if (!validSourceArray(sourceArrary)) { | |||
|             throw new RuntimeException("入参数组错误:请设置非空数组"); | |||
|         } | |||
|         Arrays.sort(sourceArrary); | |||
|         maxValue = getMaxFromSourceArray(); | |||
|         minValue = getMinFromSourceArray(); | |||
|         //计算系数
 | |||
|         System.out.println("最小值:"+minScore+";最大值:"+maxScore); | |||
|         coefficient = getCoefficient(minValue, maxValue); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 单值归一算法 | |||
|      * @return | |||
|      */ | |||
|     public BigDecimal normalize(T sourceValue) { | |||
| 
 | |||
|         if (sourceValue == null) { | |||
|             throw new RuntimeException("入参数组错误:请设置sourceValue"); | |||
|         } | |||
| 
 | |||
|         if (!Arrays.asList(sourceArrary).contains(sourceValue)) { | |||
|             throw new RuntimeException("请确认要计算的数组在数组中存在"); | |||
|         } | |||
| 
 | |||
|         if (correlation == Correlation.POSITIVE) { | |||
|             // 正相关
 | |||
|             BigDecimal x = coefficient.multiply(convertValue2BigDecimal(sourceValue).subtract(minValue)); | |||
|             BigDecimal score = minScore.add(x, MathContext.DECIMAL32); | |||
|             return score; | |||
|         } else if (correlation == Correlation.NEGATIVE) { | |||
|             // 负相关
 | |||
|             BigDecimal x = coefficient.multiply(convertValue2BigDecimal(sourceValue).subtract(minValue)); | |||
|             BigDecimal score = minScore.add(x); | |||
|             return maxScore.subtract(score, MathContext.DECIMAL32); | |||
|         } else { | |||
|             throw new RuntimeException("错误的相关性"); | |||
|         } | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 单值归一算法,带权重 | |||
|      * @param sourceValue | |||
|      * @param weight | |||
|      * @return | |||
|      */ | |||
|     public BigDecimal normalize(T sourceValue, BigDecimal weight) { | |||
|         return normalize(sourceValue).multiply(weight); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 批量归一算法 | |||
|      * @param sourceValues | |||
|      * @return | |||
|      */ | |||
|     public BigDecimal[] normalize(T[] sourceValues) { | |||
| 
 | |||
|         BigDecimal[] scores = new BigDecimal[sourceValues.length]; | |||
| 
 | |||
|         for (int i=0;i<sourceValues.length;i++) { | |||
|             BigDecimal score = normalize(sourceValues[i]); | |||
|             scores[i] = score; | |||
|         } | |||
|         return scores; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 批量归一算法,返回List | |||
|      * @param sourceValues | |||
|      * @return | |||
|      */ | |||
|     public List<BigDecimal> normalize(List<T> sourceValues) { | |||
|         return sourceValues.stream().map(s -> normalize(s)).collect(Collectors.toList()); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 批量归一算法,带权重 | |||
|      * @param sourceValues | |||
|      * @param weight | |||
|      * @return | |||
|      */ | |||
|     public BigDecimal[] normalize(T[] sourceValues, BigDecimal weight) { | |||
| 
 | |||
|         BigDecimal[] scores = new BigDecimal[sourceValues.length]; | |||
| 
 | |||
|         for (int i=0;i<sourceValues.length;i++) { | |||
|             BigDecimal score = normalize(sourceValues[i]); | |||
|             scores[i] = score.multiply(weight); | |||
|         } | |||
|         return scores; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 批量归一算法,返回List | |||
|      * @param sourceValues | |||
|      * @return | |||
|      */ | |||
|     public List<BigDecimal> normalize(List<T> sourceValues, BigDecimal weight) { | |||
|         return sourceValues.stream().map(s -> normalize(s).multiply(weight)).collect(Collectors.toList()); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 校验数组 | |||
|      * @param sourceArray | |||
|      * @param <T> | |||
|      * @return | |||
|      */ | |||
|     protected  <T> boolean validSourceArray(T[] sourceArray) { | |||
|         if (sourceArray == null || sourceArray.length == 0) { | |||
|             return false; | |||
|         } | |||
|         return true; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 计算系数 | |||
|      * @return | |||
|      */ | |||
|     protected BigDecimal getCoefficient(BigDecimal min, BigDecimal max) { | |||
|         BigDecimal fenmu = max.subtract(min); | |||
|         if (fenmu.toString().equals("0"))return new BigDecimal(0); | |||
|         BigDecimal fenzi = maxScore.subtract(minScore); | |||
|         BigDecimal divide = fenzi.divide(fenmu, MathContext.DECIMAL32); | |||
|         System.out.println("分子:"+fenzi+"分母:"+fenmu+"系数:"+divide.toString()); | |||
|         return divide; | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 从源数组中获取最大值 | |||
|      * @return | |||
|      */ | |||
|     protected abstract BigDecimal getMaxFromSourceArray(); | |||
| 
 | |||
|     /** | |||
|      * 从源数组中获取最小值 | |||
|      * @return | |||
|      */ | |||
|     protected abstract BigDecimal getMinFromSourceArray(); | |||
| 
 | |||
|     /** | |||
|      * 将值转化为BigDecimal | |||
|      * @param sourceValue | |||
|      * @return | |||
|      */ | |||
|     protected abstract BigDecimal convertValue2BigDecimal(T sourceValue); | |||
| 
 | |||
| } | |||
| @ -0,0 +1,84 @@ | |||
| <?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.screen.ScreenPublicPartiTotalDataDao"> | |||
| 
 | |||
|     <resultMap type="com.epmet.entity.screen.ScreenPublicPartiTotalDataEntity" id="screenPublicPartiTotalDataMap"> | |||
|         <result property="id" column="ID"/> | |||
|         <result property="customerId" column="CUSTOMER_ID"/> | |||
|         <result property="orgType" column="ORG_TYPE"/> | |||
|         <result property="orgId" column="ORG_ID"/> | |||
|         <result property="parentId" column="PARENT_ID"/> | |||
|         <result property="orgName" column="ORG_NAME"/> | |||
|         <result property="dataEndTime" column="DATA_END_TIME"/> | |||
|         <result property="topicTotal" column="TOPIC_TOTAL"/> | |||
|         <result property="issueTotal" column="ISSUE_TOTAL"/> | |||
|         <result property="projectTotal" column="PROJECT_TOTAL"/> | |||
|         <result property="regUserTotal" column="REG_USER_TOTAL"/> | |||
|         <result property="joinUserTotal" column="JOIN_USER_TOTAL"/> | |||
|         <result property="delFlag" column="DEL_FLAG"/> | |||
|         <result property="revision" column="REVISION"/> | |||
|         <result property="createdBy" column="CREATED_BY"/> | |||
|         <result property="createdTime" column="CREATED_TIME"/> | |||
|         <result property="updatedBy" column="UPDATED_BY"/> | |||
|         <result property="updatedTime" column="UPDATED_TIME"/> | |||
|     </resultMap> | |||
| 
 | |||
|     <delete id="deletePublicPartiTotalData"> | |||
|         delete from screen_public_parti_total_data | |||
|         where CUSTOMER_ID = #{customerId} | |||
|         AND ORG_ID IN | |||
|         <foreach item="item" collection="orgIds" open="(" separator="," close=")"> | |||
|             #{item} | |||
|         </foreach> | |||
|     </delete> | |||
| 
 | |||
|     <insert id="batchInsertPublicPartiTotalData" parameterType="map"> | |||
|         insert into screen_public_parti_total_data | |||
|         ( | |||
|         ID, | |||
|         CUSTOMER_ID, | |||
|         ORG_TYPE, | |||
|         ORG_ID, | |||
|         PARENT_ID, | |||
|         ORG_NAME, | |||
|         DATA_END_TIME, | |||
|         TOPIC_TOTAL, | |||
|         ISSUE_TOTAL, | |||
|         PROJECT_TOTAL, | |||
|         REG_USER_TOTAL, | |||
|         JOIN_USER_TOTAL, | |||
|         DEL_FLAG, | |||
|         REVISION, | |||
|         CREATED_BY, | |||
|         CREATED_TIME, | |||
|         UPDATED_BY, | |||
|         UPDATED_TIME | |||
|         ) values | |||
|         <foreach collection="list" item="item" index="index" separator=","> | |||
|             ( | |||
|             (SELECT REPLACE(UUID(), '-', '') AS id), | |||
|             #{customerId}, | |||
|             #{item.orgType}, | |||
|             #{item.orgId}, | |||
|             #{item.parentId}, | |||
|             #{item.orgName}, | |||
|             #{item.dataEndTime}, | |||
|             #{item.topicTotal}, | |||
|             #{item.issueTotal}, | |||
|             #{item.projectTotal}, | |||
|             #{item.regUserTotal}, | |||
| 
 | |||
|             #{item.joinUserTotal}, | |||
|             0, | |||
|             0, | |||
|             'APP_USER', | |||
|             now(), | |||
|             'APP_USER', | |||
|             now() | |||
|             ) | |||
|         </foreach> | |||
|     </insert> | |||
| 
 | |||
| 
 | |||
| </mapper> | |||
					Loading…
					
					
				
		Reference in new issue