|
@ -17,17 +17,20 @@ |
|
|
|
|
|
|
|
|
package com.epmet.service.evaluationindex.screen.impl; |
|
|
package com.epmet.service.evaluationindex.screen.impl; |
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
import com.epmet.constant.CompareConstant; |
|
|
import com.epmet.constant.CompareConstant; |
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
import com.epmet.constant.IndexCalConstant; |
|
|
import com.epmet.constant.IndexCalConstant; |
|
|
import com.epmet.dao.evaluationindex.screen.*; |
|
|
import com.epmet.dao.evaluationindex.screen.*; |
|
|
|
|
|
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO; |
|
|
import com.epmet.dto.screencoll.form.*; |
|
|
import com.epmet.dto.screencoll.form.*; |
|
|
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; |
|
|
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenCustomerBizOrgEntity; |
|
|
import com.epmet.entity.evaluationindex.screen.ScreenEventImgDataEntity; |
|
|
import com.epmet.entity.evaluationindex.screen.ScreenEventImgDataEntity; |
|
|
import com.epmet.entity.evaluationindex.screen.ScreenUserJoinEntity; |
|
|
import com.epmet.entity.evaluationindex.screen.ScreenUserJoinEntity; |
|
|
import com.epmet.service.evaluationindex.screen.ShiBeiScreenCollService; |
|
|
import com.epmet.service.evaluationindex.screen.ShiBeiScreenCollService; |
|
@ -40,7 +43,6 @@ import org.springframework.util.CollectionUtils; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.Calendar; |
|
|
import java.util.Calendar; |
|
|
import java.util.Collection; |
|
|
|
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@ -54,9 +56,9 @@ import java.util.stream.Collectors; |
|
|
@DataSource(DataSourceConstant.EVALUATION_INDEX) |
|
|
@DataSource(DataSourceConstant.EVALUATION_INDEX) |
|
|
public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private ScreenPartyUserRankDataDao screenPartyUserRankDataDao; |
|
|
private ScreenPartyUserRankDataDao screenPartyUserRankDataDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ScreenPartyLinkMassesDataDao screenPartyLinkMassesDataDao; |
|
|
private ScreenPartyLinkMassesDataDao screenPartyLinkMassesDataDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ScreenPartyBranchDataDao screenPartyBranchDataDao; |
|
|
private ScreenPartyBranchDataDao screenPartyBranchDataDao; |
|
@ -81,6 +83,8 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ScreenCustomerAgencyDao screenCustomerAgencyDao; |
|
|
private ScreenCustomerAgencyDao screenCustomerAgencyDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
|
|
|
private ScreenCustomerBizOrgDao screenCustomerBizOrgDao; |
|
|
|
|
|
@Autowired |
|
|
private ScreenUserTotalDataDao screenUserTotalDataDao; |
|
|
private ScreenUserTotalDataDao screenUserTotalDataDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ScreenUserJoinDao screenUserJoinDao; |
|
|
private ScreenUserJoinDao screenUserJoinDao; |
|
@ -94,7 +98,7 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true) |
|
|
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true) |
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void insertPartyUserRankData(PartyUserRankDataListFormDTO formDTO,String customerId) { |
|
|
public void insertPartyUserRankData(PartyUserRankDataListFormDTO formDTO, String customerId) { |
|
|
if (formDTO.getIsFirst()) { |
|
|
if (formDTO.getIsFirst()) { |
|
|
int deleteNum; |
|
|
int deleteNum; |
|
|
do { |
|
|
do { |
|
@ -187,7 +191,7 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
if (null != formDTO.getDataList().get(i).getImgDataList() && formDTO.getDataList().get(i).getImgDataList().size() > NumConstant.ZERO) { |
|
|
if (null != formDTO.getDataList().get(i).getImgDataList() && formDTO.getDataList().get(i).getImgDataList().size() > NumConstant.ZERO) { |
|
|
// 根据原始事件ID,物理删除 - 事件数据图片数据
|
|
|
// 根据原始事件ID,物理删除 - 事件数据图片数据
|
|
|
events[i] = formDTO.getDataList().get(i).getEventId(); |
|
|
events[i] = formDTO.getDataList().get(i).getEventId(); |
|
|
for (int j = NumConstant.ZERO; j < formDTO.getDataList().get(i).getImgDataList().size(); j++){ |
|
|
for (int j = NumConstant.ZERO; j < formDTO.getDataList().get(i).getImgDataList().size(); j++) { |
|
|
// 新增 中央区-事件数据图片数据 表
|
|
|
// 新增 中央区-事件数据图片数据 表
|
|
|
ScreenEventImgDataEntity imgDataEntity = new ScreenEventImgDataEntity(); |
|
|
ScreenEventImgDataEntity imgDataEntity = new ScreenEventImgDataEntity(); |
|
|
imgDataEntity.setEventId(formDTO.getDataList().get(i).getImgDataList().get(j).getEventId()); |
|
|
imgDataEntity.setEventId(formDTO.getDataList().get(i).getImgDataList().get(j).getEventId()); |
|
@ -198,7 +202,7 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (isImgUrl){ |
|
|
if (isImgUrl) { |
|
|
screenEventImgDataDao.delEventImgDataByEvent(events); |
|
|
screenEventImgDataDao.delEventImgDataByEvent(events); |
|
|
screenEventImgDataDao.batchInsertEventImgData(eventImgDataList); |
|
|
screenEventImgDataDao.batchInsertEventImgData(eventImgDataList); |
|
|
} |
|
|
} |
|
@ -210,11 +214,11 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void insertDifficultyData(DifficultyDataFormDTO formDTO, String customerId) { |
|
|
public void insertDifficultyData(DifficultyDataFormDTO formDTO, String customerId) { |
|
|
if(formDTO.getIsFirst()){ |
|
|
if (formDTO.getIsFirst()) { |
|
|
//直接删除当前客户下所有的数据
|
|
|
//直接删除当前客户下所有的数据
|
|
|
screenDifficultyDataDao.deleteDifficultyData(customerId); |
|
|
screenDifficultyDataDao.deleteDifficultyData(customerId); |
|
|
} |
|
|
} |
|
|
if (null != formDTO && !CollectionUtils.isEmpty(formDTO.getDataList())){ |
|
|
if (null != formDTO && !CollectionUtils.isEmpty(formDTO.getDataList())) { |
|
|
screenDifficultyDataDao.batchInsertDifficultyData(formDTO.getDataList(), customerId); |
|
|
screenDifficultyDataDao.batchInsertDifficultyData(formDTO.getDataList(), customerId); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -309,9 +313,9 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
} |
|
|
} |
|
|
if (!CollectionUtils.isEmpty(formDTO.getDataList())) { |
|
|
if (!CollectionUtils.isEmpty(formDTO.getDataList())) { |
|
|
List<CustomerAgencyFormDTO> pidIsZeroList = formDTO.getDataList().stream().filter(d -> d.getPid().equals(NumConstant.ZERO_STR) || "".equals(d.getPid())).collect(Collectors.toList()); |
|
|
List<CustomerAgencyFormDTO> pidIsZeroList = formDTO.getDataList().stream().filter(d -> d.getPid().equals(NumConstant.ZERO_STR) || "".equals(d.getPid())).collect(Collectors.toList()); |
|
|
if (pidIsZeroList.size()>NumConstant.ONE){ |
|
|
if (pidIsZeroList.size() > NumConstant.ONE) { |
|
|
Object o = JSONObject.toJSON(pidIsZeroList); |
|
|
Object o = JSONObject.toJSON(pidIsZeroList); |
|
|
throw new RenException("多个pid为【0】的数据:"+o.toString()); |
|
|
throw new RenException("多个pid为【0】的数据:" + o.toString()); |
|
|
} |
|
|
} |
|
|
screenCustomerAgencyDao.batchInsertCustomerAgency(formDTO.getDataList(), customerId); |
|
|
screenCustomerAgencyDao.batchInsertCustomerAgency(formDTO.getDataList(), customerId); |
|
|
} |
|
|
} |
|
@ -343,9 +347,9 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
} while (deleteNum != NumConstant.ZERO); |
|
|
} while (deleteNum != NumConstant.ZERO); |
|
|
} |
|
|
} |
|
|
if (!CollectionUtils.isEmpty(formDTO.getDataList())) { |
|
|
if (!CollectionUtils.isEmpty(formDTO.getDataList())) { |
|
|
if (formDTO.getDataList().size() > NumConstant.ZERO){ |
|
|
if (formDTO.getDataList().size() > NumConstant.ZERO) { |
|
|
String[] orgIds = new String[formDTO.getDataList().size()]; |
|
|
String[] orgIds = new String[formDTO.getDataList().size()]; |
|
|
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++){ |
|
|
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++) { |
|
|
orgIds[i] = formDTO.getDataList().get(i).getOrgId(); |
|
|
orgIds[i] = formDTO.getDataList().get(i).getOrgId(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -360,11 +364,11 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
// 定义本月待添加数据的集合
|
|
|
// 定义本月待添加数据的集合
|
|
|
List<ScreenUserJoinEntity> curMonthJoinEntityList = new ArrayList<>(); |
|
|
List<ScreenUserJoinEntity> curMonthJoinEntityList = new ArrayList<>(); |
|
|
// 增加率计算
|
|
|
// 增加率计算
|
|
|
if (null != lastMonthJoinList && lastMonthJoinList.size() > NumConstant.ZERO){ |
|
|
if (null != lastMonthJoinList && lastMonthJoinList.size() > NumConstant.ZERO) { |
|
|
// 存在上个月的数据 (本月-上月)/上月 *100
|
|
|
// 存在上个月的数据 (本月-上月)/上月 *100
|
|
|
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++){ |
|
|
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++) { |
|
|
for (int j = NumConstant.ZERO; j < lastMonthJoinList.size(); j++){ |
|
|
for (int j = NumConstant.ZERO; j < lastMonthJoinList.size(); j++) { |
|
|
if (formDTO.getDataList().get(i).getOrgId().equals(lastMonthJoinList.get(j).getOrgId())){ |
|
|
if (formDTO.getDataList().get(i).getOrgId().equals(lastMonthJoinList.get(j).getOrgId())) { |
|
|
ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(formDTO.getDataList().get(i), ScreenUserJoinEntity.class); |
|
|
ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(formDTO.getDataList().get(i), ScreenUserJoinEntity.class); |
|
|
entity.setJoinTotalUpRate(this.calculateGrowthRateNumber(lastMonthJoinList.get(i).getJoinTotal(), formDTO.getDataList().get(j).getJoinTotal())); |
|
|
entity.setJoinTotalUpRate(this.calculateGrowthRateNumber(lastMonthJoinList.get(i).getJoinTotal(), formDTO.getDataList().get(j).getJoinTotal())); |
|
|
entity.setJoinTotalUpFlag(this.calculateGrowthRateFlag(lastMonthJoinList.get(i).getJoinTotal(), formDTO.getDataList().get(j).getJoinTotal())); |
|
|
entity.setJoinTotalUpFlag(this.calculateGrowthRateFlag(lastMonthJoinList.get(i).getJoinTotal(), formDTO.getDataList().get(j).getJoinTotal())); |
|
@ -380,8 +384,8 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
// 计算增长率后的 待新增数据
|
|
|
// 计算增长率后的 待新增数据
|
|
|
BigDecimal zero = new BigDecimal(NumConstant.ZERO); |
|
|
BigDecimal zero = new BigDecimal(NumConstant.ZERO); |
|
|
// 不存在上个月的数据
|
|
|
// 不存在上个月的数据
|
|
|
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++){ |
|
|
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++) { |
|
|
ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(formDTO.getDataList().get(i), ScreenUserJoinEntity.class); |
|
|
ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(formDTO.getDataList().get(i), ScreenUserJoinEntity.class); |
|
|
entity.setJoinTotalUpRate(zero); |
|
|
entity.setJoinTotalUpRate(zero); |
|
|
entity.setJoinTotalUpFlag(""); |
|
|
entity.setJoinTotalUpFlag(""); |
|
|
entity.setAvgIssueUpRate(zero); |
|
|
entity.setAvgIssueUpRate(zero); |
|
@ -396,14 +400,37 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true) |
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public Integer initBizOrg(CustomerBizOrgFormDTO formDTO) { |
|
|
|
|
|
ValidatorUtils.validateEntity(formDTO); |
|
|
|
|
|
List<ScreenCustomerAgencyEntity> entityList = screenCustomerAgencyDao.selectListAgencyInfo(formDTO.getCustomerId()); |
|
|
|
|
|
List<ScreenCustomerBizOrgEntity> list = new ArrayList<>(); |
|
|
|
|
|
if (CollectionUtils.isEmpty(entityList)) { |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
entityList.forEach(o -> { |
|
|
|
|
|
ScreenCustomerBizOrgEntity entity = new ScreenCustomerBizOrgEntity(); |
|
|
|
|
|
entity.setCustomerId(o.getCustomerId()); |
|
|
|
|
|
entity.setOrgId(o.getAgencyId()); |
|
|
|
|
|
entity.setBizType(formDTO.getBizType()); |
|
|
|
|
|
list.add(entity); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
screenCustomerBizOrgDao.deleteByBizType(formDTO); |
|
|
|
|
|
return screenCustomerBizOrgDao.batchInsert(list); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取当前日期的前一个月的日期 |
|
|
* 获取当前日期的前一个月的日期 |
|
|
|
|
|
* |
|
|
* @param |
|
|
* @param |
|
|
* @return java.lang.String[] |
|
|
* @return java.lang.String[] |
|
|
* @Author zhangyong |
|
|
* @Author zhangyong |
|
|
* @Date 15:33 2020-08-21 |
|
|
* @Date 15:33 2020-08-21 |
|
|
**/ |
|
|
**/ |
|
|
private String[] lastMonthDate(){ |
|
|
private String[] lastMonthDate() { |
|
|
String[] date = new String[NumConstant.TWO]; |
|
|
String[] date = new String[NumConstant.TWO]; |
|
|
//Java获取当前日期的前一个月的日期
|
|
|
//Java获取当前日期的前一个月的日期
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
Calendar calendar = Calendar.getInstance(); |
|
@ -411,8 +438,9 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
int year = calendar.get(Calendar.YEAR); |
|
|
int year = calendar.get(Calendar.YEAR); |
|
|
int month = calendar.get(Calendar.MONTH) + NumConstant.ONE; |
|
|
int month = calendar.get(Calendar.MONTH) + NumConstant.ONE; |
|
|
date[NumConstant.ZERO] = String.valueOf(year); |
|
|
date[NumConstant.ZERO] = String.valueOf(year); |
|
|
date[NumConstant.ONE] = String.valueOf(month);; |
|
|
date[NumConstant.ONE] = String.valueOf(month); |
|
|
if (NumConstant.TEN >= month){ |
|
|
; |
|
|
|
|
|
if (NumConstant.TEN >= month) { |
|
|
date[NumConstant.ONE] = NumConstant.ZERO_STR + month; |
|
|
date[NumConstant.ONE] = NumConstant.ZERO_STR + month; |
|
|
} |
|
|
} |
|
|
return date; |
|
|
return date; |
|
@ -421,8 +449,8 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
/** |
|
|
/** |
|
|
* 计算 本月数值 相较于 上月数值,的增长率 |
|
|
* 计算 本月数值 相较于 上月数值,的增长率 |
|
|
* |
|
|
* |
|
|
* @param old 上月数值 |
|
|
* @param old 上月数值 |
|
|
* @param now 本月数值 |
|
|
* @param now 本月数值 |
|
|
* @return java.math.BigDecimal |
|
|
* @return java.math.BigDecimal |
|
|
* @Author zhangyong |
|
|
* @Author zhangyong |
|
|
* @Date 15:38 2020-08-21 |
|
|
* @Date 15:38 2020-08-21 |
|
@ -459,8 +487,8 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { |
|
|
/** |
|
|
/** |
|
|
* 计算 本月数值 相较于 上月数值,的增长率, 得出标识 |
|
|
* 计算 本月数值 相较于 上月数值,的增长率, 得出标识 |
|
|
* |
|
|
* |
|
|
* @param old 上月数值 |
|
|
* @param old 上月数值 |
|
|
* @param now 本月数值 |
|
|
* @param now 本月数值 |
|
|
* @return java.util.String |
|
|
* @return java.util.String |
|
|
* @Author zhangyong |
|
|
* @Author zhangyong |
|
|
* @Date 15:38 2020-08-21 |
|
|
* @Date 15:38 2020-08-21 |
|
|