Ver código fonte

feat: 个人积分包导出excel

lixuesong 1 ano atrás
pai
commit
a6d114b991

+ 160 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/WmScorePackageController.java

@@ -1,5 +1,6 @@
 package com.qunzhixinxi.hnqz.admin.controller;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DatePattern;
@@ -16,11 +17,13 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.ArrayListMultimap;
+import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
 import com.qunzhixinxi.hnqz.admin.api.constant.CacheConstants;
 import com.google.common.collect.Multimap;
 import com.pig4cloud.plugin.excel.annotation.RequestExcel;
 import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
 import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
+import com.qunzhixinxi.hnqz.admin.api.entity.SysDictItem;
 import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
 import com.qunzhixinxi.hnqz.admin.api.entity.WmPkgQuizRelation;
 import com.qunzhixinxi.hnqz.admin.api.enums.TargetType;
@@ -29,9 +32,11 @@ import com.qunzhixinxi.hnqz.admin.entity.*;
 import com.qunzhixinxi.hnqz.admin.entity.dto.UnpackDTO;
 import com.qunzhixinxi.hnqz.admin.entity.input.WmScorePackageSettleOutput;
 import com.qunzhixinxi.hnqz.admin.entity.model.excel.BatchPackageExcelModel;
+import com.qunzhixinxi.hnqz.admin.entity.model.excel.WmScorePackageExcelModel;
 import com.qunzhixinxi.hnqz.admin.enums.DelEnum;
 import com.qunzhixinxi.hnqz.admin.enums.EnableEnum;
 import com.qunzhixinxi.hnqz.admin.enums.PackageTypeEnum;
+import com.qunzhixinxi.hnqz.admin.enums.ScorePackageStatusEnum;
 import com.qunzhixinxi.hnqz.admin.enums.SubjectLocation;
 import com.qunzhixinxi.hnqz.admin.mapper.*;
 import com.qunzhixinxi.hnqz.admin.recharge.entity.SysDeptRecharge;
@@ -108,6 +113,7 @@ public class WmScorePackageController {
 	private final WmBizReminderService wmBizReminderService;
 	private final StringRedisTemplate redisTemplate;
 	private final WmPkgQuizRelationService pkgQuizRelationService;
+	private final SysDictItemService sysDictItemService;
 	private final Sequence pkgSequence;
 
 
@@ -2713,6 +2719,160 @@ public class WmScorePackageController {
 		return R.ok(wmScorePackagePage);
 	}
 
+	/**
+	 * 个人承接积分值导出
+	 *
+	 * @param acceptUser 接单对象,模糊查询
+	 */
+	@ResponseExcel(name = "exportPackageSettle", sheet = "积分包结算数据")
+	@SysLog("个人承接积分值导出")
+	@GetMapping("/export-score-package")
+	public List<WmScorePackageExcelModel> exportScorePackage(
+															 @RequestParam(value = "packageType1") Integer packageType1,
+															 @RequestParam(value = "packageType2") Integer packageType2,
+															 @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
+															 @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
+															 @RequestParam(value = "typeid", required = false) String typeId,
+															 @RequestParam(value = "monthStart", required = false) String monthStart,
+															 @RequestParam(value = "monthEnd", required = false) String monthEnd,
+															 @RequestParam(value = "acceptUser", required = false) String acceptUser,
+															 @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
+															 @RequestParam(value = "toApproval", required = false) Boolean toApproval,
+															 @RequestParam(value = "packageUserScope", required = false) String packageUserScope
+	) {
+
+		Integer sendDeptId = SecurityUtils.getUser().getDeptId();
+		Integer userId = SecurityUtils.getUser().getId();
+
+		LocalDateTime start = null;
+		LocalDateTime end = null;
+
+		if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
+			start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
+			LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
+			end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
+
+		}
+
+		QueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>query()
+				.eq("p.package_type1", packageType1)
+				.eq("p.package_type2", packageType2)
+				.eq(scorePackageStatus != null, "p.score_package_status", scorePackageStatus)
+				.eq("p.send_package_dept_id", sendDeptId)
+				.between(start != null && end != null, "p.create_time", start, end);
+
+		if (StrUtil.isNotBlank(scorePackageName)) {
+			queryWrapper.and(wrapper -> wrapper.like("p.score_package_name", scorePackageName).or().like("p.pkg_sn", scorePackageName));
+		}
+
+		if (StringUtil.isEmpty(typeId)) {
+			queryWrapper.in("p.typeid", "3", "4", "5");
+		} else {
+			List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
+			queryWrapper.in("p.typeid", split);
+		}
+
+		// 接单对象范围筛选
+		if (StrUtil.isNotBlank(packageUserScope)) {
+			queryWrapper.eq("p.package_user_scope", packageUserScope);
+		}
+
+		boolean onePersonScorePackageFlag = PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val().equals(String.valueOf(packageType1))
+				&& PackageTypeEnum.TYPE2_TASK_PACKAGE.val().equals(String.valueOf(packageType2));
+		boolean multiPersonScorePackageFlag = PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val().equals(String.valueOf(packageType1))
+				&& PackageTypeEnum.TYPE2_SETTLE_PACKAGE.val().equals(String.valueOf(packageType2));
+		if (onePersonScorePackageFlag || multiPersonScorePackageFlag) {
+			// 如果是个人承接-按积分值/多人承接-按积分值,判断当前用户是否配置了团队负责人
+			List<WmTeam> teamList = wmTeamService.list(Wrappers.<WmTeam>lambdaQuery()
+					.eq(WmTeam::getDeptId, sendDeptId)
+					.eq(WmTeam::getEnableFlag, EnableEnum.ENABLE.val())
+					.eq(WmTeam::getDelFlag, DelEnum.NOT_DEL.val())
+					.apply("FIND_IN_SET({0}, leader)", String.valueOf(userId)));
+			if (CollectionUtil.isNotEmpty(teamList)) {
+				// 如果配置了,则只查询所在团队下发的积分包
+				List<String> teamIdList = teamList.stream().map(wmTeam -> String.valueOf(wmTeam.getId())).collect(Collectors.toList());
+				queryWrapper.in("p.package_user_scope", teamIdList);
+			}
+		}
+
+		long startMillis = System.currentTimeMillis();
+		List<WmScorePackage> scorePackageList = wmScorePackageMapper.listScorePackage(
+				queryWrapper.orderByDesc("p.create_time"), acceptUser, relationScoreId, toApproval);
+		log.info("积分包列表-不分页sql耗时:{}", System.currentTimeMillis() - startMillis);
+
+		if (CollUtil.isEmpty(scorePackageList)) {
+			return Collections.emptyList();
+		}
+
+		long buildStartMillis = System.currentTimeMillis();
+
+		Set<String> packageIds = scorePackageList.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
+
+		// 任务统计
+		List<WmTask> taskList = wmTaskMapper.selectList(Wrappers.<WmTask>lambdaQuery()
+				.eq(WmTask::getRealFlag, "0")
+				.eq(WmTask::getEnableFlag, "0")
+				.eq(WmTask::getDelFlag, "0")
+				.in(WmTask::getScorePackageId, packageIds)
+		);
+		Map<String, List<WmTask>> taskGoupMap = taskList.stream().collect(Collectors.groupingBy(WmTask::getScorePackageId));
+
+		// 领取积分包记录
+		List<WmScorePackageStatus> scorePackageStatusList = wmScorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery()
+				.in(WmScorePackageStatus::getPackageId, packageIds)
+		);
+		Map<String, List<WmScorePackageStatus>> packageStatusGroupMap = scorePackageStatusList.stream()
+				.collect(Collectors.groupingBy(WmScorePackageStatus::getPackageId));
+
+		//获取上级包 TODO
+//		Set<String> packageIds = scorePackageList.stream().map(WmScorePackage::getRelationScoreId).collect(Collectors.toSet());
+//		List<WmScorePackage> relationScorePackages = wmScorePackageMapper.selectList(Wrappers.<WmScorePackage>lambdaQuery()
+//				.in(WmScorePackage::getId, packageIds));
+//		relationScorePackages.stream().collect(Collectors.groupingBy(WmScorePackage::getId));
+
+		// 类型标签
+		List<SysDictItem> dictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
+				.in(SysDictItem::getType, "package_type1", "package_type2"));
+		Map<String, List<SysDictItem>> dictItemMap = dictItems.stream().collect(Collectors.groupingBy(SysDictItem::getType));
+		List<SysDictItem> packageType1List = dictItemMap.get("package_type1");
+		List<SysDictItem> packageType2List = dictItemMap.get("package_type2");
+
+		List<WmScorePackageExcelModel> excelModelList = new ArrayList<>(scorePackageList.size());
+		for (int i = 0; i < scorePackageList.size(); i++) {
+			WmScorePackage wmScorePackage = scorePackageList.get(i);
+			log.info("====> 积分包SN:{}", wmScorePackage.getPackageSn());
+
+			List<WmTask> tasks = taskGoupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
+			List<WmScorePackageStatus> statuses = packageStatusGroupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
+
+			wmScorePackageService.buildScorePackageSync(wmScorePackage, packageType1, packageType2, tasks, statuses,
+					packageType1List, packageType2List);
+
+			WmScorePackageExcelModel excelModel = BeanUtil.copyProperties(wmScorePackage, WmScorePackageExcelModel.class);
+			if (StrUtil.isNotBlank(wmScorePackage.getScorePackageStatus())) {
+				excelModel.setScorePackageStatus(Objects.requireNonNull(ScorePackageStatusEnum.getByVal(wmScorePackage.getScorePackageStatus())).getDesc());
+			}
+
+			if (CollUtil.isNotEmpty(wmScorePackage.getUserList())) {
+				excelModel.setUserNames(String.join(",", wmScorePackage.getUserList()));
+			}
+
+			String typeid = wmScorePackage.getTypeid();
+			if (StrUtil.isNotBlank(typeid)) {
+				excelModel.setTypeidName("3".equals(typeid) ? "全职学术信息沟通专员" :
+						"4".equals(typeid) ? "兼职学术信息沟通专员" : "5".equals(typeid) ? "招商经理" : typeid);
+			}
+
+			excelModelList.add(excelModel);
+
+			log.info("遍历{} 耗时{}", wmScorePackage.getId(), System.currentTimeMillis() - buildStartMillis);
+		}
+
+		log.info("build积分包耗时:{}", System.currentTimeMillis() - buildStartMillis);
+
+		return excelModelList;
+	}
+
 	/**
 	 * 积分包列表(结算包管理列表、无团队限制)
 	 *

+ 138 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/entity/model/excel/WmScorePackageExcelModel.java

@@ -0,0 +1,138 @@
+package com.qunzhixinxi.hnqz.admin.entity.model.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 积分包
+ *
+ * @author gaoyanng
+ * @date 2020-06-25 23:35:42
+ */
+@Data
+public class WmScorePackageExcelModel implements Serializable {
+	private static final long serialVersionUID = -2712453720764666659L;
+
+	/**
+	 * 序号
+	 */
+	@ColumnWidth(10)
+	@ExcelProperty("序号")
+	private String number;
+
+	/**
+	 * 积分包序列号
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("积分包编号")
+	private String packageSn;
+
+	/**
+	 * 积分包名称
+	 */
+	@ColumnWidth(40)
+	@ExcelProperty("积分包名称")
+	private String scorePackageName;
+
+	/**
+	 * 所属月份
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("发布日期")
+	private String belongDate;
+
+	/**
+	 * 接单对象
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("接单对象")
+	private String userNames;
+
+	/**
+	 * 积分包状态
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("积分包状态")
+	private String scorePackageStatus;
+
+	/**
+	 * 完成积分值
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("完成积分值")
+	private Integer ysh;
+
+	/**
+	 * 已完成百分比
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("完成百分比(%)")
+	private String finishRate;
+
+	/**
+	 * 已支付积分值
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("审核通过积分值")
+	private Integer payScore;
+
+	/**
+	 * 已支付百分比
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("审核通过百分比")
+	private String payRate;
+
+	/**
+	 * 结算时间
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("提交时间")
+	private LocalDateTime settlementDate;
+
+	/**
+	 * 提交到零工时间
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("下发时间")
+	private LocalDateTime subToGigTime;
+
+	/**
+	 * 结算时间
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("到账时间")
+	private LocalDateTime notifyDate;
+
+	/**
+	 * 关联积分包名称
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("关联积分包名称")
+	private String relationScoreId;
+
+	/**
+	 * 有效任务类型
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("有效任务类型")
+	private String taskTypes;
+
+	/**
+	 * 接单对象范围
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("接单对象范围")
+	private String packageUserScopeName;
+
+	/**
+	 * 接单对象类型
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("接单对象类型")
+	private String typeidName;
+}

+ 11 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/mapper/WmScorePackageMapper.java

@@ -180,6 +180,17 @@ public interface WmScorePackageMapper extends DataScopeMapper<WmScorePackage> {
 										  @Param("acceptUser") String acceptUser, @Param("relationScoreId") String relationScoreId,
 										  @Param("toApproval") Boolean toApproval);
 
+	/**
+	 * 积分包列表查询-不分页
+	 *
+	 * @param queryWrapper
+	 * @param acceptUser
+	 * @return
+	 */
+	List<WmScorePackage> listScorePackage(@Param(Constants.WRAPPER) QueryWrapper<WmScorePackage> queryWrapper,
+										  @Param("acceptUser") String acceptUser, @Param("relationScoreId") String relationScoreId,
+										  @Param("toApproval") Boolean toApproval);
+
 	/**
 	 * 查询财务结算复核汇总
 	 *

+ 16 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/WmScorePackageService.java

@@ -23,10 +23,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
 import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
+import com.qunzhixinxi.hnqz.admin.api.entity.SysDictItem;
 import com.qunzhixinxi.hnqz.admin.api.entity.WmReportOpt;
 import com.qunzhixinxi.hnqz.admin.api.vo.WmScorePackageVO;
 import com.qunzhixinxi.hnqz.admin.entity.WmDaDrugEntDrugtable;
 import com.qunzhixinxi.hnqz.admin.entity.WmScorePackage;
+import com.qunzhixinxi.hnqz.admin.entity.WmScorePackageStatus;
+import com.qunzhixinxi.hnqz.admin.entity.WmTask;
 import com.qunzhixinxi.hnqz.admin.entity.dto.UnpackDTO;
 import com.qunzhixinxi.hnqz.admin.entity.input.WmScorePackageApiOutput;
 import com.qunzhixinxi.hnqz.admin.entity.input.WmScorePackageSettleInput;
@@ -176,6 +179,19 @@ public interface WmScorePackageService extends IService<WmScorePackage> {
 
 	Future<WmScorePackage> buildScorePackage(WmScorePackage wmScorePackage, Integer packageType1, Integer packageType2);
 
+	/**
+	 * 同步处理积分包详情数据
+	 *
+	 * @param wmScorePackage   积分包信息
+	 * @param packageType1     积分包type1
+	 * @param packageType2     积分包type2
+	 * @param tasks
+	 * @param statuses
+	 * @param packageType1List
+	 * @param packageType2List
+	 */
+	void buildScorePackageSync(WmScorePackage wmScorePackage, Integer packageType1, Integer packageType2, List<WmTask> tasks, List<WmScorePackageStatus> statuses, List<SysDictItem> packageType1List, List<SysDictItem> packageType2List);
+
 	void getReportOpt(WmScorePackage wmScorePackage);
 
 	/**

+ 251 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmScorePackageServiceImpl.java

@@ -2514,6 +2514,257 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
 		return new AsyncResult<>(scorePackage);
 	}
 
+	/**
+	 * 同步处理积分包详情数据
+	 *
+	 * @param scorePackage           积分包信息
+	 * @param packageType1           积分包type1
+	 * @param packageType2           积分包type2
+	 * @param taskList               所有任务
+	 * @param scorePackageStatusList 领包记录
+	 * @param packageType1List
+	 * @param packageType2List
+	 */
+	@Override
+	public void buildScorePackageSync(WmScorePackage scorePackage, Integer packageType1, Integer packageType2,
+									  List<WmTask> taskList, List<WmScorePackageStatus> scorePackageStatusList,
+									  List<SysDictItem> packageType1List, List<SysDictItem> packageType2List) {
+		List<String> reportWaitingCheckStatus = Arrays.asList("0", "1", "2", "3", "4");
+
+		// 审核通过
+		int shtg = taskList.parallelStream()
+				.filter(t -> StrUtil.equals(t.getReportDrugApprovalOpinion(), "1") || StrUtil.equals(t.getReportOneApprovalOpinion(), "1"))
+				.mapToInt(WmTask::getScore)
+				.sum();
+		// 审核 不通过
+		int shbtg = taskList.parallelStream()
+				.filter(t -> StrUtil.equals(t.getReportDrugApprovalOpinion(), "2") || StrUtil.equals(t.getReportOneApprovalOpinion(), "2"))
+				.mapToInt(WmTask::getScore)
+				.sum();
+		// 审核通过数
+		long shtgnum = taskList.parallelStream()
+				.filter(t -> StrUtil.equals(t.getReportDrugApprovalOpinion(), "1") || StrUtil.equals(t.getReportOneApprovalOpinion(), "1"))
+				.count();
+		// 审核不通过数
+		long shbtgnum = taskList.parallelStream()
+				.filter(t -> StrUtil.equals(t.getReportDrugApprovalOpinion(), "2") || StrUtil.equals(t.getReportOneApprovalOpinion(), "2"))
+				.count();
+		// 平台未审核
+		int temp = taskList.parallelStream()
+				.filter(t -> StrUtil.equals(t.getTaskStatus(), "1"))
+				.mapToInt(t -> t.getScore() == null ? 0 : t.getScore())
+				.sum();
+		// 待审核
+		int dsh = taskList.parallelStream()
+				.filter(t -> StrUtil.equals(t.getTaskStatus(), "2"))
+				.mapToInt(t -> t.getScore() == null ? 0 : t.getScore())
+				.sum();
+		// 已审核
+		int ysh = taskList.parallelStream()
+				.filter(t -> StrUtil.equals(t.getTaskStatus(), "3"))
+				.mapToInt(t -> t.getScore() == null ? 0 : t.getScore())
+				.sum();
+		// 已审核数
+		long yshnum = taskList.parallelStream().filter(t -> StrUtil.equals(t.getTaskStatus(), "3")).count();
+		// 已提交
+		int ytj = temp + dsh + ysh;
+
+		// 已审核百分比
+		long yshtt = 0;
+		// 审核通过百分比
+		long shtgtt = 0;
+		// 审核不通过百分比
+		long shbtgtt = 0;
+		if (StrUtil.equals(scorePackage.getPackageType1(), PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val())
+				|| StrUtil.equals(scorePackage.getPackageType1(), PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val())) {
+			int score = scorePackage.getScore();
+			if (score != 0) {
+				yshtt = ysh * 100L / score;
+				yshtt = yshtt > 100 ? 100 : yshtt;
+
+				shtgtt = shtg * 100L / score;
+				shtgtt = shtgtt > 100 ? 100 : shtgtt;
+
+				shbtgtt = shbtg * 100L / score;
+				shbtgtt = shbtgtt > 100 ? 100 : shbtgtt;
+			}
+		} else {
+			int score = scorePackage.getUserNum() * (scorePackage.getTaskNum() == null ? 0 : scorePackage.getTaskNum());
+			if (score != 0) {
+				yshtt = yshnum * 100 / score;
+				shtgtt = shtgnum * 100 / score;
+				shbtgtt = shbtgnum * 100 / score;
+			}
+		}
+
+
+		List<WmScorePackageStatus> packageStatusList = scorePackageStatusList.stream()
+				.filter(s -> StrUtil.equals(s.getEnableFlag(), "0") && StrUtil.equals(s.getDelFlag(), "0"))
+				.collect(Collectors.toList());
+
+
+		List<WmScorePackageStatus> staList = scorePackageStatusList.stream()
+				.filter(record -> StrUtil.equals(record.getStatus(), "2"))
+				.collect(Collectors.toList());
+		;
+
+		if (CollUtil.isNotEmpty(staList)) {
+			List<String> userIdList = staList.stream()
+					.map(WmScorePackageStatus::getUserId)
+					.collect(Collectors.toList());
+
+			List<String> userNameList = sysUserMapper.selectList(Wrappers.<SysUser>lambdaQuery()
+							.in(SysUser::getUserId, userIdList))
+					.stream()
+					.map(SysUser::getRealname)
+					.collect(Collectors.toList());
+			scorePackage.setUserList(userNameList);
+			scorePackage.setUserListNum(userNameList.size());
+		} else {
+			scorePackage.setUserListNum(0);
+		}
+
+		// 已结单
+		long yjd = packageStatusList.stream()
+				.filter(s -> StrUtil.equalsAny(s.getStatus(), "1", "2"))
+				.count();
+		// 已结单待审核
+		long yjddsh = packageStatusList.stream()
+				.filter(s -> StrUtil.equals(s.getStatus(), "1"))
+				.count();
+
+
+		//获取上级包
+		WmScorePackage relationScorePackage = wmScorePackageMapper.selectOne(Wrappers.<WmScorePackage>lambdaQuery()
+				.eq(WmScorePackage::getId, scorePackage.getRelationScoreId()).last("limit 1"));
+
+
+		// 类型标签
+		SysDictItem package_type1 = packageType1List.stream()
+				.filter(type -> StrUtil.equals(type.getValue(), String.valueOf(packageType1)))
+				.findFirst().get();
+		SysDictItem package_type2 = packageType1List.stream()
+				.filter(type -> StrUtil.equals(type.getValue(), String.valueOf(packageType2)))
+				.findFirst().get();
+
+		String type1Lable = package_type1.getLabel();
+		String type2Lable = package_type2.getLabel();
+
+		// 设置
+		// scorePackage.setYsh(yshtt >= 100 ? scorePackage.getScore() : ysh);
+		scorePackage.setYjd((int) yjd);
+		scorePackage.setYjddsh((int) yjddsh);
+		scorePackage.setDsh(dsh);
+		if (!StrUtil.equalsAny(scorePackage.getScorePackageStatus(), "1", "6")) {
+			scorePackage.setYsh(ysh);
+			scorePackage.setShtg(shtg);
+			scorePackage.setShbtg(shbtg);
+			scorePackage.setShbtgnum((int) shbtgnum);
+			scorePackage.setShtgnum((int) shtgnum);
+			scorePackage.setShtgtt((int) shtgtt);
+			scorePackage.setShbtgtt((int) shbtgtt);
+			scorePackage.setYshtt((int) yshtt);
+		}
+		scorePackage.setIsTask(scorePackage.getId());
+		scorePackage.setYtj(ytj);
+		scorePackage.setPackageType1(type1Lable);
+		scorePackage.setPackageType2(type2Lable);
+		scorePackage.setRelationScoreId(relationScorePackage != null ? relationScorePackage.getScorePackageName() : null);
+
+
+		// 结算记录
+		WmScorePackageSettleNote note = settleNoteMapper.selectOne(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
+				.eq(WmScorePackageSettleNote::getPackageId, scorePackage.getId()).last("limit 1"));
+
+		scorePackage.setSettleAmount(null);
+		if (note != null) {
+			scorePackage.setNotifyDate(note.getNotifyTime());
+			scorePackage.setSubToGigTime(note.getSubToGigTime());
+			scorePackage.setSettleStatus(note.getSettleNoteStatus());
+			if (SettleStatusEnum.SETTLE_STATUS_SUCCESS.getVal().equals(String.valueOf(note.getSettleNoteStatus()))) {
+				scorePackage.setSettleAmount(note.getSettleAmount());
+			}
+		}
+
+		if (packageType2 == 2) {
+
+
+			int wsNum = settleNoteMapper.selectCount(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
+					.eq(WmScorePackageSettleNote::getPackageId, scorePackage.getId())
+					.in(WmScorePackageSettleNote::getSettleNoteStatus, 2, 9));
+			int asNum = settleNoteMapper.selectCount(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
+					.eq(WmScorePackageSettleNote::getPackageId, scorePackage.getId())
+					.eq(WmScorePackageSettleNote::getSettleNoteStatus, 1));
+			scorePackage.setWsTaskNum(wsNum);
+			scorePackage.setAsTaskNum(asNum);
+
+		}
+
+		if (PackageTypeEnum.TYPE1_HCP_PACKAGE.getName().equals(scorePackage.getPackageType1())) {
+			// 如果是患者教育,则转换积分值 '分'-> '元'
+			Integer score = scorePackage.getScore();
+			String userScore = scorePackage.getUserScore();
+			if (StringUtils.isNumeric(userScore)) {
+				scorePackage.setUserScore(String.format("%.2f", Integer.parseInt(userScore) / 100.0));
+			}
+		}
+
+		List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(scorePackage.getId());
+		if (CollUtil.isNotEmpty(taskTypeList)) {
+			String taskTypes = taskTypeList.stream().map(
+					WmScoreTaskType::getTaskTypeName).collect(Collectors.joining(","));
+			scorePackage.setTaskTypes(taskTypes);
+		}
+
+
+		// 设置中止状态
+		if (relationScorePackage != null) {
+			// 关联了上级包的情况
+			// 统计发包方还未审核的
+			long drugNeedToCheckCount = taskList.stream()
+					.filter(t -> "3".equals(t.getTaskStatus()) && reportWaitingCheckStatus.contains(t.getReportDrugApprovalStatus()))
+					.count();
+
+			// 统计cso未审核 和审核通过的还未提交到药企的任务数
+			long csoNeedToCheckCount = taskList.stream()
+					.filter(t -> "2".equals(t.getTaskStatus()) ||
+							("3".equals(t.getTaskStatus()) && (reportWaitingCheckStatus.contains(t.getReportOneApprovalStatus()))))
+					.count();
+
+			// 如果有发包方未审核的不能中止
+			if (drugNeedToCheckCount != 0L || csoNeedToCheckCount != 0L) {
+				scorePackage.setStopStatus(WmScorePackage.PackageStopStatus.NOTHING);
+			}
+		} else {
+			// 没有关联上级包的情况
+			// 统计待审核任务数
+			long toApproveCount = taskList.stream().filter(t -> TaskStatusEnum.UNDER_REVIEW.val().equals(t.getTaskStatus())).count();
+			if (toApproveCount > 0) {
+				scorePackage.setStopStatus(WmScorePackage.PackageStopStatus.NOTHING);
+			}
+		}
+
+		// 封装报告记录
+		scorePackage.setReportMqName(CacheConstants.EXPORT_ZB_REPORT_CACHE);
+		getReportOpt(scorePackage);
+
+		// 封装excel报告状态
+		this.getExcelReportOpt(scorePackage, CacheConstants.EXCEL_EXPORT_ZB_REPORT_CACHE);
+
+		// 封装新版报告状态
+		WmReportOpt newReportOpt = this.getNewReportOpt(scorePackage, CacheConstants.NEW_PERSONAL_REPORT_CACHE);
+		scorePackage.setNewReportOpt(newReportOpt);
+
+		// 封装新版excel报告状态
+		WmReportOpt newExcelReportOpt = this.getNewReportOpt(scorePackage, CacheConstants.NEW_EXCEL_COMMON_REPORT_CACHE);
+		scorePackage.setNewExcelReportOpt(newExcelReportOpt);
+
+		// 接单对象范围名称
+		if (StrUtil.isNotBlank(scorePackage.getPackageUserScope())) {
+			String packageUserScopeName = wmTeamService.getPackageUserScopeName(scorePackage.getPackageUserScope());
+			scorePackage.setPackageUserScopeName(packageUserScopeName);
+		}
+	}
 
 	private Set<String> stepA(String packageId) {