|
@@ -29,6 +29,7 @@ import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
import com.jeeplus.utils.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
@@ -359,6 +360,15 @@ public class StaffUserInfoService {
|
|
|
*/
|
|
|
public RegularApply findByApplyId(String id) {
|
|
|
RegularApply regularApply=staffUserInfoMapper.findByApplyId(id);
|
|
|
+ // 查询附件信息
|
|
|
+ List<WorkAttachmentInfo> files = staffUserInfoMapper.findFiles(id);
|
|
|
+ if (CollectionUtils.isNotEmpty(files)) {
|
|
|
+ for (WorkAttachmentInfo i : files) {
|
|
|
+ i.setCreateBy(SpringUtil.getBean ( IUserApi.class ).getById(i.getBy()));
|
|
|
+ }
|
|
|
+ regularApply.setFiles(files);
|
|
|
+ }
|
|
|
+
|
|
|
return regularApply;
|
|
|
}
|
|
|
|
|
@@ -368,6 +378,21 @@ public class StaffUserInfoService {
|
|
|
* @return
|
|
|
*/
|
|
|
public RegularApply saveApplyForm(RegularApply regularApply) {
|
|
|
+ RegularApply applyId = findByApplyId(regularApply.getId());
|
|
|
+ if ("2".equals(regularApply.getStatus())){
|
|
|
+ if (ObjectUtil.isNotEmpty(applyId)){
|
|
|
+ //判断此次转正申请是否是第一次发起
|
|
|
+ //不是第一次发起则清空对应的内容并删除附件
|
|
|
+ if ("5".equals(applyId.getStatus()) && "1".equals(applyId.getIsPass()) && "0".equals(applyId.getIsEmploy()) && "0".equals(applyId.getIsPostpone())){
|
|
|
+ applyId.setIsEmploy("");
|
|
|
+ applyId.setIsPass("");
|
|
|
+ applyId.setIsPostpone("");
|
|
|
+ applyId.setReason("");
|
|
|
+ regularApplyMapper.updateById(applyId);
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).deleteById(applyId.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//获取当前登录人信息
|
|
|
UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
|
|
|
RegularApply apply = new RegularApply();
|
|
@@ -376,70 +401,185 @@ public class StaffUserInfoService {
|
|
|
apply.setUpdateById(userDTO.getId());
|
|
|
if (StringUtils.isNotBlank(regularApply.getId())){
|
|
|
regularApplyMapper.updateById(apply);
|
|
|
+ // 修改附件信息列表
|
|
|
+ if (CollectionUtils.isNotEmpty(regularApply.getFiles())) {
|
|
|
+ updateFiles(regularApply.getFiles(), userDTO, apply.getId());
|
|
|
+ }
|
|
|
}else {
|
|
|
+ apply.setId(UUID.randomUUID().toString().replace("-",""));
|
|
|
regularApplyMapper.insert(apply);
|
|
|
+ // 保存附件列表信息
|
|
|
+ if (CollectionUtils.isNotEmpty(regularApply.getFiles())) {
|
|
|
+ saveFiles(regularApply.getFiles(), userDTO, apply.getId());
|
|
|
+ }
|
|
|
}
|
|
|
- RegularApply applyId = findByApplyId(regularApply.getId());
|
|
|
- //查询入职表中的信息
|
|
|
- StaffUserInfoDTO infoDTO = findById(applyId.getInfoId());
|
|
|
- //判断是否通过
|
|
|
- if (StringUtils.isNotBlank(regularApply.getIsPass()) ){
|
|
|
- if (regularApply.getIsPass().equals("1")){
|
|
|
- //不通过则去判断是否留用
|
|
|
- if (StringUtils.isNotBlank(regularApply.getIsEmploy())){
|
|
|
- //不通过也不留用同时状态为5 则将该员工账号冻结
|
|
|
- if (regularApply.getIsPass().equals("1")&& regularApply.getIsEmploy().equals("1") && regularApply.getStatus().equals("5")){
|
|
|
- UserDTO dto = new UserDTO();
|
|
|
- dto.setLoginFlag("0");
|
|
|
- dto.setId(infoDTO.getUserId());
|
|
|
- SpringUtil.getBean(IUserApi.class).saveOrUpdate(dto);
|
|
|
- }
|
|
|
- if (regularApply.getIsPass().equals("1") && regularApply.getIsEmploy().equals("0") && regularApply.getStatus().equals("5")){
|
|
|
- //不通过 留用 但发起人驳回的情况下获取当前登录人所属岗位是否是人事部 若是人事部则冻结账号
|
|
|
- for (PostDTO postDTO : userDTO.getPostDTOList()) {
|
|
|
- if ("人事部".equals(postDTO.getId()) && regularApply.getStatus().equals("5")){
|
|
|
+ if(StringUtils.isNotBlank(regularApply.getId())){
|
|
|
+ if (ObjectUtil.isNotEmpty(applyId)){
|
|
|
+ //查询入职表中的信息
|
|
|
+ StaffUserInfoDTO infoDTO = findById(applyId.getInfoId());
|
|
|
+ //判断是否通过
|
|
|
+ if (StringUtils.isNotBlank(regularApply.getIsPass()) ){
|
|
|
+ if (regularApply.getIsPass().equals("1")){
|
|
|
+ //不通过则去判断是否留用
|
|
|
+ if (StringUtils.isNotBlank(regularApply.getIsEmploy())){
|
|
|
+ //不通过也不留用同时状态为5 则将该员工账号冻结
|
|
|
+ if (regularApply.getIsPass().equals("1")&& regularApply.getIsEmploy().equals("1") && regularApply.getStatus().equals("5")){
|
|
|
UserDTO dto = new UserDTO();
|
|
|
dto.setLoginFlag("0");
|
|
|
dto.setId(infoDTO.getUserId());
|
|
|
SpringUtil.getBean(IUserApi.class).saveOrUpdate(dto);
|
|
|
- break;
|
|
|
- }else if ("分管领导".equals(postDTO.getId()) && regularApply.getStatus().equals("5")){
|
|
|
- //否则的话则顺延一个月
|
|
|
- if (regularApply.getIsPostpone().equals("0")){
|
|
|
- StaffUserInfo staffUserInfo = new StaffUserInfo();
|
|
|
- staffUserInfo.setId(applyId.getInfoId());
|
|
|
- //获取到原本的试用期限
|
|
|
- int parseInt = Integer.parseInt(infoDTO.getTimeLimit());
|
|
|
- //顺延一个月
|
|
|
- int limit = parseInt+1;
|
|
|
- staffUserInfo.setTimeLimit(limit+"");
|
|
|
- //修改员工信息
|
|
|
- staffUserInfoMapper.updateById(staffUserInfo);
|
|
|
+ }
|
|
|
+ if (regularApply.getIsPass().equals("1") && regularApply.getIsEmploy().equals("0") && regularApply.getStatus().equals("5")){
|
|
|
+ //不通过 留用 但发起人驳回的情况下获取当前登录人所属岗位是否是人事部 若是人事部则冻结账号
|
|
|
+ for (PostDTO postDTO : userDTO.getPostDTOList()) {
|
|
|
+ if ("人事部".equals(postDTO.getId()) && regularApply.getStatus().equals("5")){
|
|
|
+ UserDTO dto = new UserDTO();
|
|
|
+ dto.setLoginFlag("0");
|
|
|
+ dto.setId(infoDTO.getUserId());
|
|
|
+ SpringUtil.getBean(IUserApi.class).saveOrUpdate(dto);
|
|
|
+ break;
|
|
|
+ }else if ("分管领导".equals(postDTO.getId()) && regularApply.getStatus().equals("5")){
|
|
|
+ //否则的话则顺延一个月
|
|
|
+ if (regularApply.getIsPostpone().equals("0")){
|
|
|
+ StaffUserInfo staffUserInfo = new StaffUserInfo();
|
|
|
+ staffUserInfo.setId(applyId.getInfoId());
|
|
|
+ //获取到原本的试用期限
|
|
|
+ int parseInt = Integer.parseInt(infoDTO.getTimeLimit());
|
|
|
+ //顺延一个月
|
|
|
+ int limit = parseInt+1;
|
|
|
+ staffUserInfo.setTimeLimit(limit+"");
|
|
|
+ //修改员工信息
|
|
|
+ staffUserInfoMapper.updateById(staffUserInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (regularApply.getStatus().equals("5")){
|
|
|
+ //将员工状态改为正式
|
|
|
+ StaffUserInfo staffUserInfo = new StaffUserInfo();
|
|
|
+ staffUserInfo.setOnJobStatus("2");
|
|
|
+ staffUserInfo.setId(applyId.getInfoId());
|
|
|
+ staffUserInfoMapper.updateById(staffUserInfo);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- }else {
|
|
|
- if (regularApply.getStatus().equals("5")){
|
|
|
- //将员工状态改为正式
|
|
|
- StaffUserInfo staffUserInfo = new StaffUserInfo();
|
|
|
- staffUserInfo.setOnJobStatus("2");
|
|
|
- staffUserInfo.setId(applyId.getInfoId());
|
|
|
- staffUserInfoMapper.updateById(staffUserInfo);
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return apply;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 修改附件信息
|
|
|
+ * @param list 待修改的附件列表
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
+ * @param id 关联id
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void updateFiles(List<WorkAttachmentInfo> list, UserDTO userDTO, String id) {
|
|
|
+ int j = 1;
|
|
|
+ String names = new String();
|
|
|
+ //表中存在,但是传过来不存在,说明已删除,表中数据也要删除
|
|
|
+ for (WorkAttachmentInfo dto : list) {
|
|
|
+ names = names + "," +dto.getUrl();
|
|
|
+ }
|
|
|
+ //查询保存的附件信息
|
|
|
+ List<WorkAttachmentInfo> infoList = staffUserInfoMapper.findList(id);
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(infoList)) {
|
|
|
+ for (WorkAttachmentInfo i : infoList) {
|
|
|
+ if (!names.contains(i.getUrl())) {
|
|
|
+// ossServiceMapper.deleteById(i.getId());
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).deleteById(i.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存信息
|
|
|
+ for (WorkAttachmentInfo dto : list) {
|
|
|
+ //判断是否存在
|
|
|
+ Integer isExit = staffUserInfoMapper.findIsExit(id, dto.getName());
|
|
|
+ if (isExit == 0) {
|
|
|
+ WorkAttachmentInfo i = new WorkAttachmentInfo();
|
|
|
+ //包含了url、size、name
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
+// i.getCreateBy().setId(userDTO.getId());
|
|
|
+ i.setCreateTime(new Date());
|
|
|
+// i.getUpdateBy().setId(userDTO.getId());
|
|
|
+ i.setUpdateTime(new Date());
|
|
|
+ i.setDelFlag(0);
|
|
|
+ i.setUrl(dto.getUrl());
|
|
|
+ //文件类型处理
|
|
|
+ List<String> strings = Arrays.asList(dto.getName().split("\\."));
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(strings)) {
|
|
|
+ i.setType(strings.get(1));
|
|
|
+ }
|
|
|
+ i.setAttachmentId(id);
|
|
|
+ i.setAttachmentName(dto.getName());
|
|
|
+ i.setAttachmentFlag("regular");
|
|
|
+ i.setFileSize(dto.getSize());
|
|
|
+ i.setSort(j);
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ String workAttachment = JSON.toJSONString((i));
|
|
|
+ String userDTOInfo = JSON.toJSONString((userDTO));
|
|
|
+ map.put("workAttachment",workAttachment);
|
|
|
+ map.put("userDTO",userDTOInfo);
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).insertWorkAttachment(map);
|
|
|
+// ossServiceMapper.insertWorkAttachment(i, userDTO);
|
|
|
+ j++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存附件信息
|
|
|
+ * @param list 待保存的附件列表
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
+ * @param id 关联id
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void saveFiles(List<WorkAttachmentInfo> list, UserDTO userDTO, String id) {
|
|
|
+ int j = 1;
|
|
|
+ for (WorkAttachmentInfo dto : list) {
|
|
|
+ WorkAttachmentInfo i = new WorkAttachmentInfo();
|
|
|
+ //包含了url、size、name
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
+// i.getCreateBy().setId(userDTO.getId());
|
|
|
+ i.setCreateTime(new Date());
|
|
|
+// i.getUpdateBy().setId(userDTO.getId());
|
|
|
+ i.setUpdateTime(new Date());
|
|
|
+ i.setDelFlag(0);
|
|
|
+ i.setUrl(dto.getUrl());
|
|
|
+ //文件类型处理
|
|
|
+ List<String> strings = Arrays.asList(dto.getName().split("\\."));
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(strings)) {
|
|
|
+ i.setType(strings.get(1));
|
|
|
+ }
|
|
|
+ i.setAttachmentId(id);
|
|
|
+ i.setAttachmentName(dto.getName());
|
|
|
+ i.setAttachmentFlag("regular");
|
|
|
+ i.setFileSize(dto.getSize());
|
|
|
+ i.setSort(j);
|
|
|
+// ossServiceMapper.insertWorkAttachment(i, userDTO);
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ String workAttachment = JSON.toJSONString((i));
|
|
|
+ String userDTOInfo = JSON.toJSONString((userDTO));
|
|
|
+ map.put("workAttachment",workAttachment);
|
|
|
+ map.put("userDTO",userDTOInfo);
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).insertWorkAttachment(map);
|
|
|
+ j++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 根据id修改转正状态
|
|
|
* @param regularApply
|
|
|
*/
|