- * 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.
- *
- * 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.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;
-
-}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailDTO.java
deleted file mode 100644
index e6335250eb..0000000000
--- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailDTO.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * 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.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;
-
-}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailTemplateDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailTemplateDTO.java
deleted file mode 100644
index e82b7b4588..0000000000
--- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailTemplateDTO.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * 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.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;
-
-}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/InitCustomerIndexForm.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/InitCustomerIndexForm.java
new file mode 100644
index 0000000000..4016a9656e
--- /dev/null
+++ b/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;
+}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java
index 3b93ce39a3..21b5ea51b7 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java
+++ b/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!");
}
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexDictController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexDictController.java
index 217867ea32..0d0b21befc 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexDictController.java
+++ b/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 initCustomerIndex(@RequestBody InitCustomerIndexForm formDTO){
+ if (StringUtils.isBlank(formDTO.getCustomerId())){
+ throw new RenException("参数错误");
+ }
+ Boolean aBoolean = indexGroupService.initCustomerIndexGroup(formDTO.getCustomerId());
+ return new Result().ok(aBoolean);
}
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java
index 10033b7456..5458720940 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java
+++ b/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 {
-
+
+ int inertGroupFromTable(String customerId);
}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailTemplateDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailTemplateDao.java
index cfe5270615..29f074c13f 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailTemplateDao.java
+++ b/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 {
int deleteAll();
+
+ List selectAll();
}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupTemplateDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupTemplateDao.java
index 6f64a61349..c1e14b531c 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupTemplateDao.java
+++ b/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 {
int deleteAll();
+
+ List selectAll();
}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailEntity.java
index e17ba9b2b2..c0088d5383 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailEntity.java
+++ b/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
*/
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupService.java
index f2ee989bea..88c66b3da6 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupService.java
+++ b/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 {
+ Boolean initCustomerIndexGroup(String customerId);
}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupServiceImpl.java
index 5d12ec33d1..65fc39f131 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupServiceImpl.java
+++ b/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 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 groupTempList = indexGroupTemplateDao.selectAll();
+ List groupDetailTempList = indexGroupDetailTemplateDao.selectAll();
+ if (CollectionUtils.isEmpty(groupTempList) || CollectionUtils.isEmpty(groupDetailTempList)){
+ throw new RenException("没有需要初始化的数据");
+ }
+ List 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 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;
+ }
}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDao.xml
index 06f0cf0198..4597456ae7 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDao.xml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDao.xml
@@ -3,5 +3,7 @@
-
+
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml
index ddb138771e..c044654dd8 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml
@@ -6,4 +6,9 @@
delete from index_group_detail_template
+
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupTemplateDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupTemplateDao.xml
index d527876c4d..6adfa4474b 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupTemplateDao.xml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupTemplateDao.xml
@@ -5,4 +5,9 @@
delete from index_group_template
+
+
\ No newline at end of file