|
@@ -52,7 +52,6 @@ import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
-import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
@@ -842,6 +841,121 @@ public class WmSupervisionManager {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 按照区域 to 服务商的打包进行展示
|
|
|
|
+ public Page<Map<String, Object>> pageB2BPkg(WmSupervisionDto.OnB2BPkgPage query, HnqzUser operator) {
|
|
|
|
+
|
|
|
|
+ // 分页结果
|
|
|
|
+ Page<Map<String, Object>> page = new Page<>(query.getCurrent(), query.getSize());
|
|
|
|
+
|
|
|
|
+ // 根据角色判断药品
|
|
|
|
+ List<Integer> drugIds;
|
|
|
|
+ if (!SecurityUtils.getRoles().contains(39) && !SecurityUtils.getRoles().contains(37)) {
|
|
|
|
+
|
|
|
|
+ drugIds = userDrugService.listDrugIdByUserId(operator.getId());
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isEmpty(drugIds)) {
|
|
|
|
+ log.info("当前操作人没有分配产品");
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ drugIds = Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 筛查区域内所有企业
|
|
|
|
+ List<Long> areaCode = query.getAreaCode();
|
|
|
|
+ List<Long> entIds;
|
|
|
|
+ if (CollUtil.isNotEmpty(areaCode)) {
|
|
|
|
+ entIds = enterpriseAreaService.listAreaEnts(areaCode);
|
|
|
|
+ if (CollUtil.isEmpty(entIds)) {
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ entIds = Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String entName = query.getEntName();
|
|
|
|
+ Set<Integer> finalEntIds = new HashSet<>();
|
|
|
|
+ if (CharSequenceUtil.isNotBlank(entName)) {
|
|
|
|
+ List<SysDept> enterprises = deptService.list(Wrappers.<SysDept>lambdaQuery().like(SysDept::getName, entName).in(CollUtil.isNotEmpty(entIds), SysDept::getDeptId, entIds));
|
|
|
|
+ List<Integer> deptIds = enterprises.stream().mapToInt(SysDept::getDeptId).boxed().distinct().collect(Collectors.toList());
|
|
|
|
+ if (CollUtil.isEmpty(deptIds)) {
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+ finalEntIds.addAll(deptIds);
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ Set<Integer> collect = entIds.stream().map(Long::intValue).collect(Collectors.toSet());
|
|
|
|
+
|
|
|
|
+ List<SysDept> depts = deptService.list(Wrappers.<SysDept>lambdaQuery().in(CollUtil.isNotEmpty(collect), SysDept::getDeptId, collect).eq(SysDept::getLevel, 4));
|
|
|
|
+
|
|
|
|
+ finalEntIds.addAll(depts.stream().map(SysDept::getDeptId).collect(Collectors.toSet()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 获取全部的区域 & 获取区域ID
|
|
|
|
+ List<SysDept> districts = deptService.list(Wrappers.<SysDept>lambdaQuery().eq(SysDept::getLevel, 3));
|
|
|
|
+ Map<Integer, String> distId2NameMap = districts.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getName));
|
|
|
|
+ List<Integer> disIds = districts.stream().mapToInt(SysDept::getDeptId).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ // 获取区域发送所有b端包
|
|
|
|
+ Page<WmScorePackage> b2bPkgPage = packageService.page(new Page<>(query.getCurrent(), query.getSize()),
|
|
|
|
+ Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
+ .in(CollUtil.isNotEmpty(drugIds), WmScorePackage::getDrugtable, drugIds)
|
|
|
|
+ .eq(StrUtil.isNotBlank(query.getPkgName()), WmScorePackage::getScorePackageName, query.getPkgName())
|
|
|
|
+ .in(CollUtil.isNotEmpty(finalEntIds), WmScorePackage::getDeptId, finalEntIds)
|
|
|
|
+ // .between(WmScorePackage::getCreateTime, , )
|
|
|
|
+ .in(WmScorePackage::getSendPackageDeptId, disIds));
|
|
|
|
+
|
|
|
|
+ List<WmScorePackage> records = b2bPkgPage.getRecords();
|
|
|
|
+
|
|
|
|
+ List<Map<String, Object>> build = new ArrayList<>(records.size());
|
|
|
|
+ if (CollUtil.isNotEmpty(records)) {
|
|
|
|
+
|
|
|
|
+ // 获取服务商信息
|
|
|
|
+ Set<Integer> deptId = records.stream().mapToInt(pkg -> Integer.parseInt(pkg.getDeptId())).boxed().collect(Collectors.toSet());
|
|
|
|
+ Map<Integer, String> deptIdToDeptNameMap = deptService.listByIds(deptId).stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getName));
|
|
|
|
+
|
|
|
|
+ // 循环拼装数据
|
|
|
|
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DatePattern.CHINESE_DATE_PATTERN);
|
|
|
|
+ for (WmScorePackage pkg : records) {
|
|
|
|
+
|
|
|
|
+ Map<String, Object> ele = new HashMap<>(7);
|
|
|
|
+ ele.put("pkgName", pkg.getScorePackageName());
|
|
|
|
+ ele.put("score", pkg.getScore());
|
|
|
|
+ ele.put("pkgState", pkg.getPackageStatus());
|
|
|
|
+ ele.put("period", String.format("%s~%s", dateTimeFormatter.format(pkg.getStartTime()), dateTimeFormatter.format(pkg.getEndTime())));
|
|
|
|
+ ele.put("districtName", distId2NameMap.get(Integer.valueOf(pkg.getSendPackageDeptId())));
|
|
|
|
+ ele.put("deptName", deptIdToDeptNameMap.get(Integer.valueOf(pkg.getDeptId())));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 获取子集包
|
|
|
|
+ List<WmScorePackage> b2cPkg = packageService.list(Wrappers.<WmScorePackage>lambdaQuery().eq(WmScorePackage::getRelationScoreId, pkg.getId()));
|
|
|
|
+ if (CollUtil.isNotEmpty(b2cPkg)) {
|
|
|
|
+ List<String> b2cPkgIds = b2cPkg.stream().map(WmScorePackage::getId).distinct().sorted().collect(Collectors.toList());
|
|
|
|
+ // 获取子集包中的所有任务
|
|
|
|
+ taskService.listAvailableTaskForSupervision1(b2cPkgIds.stream().mapToInt(Integer::valueOf).boxed().distinct().sorted().collect(Collectors.toList()), Collections.emptyList());
|
|
|
|
+ List<WmTask> tasks = taskService.list(Wrappers.<WmTask>lambdaQuery().in(WmTask::getScorePackageId, b2cPkgIds));
|
|
|
|
+ // 获取监察记录
|
|
|
|
+ List<WmTaskSupervision> supervisions = taskSupervisionService.list(Wrappers.<WmTaskSupervision>lambdaQuery().in(WmTaskSupervision::getPackageId, b2cPkgIds));
|
|
|
|
+
|
|
|
|
+ // 获取监察结果
|
|
|
|
+ Map<String, String> stat = new HashMap<>(2);
|
|
|
|
+ stat.put("supTotal", CollUtil.isNotEmpty(supervisions) ? String.valueOf(supervisions.stream().map(WmTaskSupervision::getTaskId).collect(Collectors.toSet()).size()) : "0");
|
|
|
|
+ stat.put("total", CollUtil.isNotEmpty(tasks) ? String.valueOf(tasks.size()) : "0");
|
|
|
|
+ ele.put("taskSupStat", stat);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ build.add(ele);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ page.setRecords(build);
|
|
|
|
+ page.setTotal(b2bPkgPage.getTotal());
|
|
|
|
+ return page;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
// public Boolean checkTaskSupervision(WmSupervisionDto.OnTaskSupervisionCheck resource, HnqzUser user) {
|
|
// public Boolean checkTaskSupervision(WmSupervisionDto.OnTaskSupervisionCheck resource, HnqzUser user) {
|
|
// Integer supervisionId = resource.getSupervisionId();
|
|
// Integer supervisionId = resource.getSupervisionId();
|