diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java index a83670615d..2887ed1adf 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java @@ -26,6 +26,7 @@ import java.util.Date; * @since 1.0.0 */ public class DateUtils { + /** 时间格式(yyyy-MM-dd) */ public final static String DATE_PATTERN = "yyyy-MM-dd"; /** 时间格式(yyyy-MM-dd HH:mm:ss) */ @@ -37,7 +38,9 @@ public class DateUtils { public static final String DATE_PATTERN_YYYYMMDD = "yyyyMMdd"; public static final String DATE_NAME_PATTERN = "yyyy年MM月dd日"; + public static final String MONTH_NAME_PATTERN = "yyyy年MM月"; public static final String DATE_PATTERN_YYYY = "yyyy"; + public static final String DATE_PATTERN_YYYYMM = "yyyyMM"; public static final String WEEK_TYPE_ENGLISH = "english"; public static final String WEEK_TYPE_CHINESE = "chinese"; @@ -244,11 +247,41 @@ public class DateUtils { return DateUtils.parse(DateUtils.format(targetDate, pattern), pattern); } + /** + * 查询指定日期是几月 + * @param date + * @return + */ + public static int getMonthOfYear(Date date) { + LocalDate localDate = new LocalDate(date); + return localDate.getMonthOfYear(); + } + + /** + * 获取季度 + * @param date + * @return + */ + public static int getQuarterIndex(Date date) { + LocalDate localDate = new LocalDate(date); + int monthOfYear = localDate.getMonthOfYear(); + if (monthOfYear == 1 || monthOfYear == 2 || monthOfYear == 3) { + return 1; + } + if (monthOfYear == 4 || monthOfYear == 5 || monthOfYear == 6) { + return 2; + } + if (monthOfYear == 7 || monthOfYear == 8 || monthOfYear == 9) { + return 3; + } + return 4; + } + public static void main(String[] args) { //int weekOfYear = getWeekOfYear(new Date()); - String e = DateUtils.format(new Date(), "E"); + int quarterIndex = DateUtils.getQuarterIndex(DateUtils.parse("20201001", DateUtils.DATE_PATTERN_YYYYMMDD)); - System.out.println(e); + System.out.println(666); } } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java index 47a18e3a72..f79ab899cf 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java @@ -7,5 +7,6 @@ public interface DataSourceConstant { String GOV_ISSUE = "govIssue"; String GOV_PROJECT = "govProject"; String GOV_VOICE = "govVoice"; + String OPER_CRM = "operCrm"; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/DimDateDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/DimDateDTO.java index 75c3bf51f8..e539cda274 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/DimDateDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/DimDateDTO.java @@ -88,4 +88,6 @@ public class DimDateDTO implements Serializable { */ private Date updatedTime; + private String monthId; + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index a68e4b48d3..dcd55b9ad9 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -129,6 +129,12 @@ epmet_gov_voice_user EpmEt-db-UsEr + + + + epmet_oper_crm_user + EpmEt-db-UsEr + 0 192.168.1.130 @@ -191,7 +197,13 @@ epmet - elink@833066 + elink@8473066 + + + + + epmet + elink@8473066 0 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java index d9439f5b67..c393a74bb3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java @@ -3,6 +3,7 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.service.StatsDimService; import com.epmet.service.stats.DimDateService; +import com.epmet.service.stats.DimMonthService; import oracle.jdbc.proxy.annotation.Post; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -16,6 +17,9 @@ public class DimController { @Autowired private DimDateService dimDateService; + @Autowired + private DimMonthService dimMonthService; + @Autowired private StatsDimService statsDimService; @@ -49,4 +53,34 @@ public class DimController { return new Result(); } + /** + * 客户维度 + * @return + */ + @PostMapping("/customer/init") + public Result intiCustomerDim() { + statsDimService.initCustomerDim(); + return new Result(); + } + + /** + * 部门维度 + * @return + */ + @PostMapping("/department/init") + public Result intiDepartmentDim() { + statsDimService.initDepartmentDim(); + return new Result(); + } + + /** + * 月维度 + * @return + */ + @PostMapping("/month/init") + public Result initMonthDim() { + dimMonthService.initMonthDim(); + return new Result(); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java new file mode 100644 index 0000000000..bfe699c25e --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java @@ -0,0 +1,46 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao.crm; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.crm.CustomerEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +/** + * 客户表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-11 + */ +@Mapper +public interface CustomerDao extends BaseDao { + + /** + * 根据创建时间起止查询有效客户列表 + * @param createTimeFrom + * @param createTimeTo + * @return + */ + List listValidCustomersByCreateTime( + @Param("createTimeFrom") Date createTimeFrom, + @Param("createTimeTo") Date createTimeTo); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java new file mode 100644 index 0000000000..2b9b4705ab --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java @@ -0,0 +1,41 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao.org; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.org.CustomerDepartmentEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +/** + * 客户部门表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-20 + */ +@Mapper +public interface CustomerDepartmentDao extends BaseDao { + + List listDepartmentsByCreatedTime( + @Param("createdTimeFrom") Date createdTimeFrom, + @Param("createdTimeTo") Date createdTimeTo); + +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/crm/CustomerEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/crm/CustomerEntity.java new file mode 100644 index 0000000000..a2fa408a43 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/crm/CustomerEntity.java @@ -0,0 +1,91 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity.crm; + +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-03-11 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("customer") +public class CustomerEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户名称 + */ + private String customerName; + + /** + * 产品标题 显示在产品顶端的标题 + */ + private String title; + + /** + * 组织机构代码 + */ + private String organizationNumber; + + /** + * 组织机构代码证图片 + */ + private String organizationImg; + + /** + * 有效期 + */ + private Date validityTime; + + /** + * 客户管理员 + */ + private String customerAdmin; + + /** + * 密码 加密存储 + */ + private String customerPassword; + + /** + * 客户组织级别:机关级别 + * (社区级:community, + * 乡(镇、街道)级:street, + * 区县级: district, + * 市级: city + * 省级:province) 机关级别(社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province) + */ + private String organizationLevel; + + /** + * 客户logo + */ + private String logo; + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerDepartmentEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerDepartmentEntity.java new file mode 100644 index 0000000000..0f46e25ffd --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerDepartmentEntity.java @@ -0,0 +1,63 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity.org; + +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 2020-04-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("customer_department") +public class CustomerDepartmentEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 所属组织机构ID(customer_agency.id) + */ + private String agencyId; + + /** + * 部门名称 + */ + private String departmentName; + + /** + * 部门职责 + */ + private String departmentDuty; + + /** + * 总人数 + */ + private Integer totalUser; + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimDateEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimDateEntity.java index 8b919277a1..8048c15070 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimDateEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimDateEntity.java @@ -58,4 +58,6 @@ public class DimDateEntity extends BaseEpmetEntity { */ private String weekId; + private String monthId; + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsDimService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsDimService.java index 8e99082086..b566f3d160 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsDimService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsDimService.java @@ -5,4 +5,8 @@ public interface StatsDimService { void initGridDim(); void initAgencyDim(); + + void initCustomerDim(); + + void initDepartmentDim(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java new file mode 100644 index 0000000000..e562a08365 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java @@ -0,0 +1,12 @@ +package com.epmet.service.crm; + +import com.epmet.entity.crm.CustomerEntity; + +import java.util.Date; +import java.util.List; + +public interface CustomerService { + + List listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo); + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java new file mode 100644 index 0000000000..3db2f197bd --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java @@ -0,0 +1,25 @@ +package com.epmet.service.crm.impl; + +import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.constant.DataSourceConstant; +import com.epmet.dao.crm.CustomerDao; +import com.epmet.entity.crm.CustomerEntity; +import com.epmet.service.crm.CustomerService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +@Service +@DataSource(DataSourceConstant.OPER_CRM) +public class CustomerServiceImpl implements CustomerService { + + @Autowired + private CustomerDao customerDao; + + @Override + public List listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo) { + return customerDao.listValidCustomersByCreateTime(createTimeFrom, createTimeTo); + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java index b919440cbe..c4666ba77b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java @@ -2,17 +2,20 @@ package com.epmet.service.impl; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.StatsSubject; +import com.epmet.dao.org.CustomerDepartmentDao; import com.epmet.dao.stats.LastExecRecordDao; +import com.epmet.entity.crm.CustomerEntity; import com.epmet.entity.org.CustomerAgencyEntity; +import com.epmet.entity.org.CustomerDepartmentEntity; import com.epmet.entity.org.CustomerGridEntity; import com.epmet.entity.stats.DimGridEntity; import com.epmet.entity.stats.LastExecRecordEntity; import com.epmet.service.StatsDimService; +import com.epmet.service.crm.CustomerService; import com.epmet.service.org.CustomerAgencyService; +import com.epmet.service.org.CustomerDepartmentService; import com.epmet.service.org.CustomerGridService; -import com.epmet.service.stats.DimAgencyService; -import com.epmet.service.stats.DimGridService; -import com.epmet.service.stats.LastExecRecordService; +import com.epmet.service.stats.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -38,6 +41,18 @@ public class StatsDimServiceImpl implements StatsDimService { @Autowired private CustomerAgencyService customerAgencyService; + @Autowired + private CustomerService customerService; + + @Autowired + private DimCustomerService dimCustomerService; + + @Autowired + private CustomerDepartmentService departmentService; + + @Autowired + private DimDepartmentService dimDepartmentService; + @Override public void initGridDim() { DimGridEntity lastCreatedGridDim = dimGridService.getLastCreatedGridDim(); @@ -101,6 +116,57 @@ public class StatsDimServiceImpl implements StatsDimService { List agencies = customerAgencyService.listAgenciesByCreateTime(statsStartTime, statsEndTime); dimAgencyService.addAgencyDims(agencies); lastExecRecord.setExecTime(new Date()); + + // 记录最后一次统计时间 lastExecRecordService.updateById(lastExecRecord); } + + /** + * 初始化网格维度 + */ + @Override + public void initCustomerDim() { + LastExecRecordEntity lastExecRecord = lastExecRecordService.getLastExecRecord(StatsSubject.DIM_CUSTOMER); + if (lastExecRecord == null) { + lastExecRecord = lastExecRecordService.createLastExecRecord(StatsSubject.DIM_CUSTOMER); + } + + Date statsEndTime = DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN_YYYYMMDD); + Date statsStartTime = null; + if (lastExecRecord.getExecTime() != null) { + statsStartTime = DateUtils.integrate(lastExecRecord.getExecTime(), DateUtils.DATE_PATTERN_YYYYMMDD); + } + + List customers = customerService.listValidCustomersByCreateTime(statsStartTime, statsEndTime); + dimCustomerService.addCustomerDims(customers); + + lastExecRecord.setExecTime(new Date()); + + // 记录最后一次统计时间 + lastExecRecordService.updateById(lastExecRecord); + } + + @Override + public void initDepartmentDim() { + LastExecRecordEntity lastExecRecord = lastExecRecordService.getLastExecRecord(StatsSubject.DIM_DEPARTMENT); + if (lastExecRecord == null) { + lastExecRecord = lastExecRecordService.createLastExecRecord(StatsSubject.DIM_DEPARTMENT); + } + + Date statsEndTime = DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN_YYYYMMDD); + Date statsStartTime = null; + if (lastExecRecord.getExecTime() != null) { + statsStartTime = DateUtils.integrate(lastExecRecord.getExecTime(), DateUtils.DATE_PATTERN_YYYYMMDD); + } + + List departments = departmentService.listDepartmentsByCreatedTime(statsStartTime, statsEndTime); + + dimDepartmentService.addDepartmentDims(departments); + + lastExecRecord.setExecTime(new Date()); + + // 记录最后一次统计时间 + lastExecRecordService.updateById(lastExecRecord); + + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java new file mode 100644 index 0000000000..1aa2c2f7db --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java @@ -0,0 +1,11 @@ +package com.epmet.service.org; + +import com.epmet.entity.org.CustomerDepartmentEntity; + +import java.util.Date; +import java.util.List; + +public interface CustomerDepartmentService { + + List listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java new file mode 100644 index 0000000000..ac430a3abd --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java @@ -0,0 +1,31 @@ +package com.epmet.service.org.impl; + +import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.constant.DataSourceConstant; +import com.epmet.dao.org.CustomerDepartmentDao; +import com.epmet.entity.org.CustomerDepartmentEntity; +import com.epmet.service.org.CustomerDepartmentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +@Service +@DataSource(DataSourceConstant.GOV_ORG) +public class CustomerDepartmentServiceImpl implements CustomerDepartmentService { + + @Autowired + private CustomerDepartmentDao departmentDao; + + /** + * 根据创建时间查询部门列表 + * @param createdTimeFrom + * @param createdTimeTo + * @return + */ + @Override + public List listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo) { + return departmentDao.listDepartmentsByCreatedTime(createdTimeFrom, createdTimeTo); + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java index 96eabb77ce..85e7c06202 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java @@ -20,6 +20,8 @@ package com.epmet.service.stats; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.stats.DimCustomerDTO; +import com.epmet.entity.crm.CustomerEntity; +import com.epmet.entity.org.CustomerDepartmentEntity; import com.epmet.entity.stats.DimCustomerEntity; import java.util.List; @@ -104,4 +106,10 @@ public interface DimCustomerService extends BaseService { * email:liujianjun@git.elinkit.com.cn */ List selectCustomerIdPage(Integer pageNo, Integer pageSize); + + /** + * 添加客户维度 + * @param customers + */ + void addCustomerDims(List customers); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java index ffb1601678..0055e81fb5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java @@ -20,6 +20,7 @@ package com.epmet.service.stats; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.stats.DimDepartmentDTO; +import com.epmet.entity.org.CustomerDepartmentEntity; import com.epmet.entity.stats.DimDepartmentEntity; import java.util.List; @@ -92,4 +93,6 @@ public interface DimDepartmentService extends BaseService { * @date 2020-06-16 */ void delete(String[] ids); + + void addDepartmentDims(List departments); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimMonthService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimMonthService.java index 160625db05..d6f8a75943 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimMonthService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimMonthService.java @@ -92,4 +92,6 @@ public interface DimMonthService extends BaseService { * @date 2020-06-16 */ void delete(String[] ids); + + void initMonthDim(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java index 1b8bf1e474..87ab6d789d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java @@ -27,6 +27,8 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.stats.DimCustomerDao; import com.epmet.dto.stats.DimCustomerDTO; +import com.epmet.entity.crm.CustomerEntity; +import com.epmet.entity.org.CustomerDepartmentEntity; import com.epmet.entity.stats.DimCustomerEntity; import com.epmet.service.stats.DimCustomerService; import lombok.extern.slf4j.Slf4j; @@ -35,6 +37,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; +import java.util.Date; import java.util.List; import java.util.Map; @@ -64,8 +67,8 @@ public class DimCustomerServiceImpl extends BaseServiceImpl getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); @@ -102,11 +105,28 @@ public class DimCustomerServiceImpl extends BaseServiceImpl selectCustomerIdPage(Integer pageNo, Integer pageSize) { - if (pageNo ==null || pageNo <1 || pageSize == null || pageSize < 0){ - log.error("selectCustomerIdPage param error,pageNo:{},pageSize:{}",pageNo,pageSize); - throw new RenException(EpmetErrorCode.CUSTOMER_VALIDATE_ERROR.getCode(),EpmetErrorCode.CUSTOMER_VALIDATE_ERROR.getMsg()); + if (pageNo == null || pageNo < 1 || pageSize == null || pageSize < 0) { + log.error("selectCustomerIdPage param error,pageNo:{},pageSize:{}", pageNo, pageSize); + throw new RenException(EpmetErrorCode.CUSTOMER_VALIDATE_ERROR.getCode(), EpmetErrorCode.CUSTOMER_VALIDATE_ERROR.getMsg()); } - return baseDao.selectCustomerIdPage(pageNo,(pageNo-1)*pageSize); + return baseDao.selectCustomerIdPage(pageNo, (pageNo - 1) * pageSize); } + @Transactional + @Override + public void addCustomerDims(List customers) { + Date now = new Date(); + for (CustomerEntity customer : customers) { + DimCustomerEntity dim = new DimCustomerEntity(); + dim.setCustomerName(customer.getCustomerName()); + dim.setCreatedBy("APP_USER"); + dim.setCreatedTime(now); + dim.setUpdatedBy("APP_USER"); + dim.setUpdatedTime(now); + dim.setDelFlag("0"); + dim.setRevision(0); + dim.setId(customer.getId()); + baseDao.insert(dim); + } + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDateServiceImpl.java index 5c3fdb96aa..0d0d756c12 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDateServiceImpl.java @@ -148,8 +148,10 @@ public class DimDateServiceImpl extends BaseServiceImpl departments) { + Date now = new Date(); + for (CustomerDepartmentEntity department : departments) { + DimDepartmentEntity dim = new DimDepartmentEntity(); + dim.setAgencyId(department.getAgencyId()); + dim.setCustomerId(department.getCustomerId()); + dim.setDepartmentName(department.getDepartmentName()); + dim.setCreatedBy("APP_USER"); + dim.setUpdatedBy("APP_USER"); + dim.setCreatedTime(now); + dim.setUpdatedTime(now); + dim.setRevision(0); + dim.setDelFlag("0"); + baseDao.insert(dim); + } + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimMonthServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimMonthServiceImpl.java index b495b76284..39db16d77f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimMonthServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimMonthServiceImpl.java @@ -23,16 +23,22 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constant.StatsSubject; import com.epmet.dao.stats.DimMonthDao; import com.epmet.dto.stats.DimMonthDTO; import com.epmet.entity.stats.DimMonthEntity; +import com.epmet.entity.stats.LastExecRecordEntity; import com.epmet.service.stats.DimMonthService; +import com.epmet.service.stats.LastExecRecordService; import org.apache.commons.lang3.StringUtils; +import org.joda.time.LocalDate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; +import java.util.Date; import java.util.List; import java.util.Map; @@ -45,6 +51,9 @@ import java.util.Map; @Service public class DimMonthServiceImpl extends BaseServiceImpl implements DimMonthService { + @Autowired + private LastExecRecordService lastExecRecordService; + @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -97,4 +106,62 @@ public class DimMonthServiceImpl extends BaseServiceImpl + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml new file mode 100644 index 0000000000..6d3bc43ce3 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file