Commit 57c36ad0 authored by zhangqingle's avatar zhangqingle

修改资料查询接口,修改指派时查询部门下所有人

parent 2081ddca
...@@ -637,9 +637,8 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -637,9 +637,8 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
* @param lessonId * @param lessonId
* @return * @return
*/ */
@Update("<script>select count(1) from b_lesson_person where 1=1 " + @Select("<script>select count(1) from b_lesson_person where 1=1 " +
" and del_flag != 1 and flag = 1 " + " and del_flag != 1 and flag = 1 " +
" and is_finish != 0 " +
" and lesson_id = #{lessonId} </script>" ) " and lesson_id = #{lessonId} </script>" )
int personNumberCount(String lessonId); int personNumberCount(String lessonId);
......
...@@ -35,6 +35,7 @@ import org.springframework.stereotype.Service; ...@@ -35,6 +35,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.beans.Transient;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.*; import java.util.*;
...@@ -578,15 +579,10 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -578,15 +579,10 @@ public class BLessonServiceImpl implements BLessonService {
} }
//获取部门中人员 //获取部门中人员
List<String> inDepartPerson = new ArrayList<>(); List<String> deptList = asList(org.apache.commons.lang.StringUtils.split(appointLessonDTO.getAppointDepart(), ","));
List<GetAllRspDTO> departPersons = cotactApiRequestClient.getUserByDeptIds(appointLessonDTO.getCorpId(),appointLessonDTO.getAppointDepart()); Set<String> deptSet = new HashSet<>(deptList);
if (departPersons != null && departPersons.size()>0){ List<String> inDepartPerson = cotactApiRequestClient.getSubUserIdsByDeptIds(appointLessonDTO.getCorpId(),deptSet);
departPersons.forEach(departPerson->{
inDepartPerson.add(departPerson.getId());
});
}
//------------- //-------------
// if (StringUtils.isEmpty(appointLessonDTO.getAppointPerson()) && StringUtils.isEmpty(appointLessonDTO.getAppointDepart())) { // if (StringUtils.isEmpty(appointLessonDTO.getAppointPerson()) && StringUtils.isEmpty(appointLessonDTO.getAppointDepart())) {
// throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE); // throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE);
// } // }
...@@ -669,14 +665,14 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -669,14 +665,14 @@ public class BLessonServiceImpl implements BLessonService {
//从学生Id中删除已更新的学生id //从学生Id中删除已更新的学生id
userIds.removeAll(inLessonIds); userIds.removeAll(inLessonIds);
} }
//如果为培训的话 判断剩余学生加已有学生总数超过最大数 抛异常 // //如果为培训的话 判断剩余学生加已有学生总数超过最大数 抛异常
if ("1".equals(bLesson.getLessonType())){ // if ("1".equals(bLesson.getLessonType())){
//查找已报名总人数 // //查找已报名总人数
int personNumber = bLessonRepository.personNumberCount(bLesson.getBusinessId()); // int personNumber = bLessonRepository.personNumberCount(bLesson.getBusinessId());
if (personNumber + userIds.size() > Integer.parseInt(bLesson.getMaxApplyPerson())){ // if (personNumber + userIds.size() > Integer.parseInt(bLesson.getMaxApplyPerson())){
throw new ServiceException("培训人数上限"+bLesson.getMaxApplyPerson()+",现已超出"+String.valueOf(Integer.parseInt(bLesson.getMaxApplyPerson())+"人,请重新选择")); // throw new ServiceException("培训人数上限"+bLesson.getMaxApplyPerson()+",现已超出"+String.valueOf(Integer.parseInt(bLesson.getMaxApplyPerson())+"人,请重新选择"));
} // }
} // }
//剩余学生添加至b_lesson_person表 //剩余学生添加至b_lesson_person表
List<BLessonPerson> bLessonPersonOthers = new ArrayList<>(); List<BLessonPerson> bLessonPersonOthers = new ArrayList<>();
...@@ -702,6 +698,12 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -702,6 +698,12 @@ public class BLessonServiceImpl implements BLessonService {
int line; int line;
if (bLessonPersonOthers != null && bLessonPersonOthers.size() > 0){ if (bLessonPersonOthers != null && bLessonPersonOthers.size() > 0){
if ("1".equals(bLesson.getLessonType())){
//指派培训
line = trainInsert("1",bLesson,bLessonPersonOthers);
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
}
//指派课程
line = bLessonPersonRepository.insertList(bLessonPersonOthers); line = bLessonPersonRepository.insertList(bLessonPersonOthers);
}else { }else {
line = 1; line = 1;
...@@ -935,13 +937,13 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -935,13 +937,13 @@ public class BLessonServiceImpl implements BLessonService {
//step 1 查询数 x 当前报名数 y 总数 //step 1 查询数 x 当前报名数 y 总数
synchronized (this) { synchronized (this) {
Map<String, Object> xy = bLessonPersonRepository.selecTraningNum(lessonId); // Map<String, Object> xy = bLessonPersonRepository.selecTraningNum(lessonId);
//
int x = Integer.parseInt(String.valueOf(xy.get("x"))); // int x = Integer.parseInt(String.valueOf(xy.get("x")));
int y = Integer.parseInt(String.valueOf(xy.get("y"))); // int y = Integer.parseInt(String.valueOf(xy.get("y")));
if (y > 0 && x >= y) { // if (y > 0 && x >= y) {
throw new ServiceException(ResultServiceEnums.PERSON_MAX); // throw new ServiceException(ResultServiceEnums.PERSON_MAX);
} // }
//step2 判断该用户是否被指派该培训或已经报名 //step2 判断该用户是否被指派该培训或已经报名
person = bLessonPersonRepository.getAppointInTraining(lessonId, curUser.getUserId()); person = bLessonPersonRepository.getAppointInTraining(lessonId, curUser.getUserId());
if (person != null) { if (person != null) {
...@@ -954,6 +956,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -954,6 +956,7 @@ public class BLessonServiceImpl implements BLessonService {
person.setIsApply("1"); person.setIsApply("1");
return bLessonPersonRepository.updateLessonPersonByUserId(person); return bLessonPersonRepository.updateLessonPersonByUserId(person);
} else { } else {
List<BLessonPerson> bLessonPersons = new ArrayList<>();
UserUtil.setCurrentPersistOperation(bLessonPerson); UserUtil.setCurrentPersistOperation(bLessonPerson);
bLessonPerson.setPersonId(curUser.getUserId()); bLessonPerson.setPersonId(curUser.getUserId());
bLessonPerson.setLessonId(lessonId); bLessonPerson.setLessonId(lessonId);
...@@ -962,8 +965,11 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -962,8 +965,11 @@ public class BLessonServiceImpl implements BLessonService {
bLessonPerson.setTrainIsSign("0"); bLessonPerson.setTrainIsSign("0");
bLessonPerson.setApplyDate(new Date()); bLessonPerson.setApplyDate(new Date());
bLessonPerson.setRemarks(""); bLessonPerson.setRemarks("");
bLessonPersons.add(bLessonPerson);
//插入 用户id 、培训id、指派状态、报名状态、培训状态、报名时间 、通用字段 //插入 用户id 、培训id、指派状态、报名状态、培训状态、报名时间 、通用字段
return bLessonPersonRepository.insert(bLessonPerson); // int line = bLessonPersonRepository.insert(bLessonPerson);
int line = trainInsert("0",bLesson,bLessonPersons);
return line;
} }
} }
...@@ -1189,4 +1195,31 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1189,4 +1195,31 @@ public class BLessonServiceImpl implements BLessonService {
} }
} }
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
synchronized int trainInsert(String type, BLesson bLesson, List<BLessonPerson> bLessonPersons){
if ("0".equals(type)){
Map<String, Object> xy = bLessonPersonRepository.selecTraningNum(bLesson.getBusinessId());
int x = Integer.parseInt(String.valueOf(xy.get("x")));
int y = Integer.parseInt(String.valueOf(xy.get("y")));
if (y > 0 && x >= y) {
throw new ServiceException(ResultServiceEnums.PERSON_MAX);
}
return bLessonPersonRepository.insert(bLessonPersons.get(0));
}
if ("1".equals(type)){
//如果为培训的话 判断剩余学生加已有学生总数超过最大数 抛异常
if ("1".equals(bLesson.getLessonType())){
//查找已报名总人数
int personNumber = bLessonRepository.personNumberCount(bLesson.getBusinessId());
if (Integer.parseInt(bLesson.getMaxApplyPerson()) > 0 && personNumber + bLessonPersons.size() > Integer.parseInt(bLesson.getMaxApplyPerson())){
throw new ServiceException("培训人数上限"+bLesson.getMaxApplyPerson()+",现已超出"+String.valueOf(personNumber + bLessonPersons.size()- Integer.parseInt(bLesson.getMaxApplyPerson())+"人,请重新选择"));
}
return bLessonPersonRepository.insertList(bLessonPersons);
}
}
return 0;
}
} }
...@@ -6,6 +6,7 @@ import io.swagger.annotations.Api; ...@@ -6,6 +6,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.bmaterial.dto.FindDTO;
import org.rcisoft.common.controller.PaginationController; import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.common.model.GridModel; import org.rcisoft.common.model.GridModel;
import org.rcisoft.sys.user.bean.CurUser; import org.rcisoft.sys.user.bean.CurUser;
...@@ -46,10 +47,10 @@ public class BMaterialController extends PaginationController<BMaterial> { ...@@ -46,10 +47,10 @@ public class BMaterialController extends PaginationController<BMaterial> {
} }
@ApiOperation(value="1302查看我的资料集合", notes="查看我的资料集合") @ApiOperation(value="1302分页查看我的资料集合", notes="分页查看我的资料集合")
@GetMapping(value = "/queryMyBMaterialByPagination") @GetMapping(value = "/queryMyBMaterialByPagination")
public Result queryMyBMaterialByPagination(CurUser curUser,BindingResult bindingResult) { public Result queryMyBMaterialByPagination(CurUser curUser, @Valid FindDTO findDTO, BindingResult bindingResult) {
bMaterialServiceImpl.queryMyBMaterialByPagination(getPaginationUtility(), curUser); bMaterialServiceImpl.queryMyBMaterialByPagination(getPaginationUtility(), findDTO);
GridModel gridModel = getGridModelResponse(); GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
......
...@@ -3,6 +3,7 @@ package org.rcisoft.business.bmaterial.dao; ...@@ -3,6 +3,7 @@ package org.rcisoft.business.bmaterial.dao;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import org.rcisoft.business.bfile.entity.BTrainFile; import org.rcisoft.business.bfile.entity.BTrainFile;
import org.rcisoft.business.bmaterial.dto.DelMoreDTO; import org.rcisoft.business.bmaterial.dto.DelMoreDTO;
import org.rcisoft.business.bmaterial.dto.FindDTO;
import org.rcisoft.core.base.BaseMapper; import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.business.bmaterial.entity.BMaterial; import org.rcisoft.business.bmaterial.entity.BMaterial;
import org.rcisoft.sys.user.bean.CurUser; import org.rcisoft.sys.user.bean.CurUser;
...@@ -40,17 +41,28 @@ public interface BMaterialRepository extends BaseMapper<BMaterial> { ...@@ -40,17 +41,28 @@ public interface BMaterialRepository extends BaseMapper<BMaterial> {
"</script>") "</script>")
int insertMaterial(BMaterial bMaterial); int insertMaterial(BMaterial bMaterial);
@Select("<script>select bm.*,bl.lesson_name lessonName, bl.lesson_type lessonType from b_material bm " + @Select("<script>select bm.*,bl.lesson_name lessonName, bl.lesson_type lessonType, " +
" CONCAT(if(bl.lesson_type='0','课程:','培训:'),bl.lesson_name) source " +
" from b_material bm" +
" left join b_chapter bc on bm.chapter_id = bc.business_id " + " left join b_chapter bc on bm.chapter_id = bc.business_id " +
" left join b_lesson bl on bc.lesson_id = bl.business_id " + " left join b_lesson bl on bc.lesson_id = bl.business_id " +
" where 1=1 " + " where 1=1 " +
" and bm.del_flag != 1 and bm.flag = 1 " + " and bm.del_flag != 1 and bm.flag = 1 " +
" and bc.del_flag != 1 and bc.flag = 1 " + // " and bc.del_flag != 1 and bc.flag = 1 " +
" and bl.del_flag != 1 and bl.flag = 1 " + // " and bl.del_flag != 1 and bl.flag = 1 " +
" and bm.create_by = #{userId} "+ " <if test=\"param.uploadType != null and param.uploadType != ''\">and bm.upload_type = #{param.uploadType}</if>" +
" and bm.create_by = #{param.userId} "+
"<if test= \" param.typeSort !=null and param.typeSort !='' and param.typeSort =='0'.toString()\"> ORDER BY bm.type DESC </if> "+
"<if test= \" param.typeSort !=null and param.typeSort !='' and param.typeSort =='1'.toString()\"> ORDER BY bm.type ASC </if> "+
"<if test= \" param.sizeSort !=null and param.sizeSort !='' and param.sizeSort =='0'.toString()\"> ORDER BY bm.file_size DESC </if> "+
"<if test= \" param.sizeSort !=null and param.sizeSort !='' and param.sizeSort =='1'.toString()\"> ORDER BY bm.file_size ASC </if> "+
"<if test= \" param.sourceSort !=null and param.sourceSort !='' and param.sourceSort =='0'.toString()\"> ORDER BY source DESC </if> "+
"<if test= \" param.sourceSort !=null and param.sourceSort !='' and param.sourceSort =='1'.toString()\"> ORDER BY source ASC </if> "+
"<if test= \" param.dateSort !=null and param.dateSort !='' and param.dateSort =='0'.toString()\"> ORDER BY bm.create_date DESC </if> "+
"<if test= \" param.dateSort !=null and param.dateSort !='' and param.dateSort =='1'.toString()\"> ORDER BY bm.create_date ASC </if> "+
"</script>") "</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<BMaterial> queryMyBMaterialByPagination(CurUser curUser); List<BMaterial> queryMyBMaterialByPagination(@Param("param") FindDTO findDTO);
/** /**
......
package org.rcisoft.business.bmaterial.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class FindDTO {
@ApiModelProperty(value = "上传类型 0 保存 1 上传")
private String uploadType;
@ApiModelProperty(value = "类型排序 0 降序 1 升序")
private String typeSort;
@ApiModelProperty(value = "文件大小排序 0 降序 1 升序")
private String sizeSort;
@ApiModelProperty(value = "来源排序 0 降序 1 升序")
private String sourceSort;
@ApiModelProperty(value = "保存、上传时间排序 0 降序 1 升序")
private String dateSort;
private String corpId;
private String userId;
}
...@@ -49,6 +49,10 @@ public class BMaterial extends IdEntity<BMaterial> { ...@@ -49,6 +49,10 @@ public class BMaterial extends IdEntity<BMaterial> {
@Transient @Transient
private String lessonType; private String lessonType;
@ApiModelProperty(value = "来源")
@Transient
private String source;
@Transient @Transient
private String corpId; private String corpId;
......
package org.rcisoft.business.bmaterial.service; package org.rcisoft.business.bmaterial.service;
import org.rcisoft.business.bmaterial.dto.FindDTO;
import org.rcisoft.business.bmaterial.entity.BMaterial; import org.rcisoft.business.bmaterial.entity.BMaterial;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
...@@ -57,11 +58,11 @@ public interface BMaterialService { ...@@ -57,11 +58,11 @@ public interface BMaterialService {
/** /**
* 分页查询 (我的资料) * 分页查询 (我的资料)
* @param curUser * @param findDTO
* @return * @return
*/ */
List<BMaterial> queryMyBMaterialByPagination(PageUtil<BMaterial> paginationUtility, List<BMaterial> queryMyBMaterialByPagination(PageUtil<BMaterial> paginationUtility,
CurUser curUser); FindDTO findDTO);
......
...@@ -2,6 +2,7 @@ package org.rcisoft.business.bmaterial.service.impl; ...@@ -2,6 +2,7 @@ package org.rcisoft.business.bmaterial.service.impl;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.rcisoft.business.bmaterial.dto.DelMoreDTO; import org.rcisoft.business.bmaterial.dto.DelMoreDTO;
import org.rcisoft.business.bmaterial.dto.FindDTO;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
...@@ -118,11 +119,11 @@ public class BMaterialServiceImpl implements BMaterialService { ...@@ -118,11 +119,11 @@ public class BMaterialServiceImpl implements BMaterialService {
/** /**
* 分页查询 bMaterial(我的资料) * 分页查询 bMaterial(我的资料)
* @param curUser * @param findDTO
* @return * @return
*/ */
public List<BMaterial> queryMyBMaterialByPagination(PageUtil<BMaterial> paginationUtility, public List<BMaterial> queryMyBMaterialByPagination(PageUtil<BMaterial> paginationUtility,
CurUser curUser){ FindDTO findDTO){
return bMaterialRepository.queryMyBMaterialByPagination(curUser); return bMaterialRepository.queryMyBMaterialByPagination(findDTO);
} }
} }
...@@ -231,6 +231,15 @@ public interface ContactFeignClient { ...@@ -231,6 +231,15 @@ public interface ContactFeignClient {
@RequestParam("zxClientType") String zxClientType, @RequestParam("zxClientType") String zxClientType,
@RequestParam("zxAccountId") Long zxAccountId); @RequestParam("zxAccountId") Long zxAccountId);
/**
* 根据部门ids 获取部门及子部门多有人员id(未去重)
* 获取的id与s_suer中businessId不匹配 需使用accountId 查询出 businessId
*/
@RequestMapping(value = "/user/get_sub_userIds_by_dept_ids",method = RequestMethod.POST)
Ret<List<String>> getSubUserIdsByDeptIds(@RequestBody GetSubUserIdsByDeptIdsReqDTO getSubUserIdsByDeptIdsReqDTO,
@RequestParam("zxClientType") String zxClientType,
@RequestParam("zxAccountId") Long zxAccountId);
} }
package org.rcisoft.common.util.feignDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.core.annotation.Order;
import java.util.List;
@Data
public class GetSubUserIdsByDeptIdsReqDTO {
@ApiModelProperty(value = "企业id", position = 1)
@Order(1)
private Integer corpId;
@ApiModelProperty(value = "部门id集合(可选)", position = 2)
@Order(3)
private List<Integer> deptIds;
}
...@@ -531,6 +531,26 @@ public class MTCotactApiRequestClient { ...@@ -531,6 +531,26 @@ public class MTCotactApiRequestClient {
return contactFeignClient.corpGetManager(corpId,sysLevel,zxClientType,zxAccountId).getData(); return contactFeignClient.corpGetManager(corpId,sysLevel,zxClientType,zxAccountId).getData();
} }
/**
* 根据多个部门id的Set集合获取部门内人员
* @param corpId
* @param deptIdSet
* @return
*/
public List<String> getSubUserIdsByDeptIds(String corpId,Set<String> deptIdSet){
if(deptIdSet == null || deptIdSet.size() < 1){
return new ArrayList<>();
}
GetSubUserIdsByDeptIdsReqDTO getSubUserIdsByDeptIdsReqDTO = new GetSubUserIdsByDeptIdsReqDTO();
getSubUserIdsByDeptIdsReqDTO.setCorpId(Integer.parseInt(corpId));
List<Integer> deptIdList = new ArrayList<>();
for (String deptId : deptIdSet) {
deptIdList.add(Integer.parseInt(deptId));
}
getSubUserIdsByDeptIdsReqDTO.setDeptIds(deptIdList);
return contactFeignClient.getSubUserIdsByDeptIds(getSubUserIdsByDeptIdsReqDTO,zxClientType,zxAccountId).getData();
}
/** /**
* 刷新token * 刷新token
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment