Exemplo n.º 1
0
  @Override
  public Team save(SysUser caller, TeamParam param) {
    Team itemObj = assembleTeamObject(caller, param);
    Date currTime = DateUtil.getTime();
    String teamCode = DateUtil.formatData("yyyyMMddhhmmss", currTime);
    if (StringUtil.isEmptyString(itemObj.getId())) {
      // Create
      itemObj.setDeleted(0); // 正常状态,没有删除为0
      itemObj.setCreatedBy(caller);
      itemObj.setCorporation(caller.getCorporation());
      itemObj.setDepartment(caller.getStaff().getDepartment());
      itemObj.setCreatedAt(currTime);
      itemObj.setCode(teamCode); // 用当前时间作为编号
      itemObj = teamDao.save(itemObj);

    } else {
      // Update
      itemObj = teamDao.findById(Team.class, itemObj.getId());
      itemObj.setName(param.getName());
      itemObj.setDescription(param.getDescription());
      itemObj.setCreatedBy(caller);
      itemObj.setCreatedAt(currTime);
      itemObj = teamDao.update(itemObj);
      removeMembersByTeam(itemObj.getId()); // 修改一律删除人员
    }
    // 增加负责人
    if (param.getFzIds() != null && !param.getFzIds().isEmpty()) {
      saveMembers(caller, itemObj, param.getFzIds(), 1);
    }
    // 增加成员
    if (param.getMembersIds() != null && !param.getMembersIds().isEmpty()) {
      saveMembers(caller, itemObj, param.getMembersIds(), 0);
    }
    return itemObj;
  }
Exemplo n.º 2
0
  @Override
  public void saveMembers(SysUser caller, Team team, List<String> staffIds, int type) {

    Date now = DateUtil.getTime();
    for (String id : staffIds) {
      Members member = new Members();
      Staff staff = staffDao.findById(Staff.class, id);
      member.setStaff(staff);
      member.setDeleted(0);
      member.setMemberType(type);
      member.setRecorddate(now);
      member.setTeam(team);
      member.setRecorduser(caller.getUserName());
      membersDao.save(member);
    }
  }
Exemplo n.º 3
0
 @Override
 public void AddCandidateToReward(SysUser caller, String rewardId, CandidateRule candidateRule) {
   Reward reward = rewardDao.findById(Reward.class, rewardId);
   Date now = DateUtil.getTime();
   Set<Staff> staffs =
       candidateRuleLogic.getQualifiedStaffsFromCandidateRuleId(candidateRule.getId());
   for (Staff staff : staffs) {
     if (staff.isDeleted() != 1) {
       Candidate candidate = new Candidate();
       candidate.setReward(reward);
       candidate.setStaff(staff);
       candidate.setCreatedAt(now);
       candidate.setCreatedBy(caller);
       candidate.setLastModifiedAt(now);
       candidate.setLastModifiedBy(caller);
       candidateDao.save(candidate);
     }
   }
 }