|
@@ -1,21 +1,32 @@
|
|
package com.jeeplus.test.roster.service;
|
|
package com.jeeplus.test.roster.service;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.jeeplus.test.jobPosion.utils.BeanUtils;
|
|
|
|
+import com.jeeplus.test.oss.service.OssService;
|
|
import com.jeeplus.test.rank.service.dto.RankSystemTableDTO;
|
|
import com.jeeplus.test.rank.service.dto.RankSystemTableDTO;
|
|
|
|
+import com.jeeplus.test.roster.domain.RosterBankCards;
|
|
import com.jeeplus.test.roster.domain.RosterBase;
|
|
import com.jeeplus.test.roster.domain.RosterBase;
|
|
|
|
+import com.jeeplus.test.roster.domain.RosterContract;
|
|
import com.jeeplus.test.roster.mapper.RosterBaseMapper;
|
|
import com.jeeplus.test.roster.mapper.RosterBaseMapper;
|
|
|
|
+import com.jeeplus.test.roster.service.dto.RosterBankCardsDTO;
|
|
import com.jeeplus.test.roster.service.dto.RosterBaseDTO;
|
|
import com.jeeplus.test.roster.service.dto.RosterBaseDTO;
|
|
|
|
+import com.jeeplus.test.roster.service.mapstruct.RosterBankCardsWrapper;
|
|
import com.jeeplus.test.roster.service.mapstruct.RosterBaseWrapper;
|
|
import com.jeeplus.test.roster.service.mapstruct.RosterBaseWrapper;
|
|
|
|
+import com.jeeplus.test.roster.service.mapstruct.RosterContractWrapper;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
@Service
|
|
@Service
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public class RosterBaseService extends ServiceImpl<RosterBaseMapper, RosterBase> {
|
|
public class RosterBaseService extends ServiceImpl<RosterBaseMapper, RosterBase> {
|
|
@@ -23,13 +34,41 @@ public class RosterBaseService extends ServiceImpl<RosterBaseMapper, RosterBase>
|
|
@Autowired
|
|
@Autowired
|
|
private RosterBaseMapper rosterBaseMapper;
|
|
private RosterBaseMapper rosterBaseMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private RosterContractService rosterContractService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private RosterBankCardsService rosterBankCardsService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private OssService ossService;
|
|
|
|
+
|
|
public IPage<RosterBaseDTO> findList(Page<RosterBaseDTO> page, QueryWrapper<RosterBase> queryWrapper){
|
|
public IPage<RosterBaseDTO> findList(Page<RosterBaseDTO> page, QueryWrapper<RosterBase> queryWrapper){
|
|
queryWrapper.eq("rb.del_flag","0");
|
|
queryWrapper.eq("rb.del_flag","0");
|
|
return rosterBaseMapper.findList(page,queryWrapper);
|
|
return rosterBaseMapper.findList(page,queryWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
public RosterBaseDTO queryById(String id){
|
|
public RosterBaseDTO queryById(String id){
|
|
- return rosterBaseMapper.queryById(id);
|
|
|
|
|
|
+ RosterBaseDTO rosterBaseDTO = rosterBaseMapper.queryById(id);
|
|
|
|
+ if(ObjectUtil.isNotEmpty(rosterBaseDTO)){
|
|
|
|
+ if(StrUtil.isNotEmpty(rosterBaseDTO.getCertificatesFront())){
|
|
|
|
+ String front = ossService.getFileTemporaryLookUrl(rosterBaseDTO.getCertificatesFront());
|
|
|
|
+ rosterBaseDTO.setCertificatesFrontLsUrl(front);
|
|
|
|
+ }
|
|
|
|
+ if(StrUtil.isNotEmpty(rosterBaseDTO.getCertificatesBack())){
|
|
|
|
+ String back = ossService.getFileTemporaryLookUrl(rosterBaseDTO.getCertificatesBack());
|
|
|
|
+ rosterBaseDTO.setCertificatesBackLsUrl(back);
|
|
|
|
+ }
|
|
|
|
+ if(CollectionUtil.isNotEmpty(rosterBaseDTO.getRosterBankCardsDTOList())){
|
|
|
|
+ rosterBaseDTO.getRosterBankCardsDTOList().stream().forEach(item->{
|
|
|
|
+ if(StrUtil.isNotEmpty(item.getPayrollCardPic())){
|
|
|
|
+ String cardPic = ossService.getFileTemporaryLookUrl(item.getPayrollCardPic());
|
|
|
|
+ item.setPayrollCardPicLsUrl(cardPic);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return rosterBaseDTO;
|
|
}
|
|
}
|
|
|
|
|
|
public ResponseEntity saveRoster(RosterBaseDTO rosterBaseDTO){
|
|
public ResponseEntity saveRoster(RosterBaseDTO rosterBaseDTO){
|
|
@@ -41,6 +80,31 @@ public class RosterBaseService extends ServiceImpl<RosterBaseMapper, RosterBase>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.saveOrUpdate(rosterBase);
|
|
this.saveOrUpdate(rosterBase);
|
|
|
|
+
|
|
|
|
+ if(ObjectUtil.isNotEmpty(rosterBaseDTO)){
|
|
|
|
+ if(ObjectUtil.isNotEmpty(rosterBaseDTO.getRosterContractDTO())){
|
|
|
|
+ RosterContract rosterContract = RosterContractWrapper.INSTANCE.toEntity(rosterBaseDTO.getRosterContractDTO());
|
|
|
|
+ rosterContract.setBaseId(rosterBase.getId());
|
|
|
|
+ rosterContractService.remove(new QueryWrapper<RosterContract>().eq("base_id",rosterBase.getId()));
|
|
|
|
+ rosterContractService.saveOrUpdate(rosterContract);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(ObjectUtil.isNotEmpty(rosterBaseDTO)){
|
|
|
|
+ if(CollectionUtil.isNotEmpty(rosterBaseDTO.getRosterBankCardsDTOList())){
|
|
|
|
+ List<String> collect = rosterBaseDTO.getRosterBankCardsDTOList().stream().map(RosterBankCardsDTO::getId).collect(Collectors.toList());
|
|
|
|
+ rosterBankCardsService.remove(new QueryWrapper<RosterBankCards>().eq("base_id",rosterBase.getId()).notIn(CollectionUtil.isNotEmpty(collect),"id",collect));
|
|
|
|
+ rosterBaseDTO.getRosterBankCardsDTOList().stream().forEach(item->{
|
|
|
|
+ if(ObjectUtil.isNotEmpty(item)&& BeanUtils.objectCheckIsNull(item)){
|
|
|
|
+ RosterBankCards rosterBankCards = RosterBankCardsWrapper.INSTANCE.toEntity(item);
|
|
|
|
+ rosterBankCards.setBaseId(rosterBase.getId());
|
|
|
|
+ rosterBankCardsService.saveOrUpdate(rosterBankCards);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
|
|
+ rosterBankCardsService.remove(new QueryWrapper<RosterBankCards>().eq("base_id",rosterBase.getId()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return ResponseEntity.ok("花名册保存成功");
|
|
return ResponseEntity.ok("花名册保存成功");
|
|
}
|
|
}
|
|
}
|
|
}
|