From 57888660664522e35eda80903a548170044d3f6d Mon Sep 17 00:00:00 2001 From: zhangyongzhangyong <2012005003@qq.coom> Date: Mon, 22 Mar 2021 16:40:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/screen/CategoryDictDataFormDTO.java | 27 +++++++ .../dto/screen/form/CategoryDictFormDTO.java | 72 +++++++++++++++++++ .../ScreenProjectDataCollController.java | 25 +++++-- .../stats/CustomerProjectCategoryDictDao.java | 26 ++++++- .../CustomerProjectCategoryDictService.java | 15 +++- ...ustomerProjectCategoryDictServiceImpl.java | 19 ++++- .../stats/CustomerProjectCategoryDictDao.xml | 56 ++++++++++++++- 7 files changed, 231 insertions(+), 9 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/CategoryDictDataFormDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/CategoryDictFormDTO.java diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/CategoryDictDataFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/CategoryDictDataFormDTO.java new file mode 100644 index 0000000000..bd88161f54 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/CategoryDictDataFormDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.screen; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import com.epmet.dto.screen.form.CategoryDictFormDTO; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * 项目分类字典上报 + * @Auther: zhangyong + * @Date: 2021-03-22 + */ +@Data +public class CategoryDictDataFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 当isFirst=true时,直接根据 customerId 删除原有数据,再批量insert。 + */ + private Boolean isFirst; + + private List dataList; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/CategoryDictFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/CategoryDictFormDTO.java new file mode 100644 index 0000000000..f60c33faa4 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/CategoryDictFormDTO.java @@ -0,0 +1,72 @@ +package com.epmet.dto.screen.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 项目分类字典上报 + * @Auther: zhangyong + * @Date: 2021-03-22 + */ +@Data +public class CategoryDictFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + +// public interface ExtractDailyForm extends CustomerClientShowGroup {} + + /** + * 客户内自己的分类编码 + */ +// @NotBlank(message = "客户分类编码不能为空", groups = { ExtractDailyForm.class }) + private String categoryCode; + + /** + * 客户内自己的分类名称 + */ +// @NotBlank(message = "客户分类名称不能为空", groups = { ExtractDailyForm.class }) + private String categoryName; + + /** + * 父类分类编码,如果是一级分类,此列赋值为0 + */ +// @NotBlank(message = "父类分类编码不能为空", groups = { ExtractDailyForm.class }) + private String parentCategoryCode; + + /** + * 分类等级:1、2....; + */ +// @NotBlank(message = "分类等级不能为空", groups = { ExtractDailyForm.class }) + private Integer level; + + /** + * 排序 + */ +// @NotBlank(message = "排序不能为空", groups = { ExtractDailyForm.class }) + private Integer sort; + + /** + * 当前分类对应产品内的分类编码,如果对应不上,此列传空 + */ + private String epmetCategoryCode; + + /** + * 原始创建时间yyyy-MM-dd HH:mm:ss + */ + private String originCreatedTime; + + /** + * 原始更新时间yyyy-MM-dd HH:mm:ss + */ + private String orginUpdatedTime; + + /** + * 分类字典表主键 + */ +// @NotBlank(message = "分类字典表主键不能为空", groups = { ExtractDailyForm.class }) + private String categoryId; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenProjectDataCollController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenProjectDataCollController.java index 0af70355e9..d51ca41f31 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenProjectDataCollController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenProjectDataCollController.java @@ -3,16 +3,15 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.screen.*; +import com.epmet.dto.screen.form.CategoryDictFormDTO; import com.epmet.dto.screen.form.ScreenProjectDataInfoFormDTO; import com.epmet.dto.screen.form.ScreenProjectProcessFormDTO; import com.epmet.dto.screencoll.ScreenCollFormDTO; import com.epmet.service.evaluationindex.screen.*; +import com.epmet.service.stats.CustomerProjectCategoryDictService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * @Description 事件/项目采集接口入口 @@ -41,7 +40,8 @@ public class ScreenProjectDataCollController { private ScreenProjectDataService projectDataService; @Autowired private ScreenProjectProcessService projectProcessService; - + @Autowired + private CustomerProjectCategoryDictService customerProjectCategoryDictService; /** * @author wangc * @description 【事件/项目分析】网格内月度数量统计 @@ -152,4 +152,19 @@ public class ScreenProjectDataCollController { return new Result(); } + /** + * 项目分类字典上报 + * 目标表:epmet_evaluation_index库的customer_project_category_dict + * + * @param customerId + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author zhangyong + * @Date 16:03 2021-03-22 + **/ + @PostMapping("uploadcategorydict") + public Result uploadcategorydict(@RequestHeader("CustomerId") String customerId, @RequestBody CategoryDictDataFormDTO formDTO) { + customerProjectCategoryDictService.uploadCategoryDict(customerId, formDTO); + return new Result(); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/CustomerProjectCategoryDictDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/CustomerProjectCategoryDictDao.java index fd0cdd6eb2..3489fc5917 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/CustomerProjectCategoryDictDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/CustomerProjectCategoryDictDao.java @@ -18,10 +18,13 @@ package com.epmet.dao.stats; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.screen.form.CategoryDictFormDTO; import com.epmet.entity.stats.CustomerProjectCategoryDictEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 客户项目分类字典表 * @@ -36,4 +39,25 @@ public interface CustomerProjectCategoryDictDao extends BaseDao list, @Param("customerId")String customerId); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java index 36861d7b35..1b37c9448a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java @@ -18,6 +18,7 @@ package com.epmet.service.stats; import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.dto.screen.CategoryDictDataFormDTO; import com.epmet.entity.issue.IssueProjectCategoryDictEntity; import com.epmet.entity.stats.CustomerProjectCategoryDictEntity; @@ -42,4 +43,16 @@ public interface CustomerProjectCategoryDictService extends BaseService NumConstant.ZERO); + } + if (!CollectionUtils.isEmpty(formDTO.getDataList())) { + baseDao.batchInsertCustomerProjectCategoryDict(formDTO.getDataList(), customerId); + } + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/CustomerProjectCategoryDictDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/CustomerProjectCategoryDictDao.xml index 63b47e4456..2802dc7625 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/CustomerProjectCategoryDictDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/CustomerProjectCategoryDictDao.xml @@ -38,4 +38,58 @@ and m.customer_id=#{customerId} and m.CATEGORY_ID=#{categoryId} - \ No newline at end of file + + + delete from customer_project_category_dict + where CUSTOMER_ID = #{customerId} + limit 1000; + + + + insert into customer_project_category_dict + ( + ID, + CUSTOMER_ID, + CUSTOMER_TYPE, + CATEGORY_CODE, + CATEGORY_NAME, + PARENT_CATEGORY_CODE, + `LEVEL`, + SORT, + IS_DISABLE, + EPMET_CATEGORY_CODE, + ORIGIN_CREATED_TIME, + ORIGIN_UPDATED_TIME, + CATEGORY_ID, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME + ) values + + ( + (SELECT REPLACE(UUID(), '-', '') AS id), + #{customerId}, + 'external', + #{item.categoryCode}, + #{item.categoryName}, + #{item.parentCategoryCode}, + #{item.level}, + #{item.sort}, + 'enable', + #{item.epmetCategoryCode}, + #{item.originCreatedTime}, + #{item.orginUpdatedTime}, + #{item.categoryId}, + 0, + 0, + 'APP_USER', + now(), + 'APP_USER', + now() + ) + + + From 8bbbbc2610e567508520612c9036b1d9cec19283 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 22 Mar 2021 17:06:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...V0.0.10__add_project_category_analysis.sql | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.10__add_project_category_analysis.sql diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.10__add_project_category_analysis.sql b/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.10__add_project_category_analysis.sql new file mode 100644 index 0000000000..391bb2af03 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.10__add_project_category_analysis.sql @@ -0,0 +1,47 @@ +-- epmet_data_statistical 库: +drop table if exists fact_origin_project_category_daily; +CREATE TABLE `fact_origin_project_category_daily` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `PROJECT_ID` varchar(64) NOT NULL COMMENT '项目id', + `CATEGORY_CODE` varchar(50) NOT NULL COMMENT '分类编码', + `PARENT_CATEGORY_CODE` varchar(50) NOT NULL COMMENT '所属父类分类编码', + `LEVEL` int(11) NOT NULL COMMENT '分类等级:1、2....;产品目前只有2级分类', + `DEL_FLAG` char(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除;1已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='项目所属分类表'; + +-- epmet_data_statistical_display 、epmet_evaluation_index: +drop table if exists customer_project_category_dict; +CREATE TABLE `customer_project_category_dict` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `CUSTOMER_TYPE` varchar(20) NOT NULL COMMENT '外部客户:external;内部客户:internal', + `CATEGORY_CODE` varchar(64) NOT NULL COMMENT '客户自己的分类编码', + `CATEGORY_NAME` varchar(500) CHARACTER SET utf8 NOT NULL COMMENT '客户自己的分类名称', + `PARENT_CATEGORY_CODE` varchar(64) NOT NULL COMMENT '父类分类编码,如果是一级分类,此列赋值为0', + `LEVEL` int(11) NOT NULL COMMENT '分类等级:1、2....;产品只有2级分类', + `SORT` int(11) unsigned NOT NULL COMMENT '排序', + `IS_DISABLE` varchar(32) CHARACTER SET utf8 NOT NULL COMMENT '是否禁用(enable:启用 disable:禁用)', + `EPMET_CATEGORY_CODE` varchar(64) DEFAULT NULL COMMENT '对应e世通中的分类编码,没有此列为空', + `ORIGIN_CREATED_TIME` datetime DEFAULT NULL COMMENT '原始创建时间', + `ORIGIN_UPDATED_TIME` datetime DEFAULT NULL COMMENT '原始更新时间', + `CATEGORY_ID` varchar(64) NOT NULL COMMENT '分类字典表主键', + `DEL_FLAG` char(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除;1已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE, + UNIQUE KEY `UN_KEY` (`CUSTOMER_ID`,`CATEGORY_CODE`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='客户项目分类字典表'; +-- epmet_data_statistical_display 、epmet_evaluation_index: + +alter table screen_project_category_org_daily add column `LEVEL` int(11) NOT NULL COMMENT '分类等级1、2....'; +alter table screen_project_category_grid_daily add column `LEVEL` int(11) NOT NULL COMMENT '分类等级1、2....';