|
@@ -542,11 +542,11 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
relatedService = sysDeptMapper.selectById(wmScorePackage.getRelatedService());
|
|
|
}
|
|
|
//查询分配给当前用户机构的积分包,deptid为当前用户,而且typeid=1或2
|
|
|
- String deptId = SecurityUtils.getUser().getDeptId() + "";
|
|
|
- wmScorePackage.setDeptId(deptId);
|
|
|
- wmScorePackage.setTypeid("0,1,2");
|
|
|
- wmScorePackage.setSendPackageDeptId(wmScorePackage.getRelatedService());
|
|
|
- List<WmScorePackage> packageList = wmScorePackageMapper.getScorePackagekfpjf(wmScorePackage);
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
+// wmScorePackage.setDeptId(deptId);
|
|
|
+// wmScorePackage.setTypeid("0,1,2");
|
|
|
+// wmScorePackage.setSendPackageDeptId(wmScorePackage.getRelatedService());
|
|
|
+ List<WmScorePackage> packageList = this.getScorePackagekfpjf(deptId, new String[]{"0", "1", "2"});
|
|
|
|
|
|
for (WmScorePackage wmScorePackage1 : packageList) {
|
|
|
List<WmScoreTaskType> taskTypelist = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(wmScorePackage1.getId());
|
|
@@ -3173,4 +3173,67 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
newRechargeRecord.setCreateTime(now);
|
|
|
sysDeptRechargeRecordMapper.insert(newRechargeRecord);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取指定企业下积分包的可分配积分值
|
|
|
+ *
|
|
|
+ * @param deptId 企业id
|
|
|
+ * @param typeIds 企业类型
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<WmScorePackage> getScorePackagekfpjf(Integer deptId, String[] typeIds) {
|
|
|
+ // 查询企业下的积分包
|
|
|
+ List<WmScorePackage> packages = this.list(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
+ .eq(WmScorePackage::getDeptId, deptId)
|
|
|
+ .in(WmScorePackage::getTypeid, typeIds)
|
|
|
+ .eq(WmScorePackage::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
+ .eq(WmScorePackage::getEnableFlag, EnableEnum.ENABLE.val())
|
|
|
+ .eq(WmScorePackage::getOldPackage, "0"));
|
|
|
+
|
|
|
+ if (CollUtil.isNotEmpty(packages)) {
|
|
|
+ // 查询积分包的子包
|
|
|
+ Set<String> packageIdSet = packages.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
|
|
|
+ List<WmScorePackage> subPackages = this.list(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
+ .in(WmScorePackage::getRelationScoreId, packageIdSet)
|
|
|
+ .eq(WmScorePackage::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
+ .eq(WmScorePackage::getEnableFlag, EnableEnum.ENABLE.val()));
|
|
|
+ Map<String, Integer> relatedPackageScoresMap = new HashMap<>();
|
|
|
+ if (CollUtil.isNotEmpty(subPackages)) {
|
|
|
+ // 已分配的积分
|
|
|
+ relatedPackageScoresMap = subPackages.stream()
|
|
|
+ .collect(Collectors.groupingBy(WmScorePackage::getRelationScoreId, Collectors.summingInt(WmScorePackage::getScore)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询积分包的任务
|
|
|
+ List<WmTask> tasks = wmTaskMapper.selectList(Wrappers.<WmTask>lambdaQuery()
|
|
|
+ .in(WmTask::getScorePackageId, packageIdSet)
|
|
|
+ .eq(WmTask::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
+ .eq(WmTask::getEnableFlag, EnableEnum.ENABLE.val())
|
|
|
+ .eq(WmTask::getTaskStatus, TaskStatusEnum.APPROVED.val()));
|
|
|
+ Map<String, Integer> relatedTaskScoresMap = new HashMap<>();
|
|
|
+ if (CollUtil.isNotEmpty(tasks)) {
|
|
|
+ // 已分配的积分
|
|
|
+ relatedTaskScoresMap = tasks.stream()
|
|
|
+ .collect(Collectors.groupingBy(WmTask::getScorePackageId, Collectors.summingInt(WmTask::getScore)));
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Integer> finalRelatedPackageScoresMap = relatedPackageScoresMap;
|
|
|
+ Map<String, Integer> finalRelatedTaskScoresMap = relatedTaskScoresMap;
|
|
|
+ packages.forEach(pkg -> {
|
|
|
+ String packageId = pkg.getId();
|
|
|
+ // 统计可分配积分值
|
|
|
+ Integer kfpjf = pkg.getKfpjf();
|
|
|
+ if (finalRelatedPackageScoresMap.containsKey(packageId)) {
|
|
|
+ kfpjf += finalRelatedPackageScoresMap.get(packageId);
|
|
|
+ }
|
|
|
+ if (finalRelatedTaskScoresMap.containsKey(packageId)) {
|
|
|
+ kfpjf += finalRelatedTaskScoresMap.get(packageId);
|
|
|
+ }
|
|
|
+ pkg.setKfpjf(kfpjf);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return packages;
|
|
|
+ }
|
|
|
}
|