|
|
@ -9,9 +9,11 @@ import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
|
import com.epmet.constant.IndexCalConstant; |
|
|
|
import com.epmet.dao.evaluationindex.indexcal.CpcScoreDao; |
|
|
|
import com.epmet.dao.evaluationindex.indexcal.CpcSubScoreDao; |
|
|
|
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyDao; |
|
|
|
import com.epmet.dto.indexcal.CalculateCommonFormDTO; |
|
|
|
import com.epmet.entity.evaluationindex.indexcal.CpcScoreEntity; |
|
|
|
import com.epmet.entity.evaluationindex.indexcal.CpcSubScoreEntity; |
|
|
|
import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; |
|
|
|
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity; |
|
|
|
import com.epmet.eum.IndexCodeEnum; |
|
|
@ -49,6 +51,8 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
|
private IndexCodeFieldReService indexCodeFieldReService; |
|
|
|
@Autowired |
|
|
|
private CpcScoreDao cpcScoreDao; |
|
|
|
@Autowired |
|
|
|
private CpcSubScoreDao cpcSubScoreDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO) { |
|
|
@ -136,6 +140,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
|
* @param indexCode 指标code 非必填 |
|
|
|
* @param values |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
private void deleteAndInsertBatch(CalculateCommonFormDTO formDTO, Collection<CpcScoreEntity> values, String indexCode) { |
|
|
|
cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode); |
|
|
|
cpcScoreDao.insertBatch(values); |
|
|
@ -242,23 +247,42 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
|
public void saveCpcScore(CalculateCommonFormDTO formDTO, Map<String, CpcScoreEntity> indexDetails, String parentIndexCode, HashMap<String, CalculateResult> result) { |
|
|
|
|
|
|
|
List<CpcScoreEntity> list = new ArrayList<>(); |
|
|
|
result.forEach((userId, score) -> { |
|
|
|
List<CpcSubScoreEntity> subList = new ArrayList<>(); |
|
|
|
String allParentIndexCode = null; |
|
|
|
for (Map.Entry<String, CalculateResult> entry : result.entrySet()) { |
|
|
|
String userId = entry.getKey(); |
|
|
|
CalculateResult score = entry.getValue(); |
|
|
|
CpcScoreEntity cpcScoreEntity = indexDetails.get(userId); |
|
|
|
cpcScoreEntity.setScore(score.getTotalScore()); |
|
|
|
String allParentIndexCode = score.getDetails().get(0).getAllParentIndexCode(); |
|
|
|
allParentIndexCode = score.getDetails().get(0).getAllParentIndexCode(); |
|
|
|
cpcScoreEntity.setAllParentIndexCode(allParentIndexCode.substring(0, allParentIndexCode.lastIndexOf(StrConstant.COLON))); |
|
|
|
list.add(cpcScoreEntity); |
|
|
|
CpcScoreEntity parent = ConvertUtils.sourceToTarget(cpcScoreEntity, CpcScoreEntity.class); |
|
|
|
score.getDetails().forEach(o -> { |
|
|
|
CpcScoreEntity child = ConvertUtils.sourceToTarget(parent, CpcScoreEntity.class); |
|
|
|
CpcSubScoreEntity child = ConvertUtils.sourceToTarget(parent, CpcSubScoreEntity.class); |
|
|
|
child.setIndexCode(o.getIndexCode()); |
|
|
|
child.setAllParentIndexCode(o.getAllParentIndexCode()); |
|
|
|
child.setScore(o.getScore()); |
|
|
|
list.add(child); |
|
|
|
subList.add(child); |
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
System.out.println("value:" + JSON.toJSONString(list)); |
|
|
|
this.deleteAndInsertBatch(formDTO, list, parentIndexCode); |
|
|
|
this.deleteAndInsertSubBatch(formDTO, subList, allParentIndexCode); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* desc:根据客户id和月份Id 指标code 非必填 删除数据 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @param subList |
|
|
|
* @param parentIndexCode 指标code 非必填 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void deleteAndInsertSubBatch(CalculateCommonFormDTO formDTO, List<CpcSubScoreEntity> subList, String parentIndexCode) { |
|
|
|
cpcSubScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), parentIndexCode); |
|
|
|
cpcSubScoreDao.insertBatch(subList); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|