| | |
| | | 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.ComActSocialWorkerVO; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | 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.model.dos.ComActDO; |
| | |
| | | |
| | | 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 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()); |
| | |
| | | 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()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public R activityList(CommonPage commonPage) { |
| | | return R.ok(comActActivityDAO.selectActivityBySocialWorker(new Page(commonPage.getPage(),commonPage.getSize()),commonPage.getParamId())); |
| | | return R.ok(comActActivityDAO.selectActivityBySocialWorker(new Page(commonPage.getPage(),commonPage.getSize()),commonPage)); |
| | | } |
| | | } |