| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.panzhihua.common.model.vos.civil.ComActSocialWorkerDetailsVO; |
| | | import com.panzhihua.common.model.vos.civil.ComActSocialWorkerVO; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.ComActDAO; |
| | | import com.panzhihua.service_community.dao.ComActSocialOrgDao; |
| | | import com.panzhihua.service_community.dao.ComStreetDAO; |
| | | import com.panzhihua.service_community.dao.*; |
| | | import com.panzhihua.service_community.entity.ComActColumn; |
| | | import com.panzhihua.service_community.entity.ComActSocialOrg; |
| | | import com.panzhihua.service_community.entity.ComActSocialWorker; |
| | | import com.panzhihua.service_community.dao.ComActSocialWorkerDao; |
| | | import com.panzhihua.service_community.model.dos.ComActDO; |
| | | import com.panzhihua.service_community.model.dos.ComStreetDO; |
| | | import com.panzhihua.service_community.service.ComActSocialWorkerService; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import static java.util.Objects.nonNull; |
| | | import static org.apache.commons.lang3.StringUtils.isNotBlank; |
| | | |
| | | /** |
| | | * 社工(ComActSocialWorker)表服务实现类 |
| | |
| | | private ComActSocialOrgDao comActSocialOrgMapper; |
| | | @Resource |
| | | private ComActDAO comActDAO; |
| | | @Resource |
| | | private ComActActivityDAO comActActivityDAO; |
| | | @Resource |
| | | private ComActColumnDao comActColumnDao; |
| | | /** |
| | | * 新增社工 |
| | | * @param comActSocialWorkerAddDTO |
| | |
| | | */ |
| | | @Override |
| | | public R add(ComActSocialWorkerAddDTO comActSocialWorkerAddDTO){ |
| | | ComActSocialWorker comActSocialWorker = comActSocialWorkerMapper.selectOne(new LambdaQueryWrapper<ComActSocialWorker>() |
| | | .eq(ComActSocialWorker::getTelephone, comActSocialWorkerAddDTO.getTelephone()) |
| | | .eq(ComActSocialWorker::getCommunityId, comActSocialWorkerAddDTO.getCommunityId())); |
| | | if (nonNull(comActSocialWorker)) { |
| | | return R.fail("手机号已存在"); |
| | | } |
| | | ComActSocialWorker comActSocialWorker1 = comActSocialWorkerMapper.selectOne(new LambdaQueryWrapper<ComActSocialWorker>() |
| | | .eq(ComActSocialWorker::getIdCard, comActSocialWorkerAddDTO.getIdCard()) |
| | | .eq(ComActSocialWorker::getCommunityId, comActSocialWorkerAddDTO.getCommunityId())); |
| | | if (nonNull(comActSocialWorker1)) { |
| | | return R.fail("当前身份证号码已存在社工"); |
| | | } |
| | | ComActSocialWorker comActSocialWorkerDO = new ComActSocialWorker(); |
| | | BeanUtils.copyProperties(comActSocialWorkerAddDTO, comActSocialWorkerDO); |
| | | comActSocialWorkerDO.setCreateBy(comActSocialWorkerAddDTO.getUserId()); |
| | | comActSocialWorkerDO.setCreateAt(new Date()); |
| | | if(comActSocialWorkerMapper.insert(comActSocialWorkerDO)>0){ |
| | | return R.ok(); |
| | | } |
| | |
| | | ComActSocialWorker comActSocialWorkerDO = new ComActSocialWorker(); |
| | | BeanUtils.copyProperties(comActSocialWorkerEditDTO, comActSocialWorkerDO); |
| | | //comActSocialWorkerDO.setUpdateAt(new Date()); |
| | | updateWorkerSkill(comActSocialWorkerDO); |
| | | if(comActSocialWorkerMapper.updateById(comActSocialWorkerDO)>0){ |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | private void updateWorkerSkill(ComActSocialWorker socialWorker) { |
| | | String skillType = socialWorker.getSkillType(); |
| | | if (isNotBlank(skillType)) { |
| | | List<String> skillList = Arrays.asList(skillType.split(",")); |
| | | List<String> list = new ArrayList<String>(skillList); |
| | | list.remove(socialWorker.toString()); |
| | | StringBuilder sb = new StringBuilder(); |
| | | StringBuilder sb1 = new StringBuilder(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | String skillId = list.get(i); |
| | | ComActColumn skillColumn = comActColumnDao.selectById(skillId); |
| | | if (i < list.size() - 1) { |
| | | sb.append(skillId); |
| | | sb.append(","); |
| | | sb1.append(skillColumn.getName()); |
| | | sb1.append(","); |
| | | } else { |
| | | sb.append(skillId); |
| | | sb1.append(skillColumn.getName()); |
| | | } |
| | | } |
| | | socialWorker.setSkillType(sb.toString()); |
| | | socialWorker.setSkillTypeName(sb1.toString()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return 查找结果 |
| | | */ |
| | | @Override |
| | | public R<ComActSocialWorkerDetailsVO> comActSocialWorkerDetails(Long id){ |
| | | ComActSocialWorker comActSocialWorkerDO = comActSocialWorkerMapper.selectById(id); |
| | | if(comActSocialWorkerDO!=null) { |
| | | ComActSocialWorkerDetailsVO comActSocialWorkerDetailsVO = new ComActSocialWorkerDetailsVO(); |
| | | BeanUtils.copyProperties(comActSocialWorkerDO, comActSocialWorkerDetailsVO); |
| | | return R.ok(comActSocialWorkerDetailsVO); |
| | | } |
| | | return R.fail(); |
| | | public R<ComActSocialWorkerVO> comActSocialWorkerDetails(Long id){ |
| | | ComActSocialWorkerVO comActSocialWorkerDO = comActSocialWorkerMapper.selectOneById(id); |
| | | return R.ok(comActSocialWorkerDO); |
| | | } |
| | | |
| | | @Override |
| | |
| | | for(ComActSocialWorkerExcelVO comActSocialWorkerExcelVO:lis) { |
| | | ComActSocialWorker comActSocialWorkerDO = new ComActSocialWorker(); |
| | | BeanUtils.copyProperties(comActSocialWorkerExcelVO,comActSocialWorkerDO); |
| | | if (StringUtils.isNotEmpty(comActSocialWorkerExcelVO.getStreetId())) { |
| | | ComStreetDO comStreetDO=comStreetDAO.selectOne(new QueryWrapper<ComStreetDO>().eq("name",comActSocialWorkerExcelVO.getStreetId())); |
| | | if(comStreetDO!=null){ |
| | | comActSocialWorkerDO.setStreetId(comStreetDO.getStreetId()); |
| | | } |
| | | } |
| | | if (StringUtils.isNotEmpty(comActSocialWorkerExcelVO.getSocialOrgId())) { |
| | | ComActSocialOrg comActSocialOrgDO=comActSocialOrgMapper.selectOne(new QueryWrapper<ComActSocialOrg>().eq("name",comActSocialWorkerExcelVO.getSocialOrgId())); |
| | | if(comActSocialOrgDO!=null){ |
| | | comActSocialWorkerDO.setSocialOrgId(comActSocialOrgDO.getId()); |
| | | } |
| | | } |
| | | if(StringUtils.isNotEmpty(comActSocialWorkerExcelVO.getCommunityId())){ |
| | | ComActDO comActDO= comActDAO.selectOne(new QueryWrapper<ComActDO>().eq("name",comActSocialWorkerExcelVO.getCommunityId())); |
| | | if(comActDO!=null){ |
| | |
| | | comActSocialWorkerDO.setGen(0); |
| | | } |
| | | } |
| | | if(StringUtils.isNotEmpty(comActSocialWorkerExcelVO.getCredential())){ |
| | | if("是".equals(comActSocialWorkerExcelVO.getCredential())){ |
| | | comActSocialWorkerDO.setCredential(1); |
| | | } |
| | | else { |
| | | comActSocialWorkerDO.setCredential(0); |
| | | } |
| | | } |
| | | if(StringUtils.isNotEmpty(comActSocialWorkerExcelVO.getCredential())){ |
| | | if("是".equals(comActSocialWorkerExcelVO.getCredential())){ |
| | | comActSocialWorkerDO.setCredential(1); |
| | | } |
| | | else { |
| | | comActSocialWorkerDO.setCredential(0); |
| | | } |
| | | } |
| | | list.add(comActSocialWorkerDO); |
| | | } |
| | | this.saveBatch(list); |
| | |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R activity(CommonPage commonPage) { |
| | | return R.ok(comActSocialWorkerMapper.selectActivity(new Page(commonPage.getPage(),commonPage.getSize()),commonPage.getParamId())); |
| | | } |
| | | |
| | | @Override |
| | | public R activityList(CommonPage commonPage) { |
| | | return R.ok(comActActivityDAO.selectActivityBySocialWorker(new Page(commonPage.getPage(),commonPage.getSize()),commonPage)); |
| | | } |
| | | } |