Browse Source

修改客户权重信息

master
yinzuomei 5 years ago
parent
commit
5e5592f2fd
  1. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexDictController.java
  2. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/IndexGroupDetailDao.java
  3. 27
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java
  4. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/IndexGroupDetailService.java
  5. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/IndexGroupDetailServiceImpl.java
  6. 9
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDetailDao.xml

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

@ -8,10 +8,7 @@ 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.evaluationindex.screen.IndexDictService;
import com.epmet.service.evaluationindex.screen.IndexGroupDetailTemplateService;
import com.epmet.service.evaluationindex.screen.IndexGroupService;
import com.epmet.service.evaluationindex.screen.IndexGroupTemplateService;
import com.epmet.service.evaluationindex.screen.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -37,7 +34,8 @@ public class IndexDictController {
private IndexGroupService indexGroupService;
@Autowired
private IndexGroupDetailTemplateService indexGroupDetailTemplateService;
@Autowired
private IndexGroupDetailService indexGroupDetailService;
/**
* urlhttp://localhost:8108/data/stats/indexdict/initFromExcel
* desc:从excel初始化指标分组权重
@ -46,7 +44,7 @@ public class IndexDictController {
* @return
*/
@PostMapping("initFromExcel")
public Result<String> testTx(@RequestPart("file") MultipartFile file) {
public Result<String> testTx(@RequestPart("file") MultipartFile file,@RequestParam("customerId") String customerId) {
ExcelReader excelReader = null;
try {
InputStream inputStream = null;
@ -58,7 +56,9 @@ public class IndexDictController {
excelReader = EasyExcel.read(inputStream).build();
// 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
ReadSheet readSheet = EasyExcel.readSheet(1).head(IndexModel.class)
.registerReadListener(new IndexExcelDataListener(indexDictService, indexGroupTemplateService, indexGroupDetailTemplateService))
.registerReadListener(new IndexExcelDataListener(indexDictService, indexGroupTemplateService, indexGroupDetailTemplateService,
customerId,
indexGroupDetailService))
.build();
excelReader.read(readSheet);
} finally {

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

@ -22,6 +22,7 @@ import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
/**
@ -47,4 +48,6 @@ public interface IndexGroupDetailDao extends BaseDao<IndexGroupDetailEntity> {
* @return
*/
List<IndexGroupDetailEntity> selectSelfSubIndex(@Param("customerId") String customerId, @Param("allIndexCodePath") String allIndexCodePath);
int updateWeight(@Param("indexCode") String indexCode, @Param("customerId") String customerId, @Param("weight") BigDecimal weight);
}

27
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java

@ -9,6 +9,7 @@ import com.epmet.entity.evaluationindex.screen.IndexDictEntity;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailTemplateEntity;
import com.epmet.entity.evaluationindex.screen.IndexGroupTemplateEntity;
import com.epmet.service.evaluationindex.screen.IndexDictService;
import com.epmet.service.evaluationindex.screen.IndexGroupDetailService;
import com.epmet.service.evaluationindex.screen.IndexGroupDetailTemplateService;
import com.epmet.service.evaluationindex.screen.IndexGroupTemplateService;
import com.epmet.support.normalizing.Correlation;
@ -51,16 +52,25 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
private IndexGroupDetailTemplateService indexGroupDetailTemplateService;
private IndexGroupDetailService indexGroupDetailService;
/**
* 客户id不为空时需要修改index_group_detail
*/
private String customerId;
/**
* 如果使用了spring,请使用这个构造方法每次创建Listener的时候需要把spring管理的类传进来
*
* @param indexDictService
*/
public IndexExcelDataListener(IndexDictService indexDictService, IndexGroupTemplateService indexGroupTemplateService, IndexGroupDetailTemplateService indexGroupDetailTemplateService) {
public IndexExcelDataListener(IndexDictService indexDictService, IndexGroupTemplateService indexGroupTemplateService, IndexGroupDetailTemplateService indexGroupDetailTemplateService,
String customerId,
IndexGroupDetailService indexGroupDetailService) {
this.indexDictService = indexDictService;
this.indexGroupTemplateService = indexGroupTemplateService;
this.indexGroupDetailTemplateService = indexGroupDetailTemplateService;
this.customerId=customerId;
this.indexGroupDetailService=indexGroupDetailService;
}
/**
@ -329,10 +339,16 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
saveData();
if(StringUtils.isNotBlank(customerId)){
//修改客户权重信息
updateCustomerGroupDetail();
}else{
saveData();
}
LOGGER.info("所有数据解析完成!total:{}", total.intValue());
}
/**
* 加上存储数据库
*/
@ -346,4 +362,11 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
indexGroupDetailTemplateService.deleteAndInsertBatch(indexGroupDetailMap.values());
LOGGER.info("存储数据库成功!指标:{}个,分组:{}个,详情:{}个", indexDicMap.values().size(), indexGroupMap.values().size(), indexGroupDetailMap.values().size());
}
/**
* 修改客户权重信息
*/
private void updateCustomerGroupDetail() {
indexGroupDetailService.updateCustomerIndexGroupDetail(indexGroupDetailMap.values(),customerId);
}
}

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/IndexGroupDetailService.java

@ -19,8 +19,10 @@ package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailTemplateEntity;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
/**
@ -46,4 +48,14 @@ public interface IndexGroupDetailService extends BaseService<IndexGroupDetailEnt
* @param allPathIndexCode
*/
BigDecimal getWeightByAllPathIndexCode(String customerId, String allPathIndexCode);
/**
* @return void
* @param values
* @param customerId
* @author yinzuomei
* @description 修改客户权重信息
* @Date 2020/10/14 13:40
**/
void updateCustomerIndexGroupDetail(Collection<IndexGroupDetailTemplateEntity> values, String customerId);
}

19
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/IndexGroupDetailServiceImpl.java

@ -25,6 +25,7 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.evaluationindex.screen.IndexGroupDetailDao;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailTemplateEntity;
import com.epmet.redis.IndexCalRedis;
import com.epmet.service.evaluationindex.screen.IndexGroupDetailService;
import lombok.extern.slf4j.Slf4j;
@ -33,6 +34,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -79,4 +81,21 @@ public class IndexGroupDetailServiceImpl extends BaseServiceImpl<IndexGroupDetai
return weight == null ? new BigDecimal(NumConstant.ONE_NEG) : weight;
}
/**
* @param values
* @param customerId
* @return void
* @author yinzuomei
* @description 修改客户权重信息
* @Date 2020/10/14 13:40
**/
@Override
public void updateCustomerIndexGroupDetail(Collection<IndexGroupDetailTemplateEntity> values, String customerId) {
int updatedNum=0;
for(IndexGroupDetailTemplateEntity entity:values){
updatedNum+=baseDao.updateWeight(entity.getIndexCode(),customerId,entity.getWeight());
}
log.info("修改客户权重信息,影响行数="+updatedNum);
}
}

9
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDetailDao.xml

@ -31,4 +31,13 @@
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and STATUS = 'enable' and DEL_FLAG = '0'
and ALL_PARENT_INDEX_CODE like concat(#{allIndexCodePath,jdbcType=VARCHAR},'%')
</select>
<update id="updateWeight" parameterType="map">
UPDATE index_group_detail
SET WEIGHT =#{weight}
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND INDEX_CODE = #{indexCode}
</update>
</mapper>
Loading…
Cancel
Save