组织架构部分修改

master
shijie 4 years ago
parent b2b5a37aca
commit eb3975b6c9
  1. 3
      src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java
  2. 26
      src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java
  3. 3
      src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java
  4. 20
      src/main/java/com/yipin/liuwanr/service/StaffProfessionalArchitectureService.java

@ -105,13 +105,14 @@ public class StaffGradeController {
Response resp = new Response();
Integer staffGradeId = staffGrade.getStaffGradeId();
HashMap<String, Object> ret = new HashMap<>();
HashMap<String, Object> ret2 = new HashMap<>();
if (staffGradeId==null) {
resp.setStatus(300);
resp.setErrmessage("Parameter Invalid");
} else {
List<Integer> userIds = staffGradeService.queryUserIdsByGradeId(staffGradeId);
if(userIds.size()>0){
ret = staffGradeService.deleteStaffGrade(userIds);
ret2 = staffGradeService.deleteStaffGrade(userIds);
ret = staffGradeService.deleteStaffGradePs(staffGradeId);
}else{//如果组织架构下面没有员工,则只删除组织架构
ret = staffGradeService.deleteStaffGradePs(staffGradeId);

@ -2,10 +2,8 @@ package com.yipin.liuwanr.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.yipin.liuwanr.entity.Student;
import org.apache.ibatis.annotations.*;
import com.yipin.liuwanr.entity.Staff;
import com.yipin.liuwanr.entity.StaffGrade;
@ -21,12 +19,14 @@ public interface StaffGradeMapper {
"</script> "})
List<StaffGrade> queryStaffGrade(Integer staffProfessionalArchitectureId);
// @Update("UPDATE staff_grade SET isdel = 1 where staffGradeId = #{staffGradeId}")
@Update("UPDATE staff s,hr_user_info u SET s.isdel = 1,u.isdel = 1 WHERE s.userId = u.userId AND s.userId IN" +
"(<foreach collection='userIds' item='userId' separator=','>" +
"#{userId}" +
"</foreach>)")
void deleteStaffGrade(List<Integer> userIds);
@Update({"<script>",
"UPDATE staff s,hr_user_info u SET s.isdel = 1,u.isdel = 1 WHERE s.userId = u.userId AND s.userId IN"
+ "<foreach collection='userIds' item='stu' open='(' separator=',' close=')'>"
+ "#{stu}"
+ "</foreach> ",
"</script>"})
void deleteStaffGrade(@Param("userIds") List<Integer> userIds);
@Update("UPDATE staff_grade SET isdel = 1 where staffGradeId = #{staffGradeId}")
void deleteStaffGradePs(Integer staffGradeId);
@ -41,4 +41,10 @@ public interface StaffGradeMapper {
@Select("select userId from staff where staffGradeId =#{staffGradeId} and isdel = 0")
List<Integer> queryUserIdsByGradeId(Integer staffGradeId);
@Update("UPDATE staff_grade SET isdel = 1 where staffProfessionalArchitectureId = #{staffProfessionalArchitectureId}")
void delStaffGradeByArchId(Integer staffProfessionalArchitectureId);
@Update("UPDATE staff_grade SET isdel = 1 where staffProfessionalArchitectureId = #{staffProfessionalArchitectureId}")
void deleteStaffArch(Integer staffProfessionalArchitectureId);
}

@ -123,4 +123,7 @@ public interface StaffMapper {
@Select("select schoolId,staffId FROM staff WHERE userId = #{userId} AND isdel = 0 GROUP BY schoolId ORDER BY staffId limit 1")
Integer querySchoolId(Integer userId);
@Select("select userId from staff where staffProfessionalArchitectureId =#{staffProfessionalArchitectureId} and isdel = 0")
List<Integer> queryUserIdsByArchId(Integer staffProfessionalArchitectureId);
}

@ -1,7 +1,10 @@
package com.yipin.liuwanr.service;
import java.util.HashMap;
import java.util.List;
import com.yipin.liuwanr.mapper.StaffGradeMapper;
import com.yipin.liuwanr.mapper.StaffMapper;
import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -17,6 +20,11 @@ public class StaffProfessionalArchitectureService {
@Autowired
private StaffProfessionalArchitectureMapper staffProfessionalArchitectureMapper;
@Autowired
private StaffGradeMapper staffGradeMapper;
@Autowired
private StaffMapper staffMapper;
public HashMap<String, Object> addStaffProfessionalArchitecture(StaffProfessionalArchitecture staffProfessionalArchitecture){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
@ -78,7 +86,19 @@ public class StaffProfessionalArchitectureService {
public HashMap<String, Object> deleteStaffProfessionalArchitecture(Integer staffProfessionalArchitectureId){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
//删除员工专业一级组织架构
staffProfessionalArchitectureMapper.deleteStaffProfessionalArchitecture(staffProfessionalArchitectureId);
//根据一级架构id删除staff_grade表中二级组织架构(假删)
staffGradeMapper.delStaffGradeByArchId(staffProfessionalArchitectureId);
//根据staffProfessionalArchitectureId查询staff表中的userId,然后调用批量删除员工信息接口
List<Integer> userIds =staffMapper.queryUserIdsByArchId(staffProfessionalArchitectureId);
if(userIds.size()>0){//说明年级架构下面存在用户
staffGradeMapper.deleteStaffGrade(userIds);
staffGradeMapper.deleteStaffArch(staffProfessionalArchitectureId);
}else{//如果组织架构下面没有员工,则只删除组织架构
staffGradeMapper.deleteStaffArch(staffProfessionalArchitectureId);
}
resp.put("retcode", 200);
} catch (RuntimeException e) {
logger.error(e.getMessage());

Loading…
Cancel
Save