Browse Source

初始化客户指标

master
jianjun 5 years ago
parent
commit
8c2d50b4e6
  1. 97
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexDictDTO.java
  2. 92
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDTO.java
  3. 92
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailDTO.java
  4. 92
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailTemplateDTO.java
  5. 18
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/InitCustomerIndexForm.java
  6. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java
  7. 27
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexDictController.java
  8. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java
  9. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailTemplateDao.java
  10. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupTemplateDao.java
  11. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailEntity.java
  12. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupService.java
  13. 49
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupServiceImpl.java
  14. 4
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDao.xml
  15. 5
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml
  16. 5
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupTemplateDao.xml

97
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexDictDTO.java

@ -1,97 +0,0 @@
/**
* 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.dto.screen;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 评价指标字典
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-19
*/
@Data
public class IndexDictDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
private String id;
/**
* 指标编码(唯一)
*/
private String indexCode;
/**
* 指标名
*/
private String indexName;
/**
* 指标描述
*/
private String indexDesc;
/**
* 父级指标id如果是一级指标PID=0
*/
private String pid;
/**
* 指标级别1,2,3,4,5
*/
private String level;
/**
* 删除标识 0.未删除 1.已删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

92
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDTO.java

@ -1,92 +0,0 @@
/**
* 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.dto.screen;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 客户指标分组
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-19
*/
@Data
public class IndexGroupDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
private String id;
/**
* 客户id
*/
private String customerId;
/**
* 指标id
*/
private String indexCode;
/**
* 是否启用启用enable 禁用disabled
*/
private String status;
/**
* 当前指标关联的上一级指标分组如果没有上一级则为0
*/
private String parentIndexGroupId;
/**
* 删除标识 0.未删除 1.已删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

92
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailDTO.java

@ -1,92 +0,0 @@
/**
* 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.dto.screen;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* 客户指标详情
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-19
*/
@Data
public class IndexGroupDetailDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
private String id;
/**
* index_group.id
*/
private String indexGroupId;
/**
* 指标id
*/
private String indexCode;
/**
* 权重同一组权重总和=1
*/
private BigDecimal weight;
/**
* 是否启用启用enable 禁用disabled
*/
private String status;
/**
* 删除标识 0.未删除 1.已删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

92
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailTemplateDTO.java

@ -1,92 +0,0 @@
/**
* 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.dto.screen;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* 客户指标详情
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-19
*/
@Data
public class IndexGroupDetailTemplateDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
private String id;
/**
* index_group.id
*/
private String indexGroupId;
/**
* 指标id
*/
private String indexCode;
/**
* 权重同一组权重总和=1
*/
private BigDecimal weight;
/**
* 是否启用启用enable 禁用disabled
*/
private String status;
/**
* 删除标识 0.未删除 1.已删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

18
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/InitCustomerIndexForm.java

@ -0,0 +1,18 @@
package com.epmet.dto.screen.form;
import lombok.Data;
import java.io.Serializable;
/**
* desc:初始化客户指标权重参数实体类
* @author liujianjun
*/
@Data
public class InitCustomerIndexForm implements Serializable {
private static final long serialVersionUID = 3280392511156378209L;
/**
* desc:客户id
*/
private String customerId;
}

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java

@ -15,5 +15,6 @@ public class DataStatsApplication {
public static void main(String[] args) {
SpringApplication.run(DataStatsApplication.class ,args);
//HttpClientManager.getInstance().sendAlarmMsg("DataStatsApplication started!");
}
}

27
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexDictController.java

@ -3,18 +3,19 @@ package com.epmet.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.screen.form.InitCustomerIndexForm;
import com.epmet.model.IndexExcelDataListener;
import com.epmet.model.IndexModel;
import com.epmet.service.screen.IndexDictService;
import com.epmet.service.screen.IndexGroupDetailTemplateService;
import com.epmet.service.screen.IndexGroupService;
import com.epmet.service.screen.IndexGroupTemplateService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
@ -33,6 +34,8 @@ public class IndexDictController {
@Autowired
private IndexGroupTemplateService indexGroupTemplateService;
@Autowired
private IndexGroupService indexGroupService;
@Autowired
private IndexGroupDetailTemplateService indexGroupDetailTemplateService;
/**
@ -63,6 +66,20 @@ public class IndexDictController {
excelReader.finish();
}
}
return new Result<>();
return new Result<>();
}
/**
* desc 初始化客户的评价指标数据
* @param formDTO customerId
* @return
*/
@PostMapping("initCustomerIndex")
public Result<Boolean> initCustomerIndex(@RequestBody InitCustomerIndexForm formDTO){
if (StringUtils.isBlank(formDTO.getCustomerId())){
throw new RenException("参数错误");
}
Boolean aBoolean = indexGroupService.initCustomerIndexGroup(formDTO.getCustomerId());
return new Result<Boolean>().ok(aBoolean);
}
}

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java

@ -29,5 +29,6 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface IndexGroupDao extends BaseDao<IndexGroupEntity> {
int inertGroupFromTable(String customerId);
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailTemplateDao.java

@ -22,6 +22,8 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.screen.IndexGroupDetailTemplateEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 客户指标详情
*
@ -32,4 +34,6 @@ import org.apache.ibatis.annotations.Mapper;
public interface IndexGroupDetailTemplateDao extends BaseDao<IndexGroupDetailTemplateEntity> {
int deleteAll();
List<IndexGroupDetailTemplateEntity> selectAll();
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupTemplateDao.java

@ -21,6 +21,8 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.screen.IndexGroupTemplateEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 默认指标分组
*
@ -31,4 +33,6 @@ import org.apache.ibatis.annotations.Mapper;
public interface IndexGroupTemplateDao extends BaseDao<IndexGroupTemplateEntity> {
int deleteAll();
List<IndexGroupTemplateEntity> selectAll();
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailEntity.java

@ -37,6 +37,11 @@ public class IndexGroupDetailEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户id
*/
private String customerId;
/**
* index_group.id
*/

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupService.java

@ -28,4 +28,5 @@ import com.epmet.entity.screen.IndexGroupEntity;
*/
public interface IndexGroupService extends BaseService<IndexGroupEntity> {
Boolean initCustomerIndexGroup(String customerId);
}

49
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupServiceImpl.java

@ -18,10 +18,25 @@
package com.epmet.service.screen.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.UniqueIdGenerator;
import com.epmet.dao.screen.IndexGroupDao;
import com.epmet.dao.screen.IndexGroupDetailDao;
import com.epmet.dao.screen.IndexGroupDetailTemplateDao;
import com.epmet.dao.screen.IndexGroupTemplateDao;
import com.epmet.entity.screen.IndexGroupDetailEntity;
import com.epmet.entity.screen.IndexGroupDetailTemplateEntity;
import com.epmet.entity.screen.IndexGroupEntity;
import com.epmet.entity.screen.IndexGroupTemplateEntity;
import com.epmet.service.screen.IndexGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.stream.Collectors;
/**
* 客户指标分组
@ -31,5 +46,39 @@ import org.springframework.stereotype.Service;
*/
@Service
public class IndexGroupServiceImpl extends BaseServiceImpl<IndexGroupDao, IndexGroupEntity> implements IndexGroupService {
@Autowired
private IndexGroupTemplateDao indexGroupTemplateDao;
@Autowired
private IndexGroupDetailTemplateDao indexGroupDetailTemplateDao;
@Autowired
private IndexGroupDetailDao indexGroupDetailDao;
@Transactional(rollbackFor = Exception.class)
@Override
public Boolean initCustomerIndexGroup(String customerId) {
List<IndexGroupTemplateEntity> groupTempList = indexGroupTemplateDao.selectAll();
List<IndexGroupDetailTemplateEntity> groupDetailTempList = indexGroupDetailTemplateDao.selectAll();
if (CollectionUtils.isEmpty(groupTempList) || CollectionUtils.isEmpty(groupDetailTempList)){
throw new RenException("没有需要初始化的数据");
}
List<IndexGroupEntity> groupEntityList = groupTempList.stream().map(groupTemp -> {
IndexGroupEntity entity = ConvertUtils.sourceToTarget(groupTemp, IndexGroupEntity.class);
entity.setId(UniqueIdGenerator.generate());
entity.setCustomerId(customerId);
return entity;
}).collect(Collectors.toList());
this.insertBatch(groupEntityList,10);
List<IndexGroupDetailEntity> groupTempEntityList = groupDetailTempList.stream().map(groupTemp -> {
IndexGroupDetailEntity entity = ConvertUtils.sourceToTarget(groupTemp, IndexGroupDetailEntity.class);
entity.setId(UniqueIdGenerator.generate());
entity.setCustomerId(customerId);
return entity;
}).collect(Collectors.toList());
groupTempEntityList.forEach(o->{
indexGroupDetailDao.insert(o);
});
return true;
}
}

4
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDao.xml

@ -3,5 +3,7 @@
<mapper namespace="com.epmet.dao.screen.IndexGroupDao">
<!--<insert id="inertGroupFromTable">
insert into index_group_template ()
</insert>-->
</mapper>

5
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml

@ -6,4 +6,9 @@
<delete id="deleteAll">
delete from index_group_detail_template
</delete>
<select id="selectAll" resultType="com.epmet.entity.screen.IndexGroupDetailTemplateEntity">
select ID, INDEX_GROUP_ID, INDEX_ID, WEIGHT, THRESHOLD
from index_group_detail_template
where STATUS = 'enable' and DEL_FLAG = '0'
</select>
</mapper>

5
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupTemplateDao.xml

@ -5,4 +5,9 @@
<delete id="deleteAll">
delete from index_group_template
</delete>
<select id="selectAll" resultType="com.epmet.entity.screen.IndexGroupTemplateEntity">
select ID, INDEX_ID, STATUS, PARENT_INDEX_GROUP_ID FROM INDEX_GROUP_TEMPLATE
where STATUS = 'enable' and DEL_FLAG = '0'
</select>
</mapper>
Loading…
Cancel
Save