|
@@ -12,15 +12,18 @@ import com.pig4cloud.plugin.excel.annotation.RequestExcel;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDictItem;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.WmScorePackage;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.WmScorePackageStatus;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.WmTeam;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.base.BaseEntity;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.model.excel.WmTeamExcelModel;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.DelEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.EnableEnum;
|
|
|
+import com.qunzhixinxi.hnqz.admin.enums.PackageStatusEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.ScorePackageStatusEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserMapper;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDictItemService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmScorePackageService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmScorePackageStatusService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTeamService;
|
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
|
import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
|
|
@@ -36,7 +39,6 @@ import org.springframework.web.bind.annotation.PutMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RequestPart;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
@@ -44,6 +46,7 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -62,6 +65,8 @@ public class WmTeamController {
|
|
|
|
|
|
private final WmScorePackageService wmScorePackageService;
|
|
|
|
|
|
+ private final WmScorePackageStatusService wmScorePackageStatusService;
|
|
|
+
|
|
|
private final SysUserMapper sysUserMapper;
|
|
|
|
|
|
private final SysDictItemService sysDictItemService;
|
|
@@ -95,6 +100,38 @@ public class WmTeamController {
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存
|
|
|
+ *
|
|
|
+ * @param wmTeam
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @SysLog("保存团队-平台")
|
|
|
+ @PostMapping("/save-by-dept")
|
|
|
+ public R<?> saveByDept(@RequestBody @Validated({BaseEntity.Create.class}) WmTeam wmTeam) {
|
|
|
+ if (wmTeam.getDeptId() == null) {
|
|
|
+ return R.failed("deptId不能为空");
|
|
|
+ }
|
|
|
+ if (StrUtil.containsBlank(wmTeam.getName())) {
|
|
|
+ return R.failed("团队名称不能包含空格");
|
|
|
+ }
|
|
|
+ int count = wmTeamService.count(Wrappers.<WmTeam>lambdaQuery()
|
|
|
+ .eq(WmTeam::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
+ .eq(WmTeam::getName, wmTeam.getName()));
|
|
|
+ if (count > 0) {
|
|
|
+ return R.failed("团队名称已存在");
|
|
|
+ }
|
|
|
+ wmTeam.setDeptId(wmTeam.getDeptId());
|
|
|
+ wmTeam.setCreateTime(LocalDateTime.now());
|
|
|
+ wmTeam.setCreateUser(SecurityUtils.getUser().getId());
|
|
|
+ if (wmTeam.getLeader() != null) {
|
|
|
+ wmTeam.setEnableFlag(EnableEnum.ENABLE.val());
|
|
|
+ }
|
|
|
+ wmTeam.setDelFlag(DelEnum.NOT_DEL.val());
|
|
|
+ wmTeamService.save(wmTeam);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 更新
|
|
|
*
|
|
@@ -114,6 +151,38 @@ public class WmTeamController {
|
|
|
if (count > 0) {
|
|
|
return R.failed("团队名称已存在");
|
|
|
}
|
|
|
+ // 校验被移除的人员是否正在做任务
|
|
|
+ WmTeam queryTeam = wmTeamService.getById(wmTeam.getId());
|
|
|
+ if (ArrayUtil.isNotEmpty(queryTeam.getMember())) {
|
|
|
+ // 计算单差集,找到被删除的成员
|
|
|
+ List<String> deletedMemberList =
|
|
|
+ CollectionUtil.subtractToList(CollectionUtil.toList(queryTeam.getMember()), CollectionUtil.toList(wmTeam.getMember()));
|
|
|
+ if (CollectionUtil.isNotEmpty(deletedMemberList)) {
|
|
|
+ // 查询被删除的人员正在做的任务
|
|
|
+ List<WmScorePackage> scorePackageList = wmScorePackageService.list(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
+ .le(WmScorePackage::getScorePackageStatus, ScorePackageStatusEnum.IN_PROGRESS.val())
|
|
|
+ .eq(WmScorePackage::getPackageUserScope, wmTeam.getId())
|
|
|
+ .eq(WmScorePackage::getDeptId, wmTeam.getDeptId())
|
|
|
+ .eq(WmScorePackage::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
+ .eq(WmScorePackage::getEnableFlag, EnableEnum.ENABLE.val()));
|
|
|
+ if (CollectionUtil.isNotEmpty(scorePackageList)) {
|
|
|
+ List<String> packageIdList = scorePackageList.stream().map(WmScorePackage::getId).collect(Collectors.toList());
|
|
|
+ List<WmScorePackageStatus> packageStatusList = wmScorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery()
|
|
|
+ .in(WmScorePackageStatus::getPackageId, packageIdList)
|
|
|
+ .in(WmScorePackageStatus::getUserId, deletedMemberList)
|
|
|
+ .eq(WmScorePackageStatus::getStatus, PackageStatusEnum.APPROVED.val())
|
|
|
+ .eq(WmScorePackageStatus::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
+ .eq(WmScorePackageStatus::getEnableFlag, EnableEnum.ENABLE.val()));
|
|
|
+ if (CollectionUtil.isNotEmpty(packageStatusList)) {
|
|
|
+ Set<String> statusUserSet = packageStatusList.stream().map(WmScorePackageStatus::getUserId).collect(Collectors.toSet());
|
|
|
+ List<SysUser> sysUsers = sysUserMapper.selectBatchIds(statusUserSet);
|
|
|
+ List<String> userNameList = sysUsers.stream().map(SysUser::getRealname).collect(Collectors.toList());
|
|
|
+ return R.failed(String.format("正在团队中做任务的人员'%s',不能从团队中移除", String.join(",", userNameList)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (wmTeam.getLeader() != null) {
|
|
|
wmTeam.setEnableFlag(EnableEnum.ENABLE.val());
|
|
|
}
|
|
@@ -134,7 +203,8 @@ public class WmTeamController {
|
|
|
public R<?> dissolve(@PathVariable("id") Integer id) {
|
|
|
// 查询团队是否还有任务在进行
|
|
|
int packageCount = wmScorePackageService.count(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
- .ge(WmScorePackage::getPackageUserScope, "1000")
|
|
|
+ .eq(WmScorePackage::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
+ .eq(WmScorePackage::getEnableFlag, EnableEnum.ENABLE.val())
|
|
|
.eq(WmScorePackage::getPackageUserScope, id)
|
|
|
.le(WmScorePackage::getScorePackageStatus, ScorePackageStatusEnum.IN_PROGRESS.val()));
|
|
|
if (packageCount > 0) {
|
|
@@ -165,7 +235,8 @@ public class WmTeamController {
|
|
|
}
|
|
|
|
|
|
Map<String, List<WmTeamExcelModel>> excelMap = teamExcelModelList.stream()
|
|
|
- .filter(wmTeamExcelModel -> StrUtil.isNotBlank(wmTeamExcelModel.getId()))
|
|
|
+ .filter(wmTeamExcelModel ->
|
|
|
+ !StrUtil.isAllBlank(wmTeamExcelModel.getId(), wmTeamExcelModel.getUsername(), wmTeamExcelModel.getRealname()))
|
|
|
.map(wmTeamExcelModel -> {
|
|
|
wmTeamExcelModel.setId(StrUtil.trim(wmTeamExcelModel.getId()));
|
|
|
wmTeamExcelModel.setRealname(StrUtil.trim(wmTeamExcelModel.getRealname()));
|
|
@@ -295,14 +366,30 @@ public class WmTeamController {
|
|
|
/**
|
|
|
* 查询团队可选择人员
|
|
|
*
|
|
|
+ * @param deptId 部门id
|
|
|
* @param teamId 团队id
|
|
|
* @param realNameOrPhone 姓名或手机号
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/list-selectable-user")
|
|
|
- public R<Map<String, Object>> listSelectableUser(@RequestParam(value = "teamId", required = false) Integer teamId,
|
|
|
+ public R<Map<String, Object>> listSelectableUser(@RequestParam(value = "deptId", required = false) Integer deptId,
|
|
|
+ @RequestParam(value = "teamId", required = false) Integer teamId,
|
|
|
+ @RequestParam(value = "realNameOrPhone", required = false) String realNameOrPhone) {
|
|
|
+ Map<String, Object> map = wmTeamService.listSelectableUser(deptId, teamId, realNameOrPhone);
|
|
|
+ return R.ok(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询团队可选择人员-搜索
|
|
|
+ *
|
|
|
+ * @param deptId 部门id
|
|
|
+ * @param realNameOrPhone 姓名或手机号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/list-selectable-user-for-search")
|
|
|
+ public R<Map<String, Object>> listSelectableUserForSearch(@RequestParam(value = "deptId", required = false) Integer deptId,
|
|
|
@RequestParam(value = "realNameOrPhone", required = false) String realNameOrPhone) {
|
|
|
- Map<String, Object> map = wmTeamService.listSelectableUser(teamId, realNameOrPhone);
|
|
|
+ Map<String, Object> map = wmTeamService.listSelectableUser(deptId, null, realNameOrPhone);
|
|
|
return R.ok(map);
|
|
|
}
|
|
|
|