|
@@ -2,6 +2,7 @@ package com.qunzhixinxi.hnqz.admin.manager;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -22,10 +23,13 @@ import com.qunzhixinxi.hnqz.admin.service.WmTaskService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeService;
|
|
|
import com.qunzhixinxi.hnqz.common.core.exception.BizException;
|
|
|
import com.qunzhixinxi.hnqz.common.security.service.HnqzUser;
|
|
|
+import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -47,6 +51,7 @@ import java.util.stream.Collectors;
|
|
|
public class WmPackageManager {
|
|
|
|
|
|
|
|
|
+ private static final int BIZ_ADMIN_ROLE = 41;
|
|
|
private static final int SERV_ADMIN_ROLE = 37;
|
|
|
private static final int DIST_ADMIN_ROLE = 4;
|
|
|
private static final int OK_CHAIN_TASK_NODE = 6;
|
|
@@ -89,23 +94,31 @@ public class WmPackageManager {
|
|
|
Page<Map<String, Object>> res = new Page<>(query.getCurrent(), query.getSize());
|
|
|
|
|
|
// 获取用户角色
|
|
|
- Set<Integer> roleIds = userRoleService.list(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, user.getId()))
|
|
|
- .stream().mapToInt(SysUserRole::getRoleId).boxed().collect(Collectors.toSet());
|
|
|
+ List<Integer> roles = SecurityUtils.getRoles();
|
|
|
+ // Set<Integer> roleIds = userRoleService.list(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, user.getId()))
|
|
|
+ // .stream().mapToInt(SysUserRole::getRoleId).boxed().collect(Collectors.toSet());
|
|
|
|
|
|
Page<WmPackageRedemptionNotice> page = new Page<>(query.getCurrent(), query.getSize());
|
|
|
LambdaQueryWrapper<WmPackageRedemptionNotice> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
|
|
// 根据用户角色判断是管理员还是服务商
|
|
|
// 区域管理员
|
|
|
- if (roleIds.contains(DIST_ADMIN_ROLE)) {
|
|
|
+ if (roles.contains(DIST_ADMIN_ROLE)) {
|
|
|
queryWrapper.eq(WmPackageRedemptionNotice::getFromEntId, user.getDeptId()).eq(WmPackageRedemptionNotice::getCreateBy, user.getUsername());
|
|
|
}
|
|
|
+ // 事业部分管领导
|
|
|
+ else if (roles.contains(BIZ_ADMIN_ROLE)) {
|
|
|
+ // 查询全部
|
|
|
+ }
|
|
|
// 服务商
|
|
|
- else if (roleIds.contains(SERV_ADMIN_ROLE)) {
|
|
|
- queryWrapper.eq(WmPackageRedemptionNotice::getToEntId, user.getDeptId());
|
|
|
+ else if (roles.contains(SERV_ADMIN_ROLE)) {
|
|
|
+ queryWrapper
|
|
|
+ .eq(WmPackageRedemptionNotice::getCheckState, WmPackageRedemptionNotice.CheckState.PASSED)
|
|
|
+ .eq(WmPackageRedemptionNotice::getToEntId, user.getDeptId());
|
|
|
} else {
|
|
|
throw new BizException("角色不支持该数据查询");
|
|
|
}
|
|
|
+
|
|
|
packageRedemptionNoticeService.page(page, queryWrapper);
|
|
|
|
|
|
List<WmPackageRedemptionNotice> records = page.getRecords();
|
|
@@ -206,9 +219,9 @@ public class WmPackageManager {
|
|
|
|
|
|
int taskTotalCount = tasks.size();
|
|
|
result.put("taskTotalCount", taskTotalCount);
|
|
|
- result.put("servicePlanDeviationRate", "10%");
|
|
|
- result.put("taskCompleteRate", String.format(".2f%d%%", okTasks.size() * 100 / ((taskTotalCount == 0) ? 1 : taskTotalCount)));
|
|
|
- result.put("marketCustomerContactRate", "3%");
|
|
|
+ result.put("servicePlanDeviationRate", "10");
|
|
|
+ result.put("taskCompleteRate", String.format("%.2f", okTasks.size() * 100.0 / ((taskTotalCount == 0) ? 1 : taskTotalCount)));
|
|
|
+ result.put("marketCustomerContactRate", "3");
|
|
|
result.put("fromEntId", scorePackage.getSendPackageDeptId());
|
|
|
result.put("toEntId", scorePackage.getDeptId());
|
|
|
|
|
@@ -264,5 +277,68 @@ public class WmPackageManager {
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生效兑付同种
|
|
|
+ *
|
|
|
+ * @param resource 生效信息
|
|
|
+ * @param user 操作人
|
|
|
+ * @return 操作结果
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean launchPackageRedemptionNotice(WmPkgDTO.OnRedemptionNoticeLaunch resource, HnqzUser user) {
|
|
|
+
|
|
|
+ WmPackageRedemptionNotice notice = new WmPackageRedemptionNotice();
|
|
|
+ notice.setNoticeId(resource.getRedemptionNoticeId());
|
|
|
+ notice.setCheckState(WmPackageRedemptionNotice.CheckState.CKT2.getState());
|
|
|
+ notice.setUpdateBy(user.getUsername());
|
|
|
+ notice.setUpdateTime(LocalDateTime.now());
|
|
|
+
|
|
|
+ return packageRedemptionNoticeService.updateById(notice);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核兑付通知
|
|
|
+ *
|
|
|
+ * @param resource 生效信息
|
|
|
+ * @param user 操作人
|
|
|
+ * @return 操作结果
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean checkPackageRedemptionNotice(WmPkgDTO.OnRedemptionNoticeCheck resource, HnqzUser user) {
|
|
|
+
|
|
|
+ Boolean checkResult = resource.getCheckResult();
|
|
|
+
|
|
|
+ WmPackageRedemptionNotice.NoticeState noticeState;
|
|
|
+ WmPackageRedemptionNotice.CheckState checkState;
|
|
|
+ String checkRemarks;
|
|
|
+
|
|
|
+ // 审核通过
|
|
|
+ if (checkResult){
|
|
|
+ noticeState = WmPackageRedemptionNotice.NoticeState.SEND;
|
|
|
+ checkState = WmPackageRedemptionNotice.CheckState.PASSED;
|
|
|
+ checkRemarks = StrUtil.isBlank(resource.getCheckRemarks()) ? "通过(系统追加)" : resource.getCheckRemarks();
|
|
|
+ }
|
|
|
+ // 审核不通过
|
|
|
+ else {
|
|
|
+ noticeState = WmPackageRedemptionNotice.NoticeState.PENDING;
|
|
|
+ checkState = WmPackageRedemptionNotice.CheckState.REJECTED;
|
|
|
+ checkRemarks = resource.getCheckRemarks();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ WmPackageRedemptionNotice notice = new WmPackageRedemptionNotice();
|
|
|
+ notice.setNoticeId(resource.getRedemptionNoticeId());
|
|
|
+
|
|
|
+ notice.setNoticeState(noticeState.getState());
|
|
|
+ notice.setCheckState(checkState.getState());
|
|
|
+ notice.setCheckResult(checkResult);
|
|
|
+ notice.setCheckRemarks(checkRemarks);
|
|
|
+ notice.setUpdateBy(user.getUsername());
|
|
|
+ notice.setUpdateTime(LocalDateTime.now());
|
|
|
+
|
|
|
+
|
|
|
+ return packageRedemptionNoticeService.updateById(notice);
|
|
|
+ }
|
|
|
}
|
|
|
|