Browse Source

1.新增客户,部门,按月维度的初始化

dev_shibei_match
wxz 5 years ago
parent
commit
ea5522a652
  1. 37
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java
  2. 1
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java
  3. 2
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/DimDateDTO.java
  4. 14
      epmet-module/data-statistical/data-statistical-server/pom.xml
  5. 34
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java
  6. 46
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java
  7. 41
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java
  8. 91
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/crm/CustomerEntity.java
  9. 63
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerDepartmentEntity.java
  10. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimDateEntity.java
  11. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsDimService.java
  12. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java
  13. 25
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java
  14. 72
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java
  15. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java
  16. 31
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java
  17. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java
  18. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java
  19. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimMonthService.java
  20. 32
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java
  21. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDateServiceImpl.java
  22. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDepartmentServiceImpl.java
  23. 67
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimMonthServiceImpl.java
  24. 5
      epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
  25. 44
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml
  26. 19
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml

37
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);
}
}

1
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";
}

2
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;
}

14
epmet-module/data-statistical/data-statistical-server/pom.xml

@ -129,6 +129,12 @@
<datasource.druid.voice.username>epmet_gov_voice_user</datasource.druid.voice.username>
<datasource.druid.voice.password>EpmEt-db-UsEr</datasource.druid.voice.password>
<datasource.druid.voice.url>
<![CDATA[jdbc:mysql://192.168.1.130:3306/epmet_oper_crm?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.voice.url>
<datasource.druid.voice.username>epmet_oper_crm_user</datasource.druid.voice.username>
<datasource.druid.voice.password>EpmEt-db-UsEr</datasource.druid.voice.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
<spring.redis.host>192.168.1.130</spring.redis.host>
@ -191,7 +197,13 @@
<![CDATA[jdbc:mysql://192.168.1.130:3306/epmet_gov_voice?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.voice.url>
<datasource.druid.voice.username>epmet</datasource.druid.voice.username>
<datasource.druid.voice.password>elink@833066</datasource.druid.voice.password>
<datasource.druid.voice.password>elink@8473066</datasource.druid.voice.password>
<datasource.druid.crm.url>
<![CDATA[jdbc:mysql://192.168.1.130:3306/epmet_oper_crm?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.crm.url>
<datasource.druid.crm.username>epmet</datasource.druid.crm.username>
<datasource.druid.crm.password>elink@8473066</datasource.druid.crm.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>

34
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();
}
}

46
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
* <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.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<CustomerEntity> {
/**
* 根据创建时间起止查询有效客户列表
* @param createTimeFrom
* @param createTimeTo
* @return
*/
List<CustomerEntity> listValidCustomersByCreateTime(
@Param("createTimeFrom") Date createTimeFrom,
@Param("createTimeTo") Date createTimeTo);
}

41
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
* <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.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<CustomerDepartmentEntity> {
List<CustomerDepartmentEntity> listDepartmentsByCreatedTime(
@Param("createdTimeFrom") Date createdTimeFrom,
@Param("createdTimeTo") Date createdTimeTo);
}

91
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
* <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.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;
}

63
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
* <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.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;
/**
* 所属组织机构IDcustomer_agency.id
*/
private String agencyId;
/**
* 部门名称
*/
private String departmentName;
/**
* 部门职责
*/
private String departmentDuty;
/**
* 总人数
*/
private Integer totalUser;
}

2
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;
}

4
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();
}

12
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<CustomerEntity> listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo);
}

25
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<CustomerEntity> listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo) {
return customerDao.listValidCustomersByCreateTime(createTimeFrom, createTimeTo);
}
}

72
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<CustomerAgencyEntity> 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<CustomerEntity> 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<CustomerDepartmentEntity> departments = departmentService.listDepartmentsByCreatedTime(statsStartTime, statsEndTime);
dimDepartmentService.addDepartmentDims(departments);
lastExecRecord.setExecTime(new Date());
// 记录最后一次统计时间
lastExecRecordService.updateById(lastExecRecord);
}
}

11
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<CustomerDepartmentEntity> listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo);
}

31
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<CustomerDepartmentEntity> listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo) {
return departmentDao.listDepartmentsByCreatedTime(createdTimeFrom, createdTimeTo);
}
}

8
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<DimCustomerEntity> {
* email:liujianjun@git.elinkit.com.cn
*/
List<String> selectCustomerIdPage(Integer pageNo, Integer pageSize);
/**
* 添加客户维度
* @param customers
*/
void addCustomerDims(List<CustomerEntity> customers);
}

3
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<DimDepartmentEntity> {
* @date 2020-06-16
*/
void delete(String[] ids);
void addDepartmentDims(List<CustomerDepartmentEntity> departments);
}

2
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<DimMonthEntity> {
* @date 2020-06-16
*/
void delete(String[] ids);
void initMonthDim();
}

32
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<DimCustomerDao, DimC
return ConvertUtils.sourceToTarget(entityList, DimCustomerDTO.class);
}
private QueryWrapper<DimCustomerEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<DimCustomerEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<DimCustomerEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -102,11 +105,28 @@ public class DimCustomerServiceImpl extends BaseServiceImpl<DimCustomerDao, DimC
@Override
public List<String> 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<CustomerEntity> 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);
}
}
}

5
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<DimDateDao, DimDateEntit
public DimDateEntity generateDimDate(Date targetDate) {
Date now = new Date();
// 日期字符串
// 日期id
String id = DateUtils.format(targetDate, DateUtils.DATE_PATTERN_YYYYMMDD);
// 月份id
String monthId = DateUtils.format(targetDate, DateUtils.DATE_PATTERN_YYYYMM);
// 日期名称字符串
String dateNameStr = DateUtils.format(targetDate, DateUtils.DATE_NAME_PATTERN);
// 星期几
@ -164,6 +166,7 @@ public class DimDateServiceImpl extends BaseServiceImpl<DimDateDao, DimDateEntit
dimDateEntity.setDayOfWeek(englishWeekName);
dimDateEntity.setDayOfWeekName(chineseWeekName);
dimDateEntity.setWeekId(weekId);
dimDateEntity.setMonthId(monthId);
dimDateEntity.setDelFlag("0");
dimDateEntity.setCreatedBy("APP_USER");
dimDateEntity.setCreatedTime(now);

20
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDepartmentServiceImpl.java

@ -25,6 +25,7 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.stats.DimDepartmentDao;
import com.epmet.dto.stats.DimDepartmentDTO;
import com.epmet.entity.org.CustomerDepartmentEntity;
import com.epmet.entity.stats.DimDepartmentEntity;
import com.epmet.service.stats.DimDepartmentService;
import org.apache.commons.lang3.StringUtils;
@ -33,6 +34,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;
@ -97,4 +99,22 @@ public class DimDepartmentServiceImpl extends BaseServiceImpl<DimDepartmentDao,
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Transactional(rollbackFor = Exception.class)
@Override
public void addDepartmentDims(List<CustomerDepartmentEntity> 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);
}
}
}

67
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<DimMonthDao, DimMonthEntity> implements DimMonthService {
@Autowired
private LastExecRecordService lastExecRecordService;
@Override
public PageData<DimMonthDTO> page(Map<String, Object> params) {
IPage<DimMonthEntity> page = baseDao.selectPage(
@ -97,4 +106,62 @@ public class DimMonthServiceImpl extends BaseServiceImpl<DimMonthDao, DimMonthEn
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Transactional
@Override
public void initMonthDim() {
LastExecRecordEntity lastExecRecord = lastExecRecordService.getLastExecRecord(StatsSubject.DIM_MONTH);
if (lastExecRecord == null) {
lastExecRecord = lastExecRecordService.createLastExecRecord(StatsSubject.DIM_DEPARTMENT);
}
Date now = new Date();
String startTime;
String endTime = DateUtils.format(now, DateUtils.DATE_PATTERN_YYYYMM);
if (lastExecRecord.getExecTime() == null) {
Date targetDate = new LocalDate(now).minusMonths(1).toDate();
initMonthDim(DateUtils.format(targetDate, DateUtils.DATE_PATTERN_YYYYMM));
} else {
startTime = DateUtils.format(lastExecRecord.getExecTime(), DateUtils.DATE_PATTERN_YYYYMM);
initMonthDims(startTime, endTime);
}
lastExecRecord.setExecTime(new Date());
// 记录最后一次统计时间
lastExecRecordService.updateById(lastExecRecord);
}
public void initMonthDims(String startMonthStr, String endMonthStr) {
Integer startMonthInt = Integer.valueOf(startMonthStr);
Integer endMonthInt = Integer.valueOf(endMonthStr);
while(startMonthInt < endMonthInt) {
initMonthDim(startMonthInt + "");
++ startMonthInt;
}
}
public void initMonthDim(String startMonthStr) {
Date now = new Date();
Date startDate = DateUtils.stringToDate( startMonthStr, DateUtils.DATE_PATTERN_YYYYMM);
Date endDate = DateUtils.addDateDays(DateUtils.addDateMonths(startDate, 1), -1);
LocalDate localDate = new LocalDate(startDate);
DimMonthEntity dim = new DimMonthEntity();
dim.setStartDate(startDate);
dim.setEndDate(endDate);
dim.setMonthName(DateUtils.format(startDate, DateUtils.MONTH_NAME_PATTERN));
dim.setMonthOrder(DateUtils.getMonthOfYear(startDate));
dim.setQuarterId(localDate.getYear() + "Q" + DateUtils.getQuarterIndex(startDate));
dim.setYearId(localDate.getYear() + "");
dim.setCreatedBy("APP_USER");
dim.setUpdatedBy("APP_USER");
dim.setCreatedTime(now);
dim.setUpdatedTime(now);
dim.setDelFlag("0");
dim.setId(DateUtils.format(startDate, DateUtils.DATE_PATTERN_YYYYMM));
baseDao.insert(dim);
}
}

5
epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml

@ -140,6 +140,11 @@ dynamic:
url: @datasource.druid.voice.url@
username: @datasource.druid.voice.username@
password: @datasource.druid.voice.password@
operCrm:
driver-class-name: com.mysql.cj.jdbc.Driver
url: @datasource.druid.crm.url@
username: @datasource.druid.crm.username@
password: @datasource.druid.crm.password@
thread:
# 线程池配置

44
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml

@ -0,0 +1,44 @@
<?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.crm.CustomerDao">
<resultMap type="com.epmet.entity.crm.CustomerEntity" id="customerMap">
<result property="id" column="ID"/>
<result property="customerName" column="CUSTOMER_NAME"/>
<result property="title" column="TITLE"/>
<result property="organizationNumber" column="ORGANIZATION_NUMBER"/>
<result property="organizationImg" column="ORGANIZATION_IMG"/>
<result property="validityTime" column="VALIDITY_TIME"/>
<result property="customerAdmin" column="CUSTOMER_ADMIN"/>
<result property="customerPassword" column="CUSTOMER_PASSWORD"/>
<result property="organizationLevel" column="ORGANIZATION_LEVEL"/>
<result property="logo" column="LOGO"/>
<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>
<!--根据创建时间起止查询有效客户列表-->
<select id="listValidCustomersByCreateTime" resultType="com.epmet.entity.crm.CustomerEntity">
SELECT c.*
FROM
customer c
<where>
c.DEL_FLAG = '0'
AND c.VALIDITY_TIME > NOW()
<if test="createTimeFrom != null">
AND c.CREATED_TIME >= #{createTimeFrom}
</if>
<if test="createTimeTo != null">
AND c.CREATED_TIME &lt; #{createTimeTo}
</if>
</where>
ORDER BY
CONVERT ( c.CUSTOMER_NAME USING gbk ) ASC
</select>
</mapper>

19
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml

@ -0,0 +1,19 @@
<?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.org.CustomerDepartmentDao">
<select id="listDepartmentsByCreatedTime" resultType="com.epmet.entity.org.CustomerDepartmentEntity">
SELECT *
FROM customer_department
<where>
DEL_FLAG = 0
<if test="createdTimeFrom != null">
AND CREATED_TIME >= #{createdTimeFrom}
</if>
<if test="createdTimeTo != null">
AND CREATED_TIME &lt; #{createdTimeTo}
</if>
</where>
</select>
</mapper>
Loading…
Cancel
Save