|
@@ -0,0 +1,170 @@
|
|
|
+package com.jeeplus.human.enrollment.enrollmentRegistration.service;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.jeeplus.common.TokenProvider;
|
|
|
+import com.jeeplus.human.enrollment.enrollmentRegistration.domain.EnrollmentLaborContractInfo;
|
|
|
+import com.jeeplus.human.enrollment.enrollmentRegistration.domain.EnrollmentTrainingInfo;
|
|
|
+import com.jeeplus.human.enrollment.enrollmentRegistration.mapper.EnrollmentLaborContractInfoMapper;
|
|
|
+import com.jeeplus.human.enrollment.enrollmentRegistration.mapper.EnrollmentTrainingInfoMapper;
|
|
|
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
|
|
|
+import com.jeeplus.sys.feign.IUserApi;
|
|
|
+import com.jeeplus.sys.feign.IWorkAttachmentApi;
|
|
|
+import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
+import com.jeeplus.sys.service.dto.WorkAttachmentInfoDTO;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.UUID;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2023-10-17 8:57
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Transactional
|
|
|
+public class EnrollmentLaborContractInfoService extends ServiceImpl<EnrollmentLaborContractInfoMapper, EnrollmentLaborContractInfo> {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private EnrollmentLaborContractInfoMapper mapper;
|
|
|
+
|
|
|
+ public void deleteByRegistrationId(String id){
|
|
|
+ QueryWrapper<EnrollmentLaborContractInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("enrollment_registration_id",id);
|
|
|
+ mapper.delete(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ public EnrollmentLaborContractInfo findById(String id) throws Exception {
|
|
|
+ // 查询基础信息表
|
|
|
+ EnrollmentLaborContractInfo info = mapper.getById(id);
|
|
|
+ // 查询附件信息
|
|
|
+ List<WorkAttachmentInfoDTO> files = mapper.findDtos(id);
|
|
|
+ if (CollectionUtils.isNotEmpty(files)) {
|
|
|
+ info.setFiles(files);
|
|
|
+ }
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据关联id查询所有数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<EnrollmentLaborContractInfo> findByUserId(String id,String status) {
|
|
|
+ QueryWrapper<EnrollmentLaborContractInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotBlank(id)) {
|
|
|
+ queryWrapper.eq("user_id", id);
|
|
|
+ }
|
|
|
+ if(com.jeeplus.utils.StringUtils.isNotBlank(status)){
|
|
|
+ if("5".equals(status)){
|
|
|
+ queryWrapper.and(wrapper ->
|
|
|
+ wrapper.eq("status", "5").or().isNull("status").or().eq("status", "")
|
|
|
+ );
|
|
|
+ }else{
|
|
|
+ queryWrapper.and(wrapper ->
|
|
|
+ wrapper.eq("status", "2").or().eq("status", "4")
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<EnrollmentLaborContractInfo> infos = mapper.selectList(queryWrapper);
|
|
|
+ // 查询附件信息
|
|
|
+ for (EnrollmentLaborContractInfo eduInfo : infos) {
|
|
|
+ List<WorkAttachmentInfoDTO> files = mapper.findDtos(eduInfo.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(files)) {
|
|
|
+ eduInfo.setFiles(files);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return infos;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void saveOrUpdateInfo(EnrollmentLaborContractInfo info) {
|
|
|
+ if (info == null) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!StringUtils.isNotBlank(info.getId())) {
|
|
|
+ // 新增
|
|
|
+ add(info);
|
|
|
+ } else {
|
|
|
+ // 更新
|
|
|
+ update(info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增
|
|
|
+ * @param info
|
|
|
+ */
|
|
|
+ public void add(EnrollmentLaborContractInfo info){
|
|
|
+ String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
|
|
|
+ // 保存附件
|
|
|
+ if (ObjectUtil.isNotEmpty(info.getFiles())) {
|
|
|
+ AtomicInteger sort = new AtomicInteger(1);
|
|
|
+ info.getFiles().stream().forEach(item->{
|
|
|
+ //保存附件信息
|
|
|
+ WorkAttachmentInfo workAttachmentDto = new WorkAttachmentInfo();
|
|
|
+ workAttachmentDto.setName(item.getName());
|
|
|
+ workAttachmentDto.setSize(item.getSize());
|
|
|
+ workAttachmentDto.setUrl(item.getUrl());
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ String workAttachmentDtoInfo = JSON.toJSONString(workAttachmentDto);
|
|
|
+ String userDTOInfo = JSON.toJSONString(userDTO);
|
|
|
+ String attachmentId =id;
|
|
|
+ String attachmentFlag = "laborContract";
|
|
|
+ String sortInfo = Integer.toString(sort.get());
|
|
|
+ map.put("workAttachmentDtoInfo",workAttachmentDtoInfo);
|
|
|
+ map.put("userDTOInfo",userDTOInfo);
|
|
|
+ map.put("attachmentId",attachmentId);
|
|
|
+ map.put("attachmentFlag",attachmentFlag);
|
|
|
+ map.put("sortInfo",sortInfo);
|
|
|
+ String fileId = SpringUtil.getBean ( IWorkAttachmentApi.class ).saveFile(map);
|
|
|
+ sort.getAndIncrement();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ info.setId(id);
|
|
|
+ mapper.insert(info);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void update(EnrollmentLaborContractInfo info){
|
|
|
+ UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
|
|
|
+ mapper.updateContractById(info);
|
|
|
+ // 保存附件
|
|
|
+ if (ObjectUtil.isNotEmpty(info.getFiles())) {
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).deleteByAttachmentId(info.getId());
|
|
|
+ AtomicInteger sort = new AtomicInteger(1);
|
|
|
+ info.getFiles().stream().forEach(item->{
|
|
|
+ //保存附件信息
|
|
|
+ WorkAttachmentInfo workAttachmentDto = new WorkAttachmentInfo();
|
|
|
+ workAttachmentDto.setName(item.getName());
|
|
|
+ workAttachmentDto.setSize(item.getSize());
|
|
|
+ workAttachmentDto.setUrl(item.getUrl());
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ String workAttachmentDtoInfo = JSON.toJSONString(workAttachmentDto);
|
|
|
+ String userDTOInfo = JSON.toJSONString(userDTO);
|
|
|
+ String attachmentId = info.getId();
|
|
|
+ String attachmentFlag = "laborContract";
|
|
|
+ String sortInfo = Integer.toString(sort.get());
|
|
|
+ map.put("workAttachmentDtoInfo",workAttachmentDtoInfo);
|
|
|
+ map.put("userDTOInfo",userDTOInfo);
|
|
|
+ map.put("attachmentId",attachmentId);
|
|
|
+ map.put("attachmentFlag",attachmentFlag);
|
|
|
+ map.put("sortInfo",sortInfo);
|
|
|
+ String fileId = SpringUtil.getBean ( IWorkAttachmentApi.class ).saveFile(map);
|
|
|
+ sort.getAndIncrement();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|