| | |
| | | import com.smartor.domain.HeLibrary; |
| | | import com.smartor.domain.HeLibraryTag; |
| | | import com.smartor.domain.HeLibraryVO; |
| | | import com.smartor.domain.TempDetpRelevance; |
| | | import com.smartor.mapper.HeLibraryMapper; |
| | | import com.smartor.mapper.HeLibraryTagMapper; |
| | | import com.smartor.mapper.TempDetpRelevanceMapper; |
| | | import com.smartor.service.IHeLibraryService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | |
| | | |
| | | @Autowired |
| | | private HeLibraryTagMapper heLibraryTagMapper; |
| | | |
| | | @Autowired |
| | | private TempDetpRelevanceMapper tempDetpRelevanceMapper; |
| | | |
| | | /** |
| | | * 查询宣教资料库 |
| | |
| | | */ |
| | | @Override |
| | | public int deleteHeLibraryByIds(Long[] ids) { |
| | | return heLibraryMapper.deleteHeLibraryByIds(ids); |
| | | Integer i = null; |
| | | for (Long id : ids) { |
| | | i = heLibraryMapper.deleteHeLibraryById(id); |
| | | } |
| | | return i; |
| | | } |
| | | |
| | | /** |
| | | * 删除宣教资料库信息 |
| | | * |
| | | * @param id 宣教资料库主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteHeLibraryById(Long id) { |
| | | return heLibraryMapper.deleteHeLibraryById(id); |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改宣教详情 |
| | | */ |
| | | @Override |
| | | public Integer saveOrUpdateScript(HeLibraryVO heLibraryVO) { |
| | | Integer i = null; |
| | | HeLibrary heLibrary = DtoConversionUtils.sourceToTarget(heLibraryVO, HeLibrary.class); |
| | | if (heLibraryVO.getIsoperation() != null && heLibraryVO.getIsoperation() == 1) { |
| | | //新增 |
| | | i = heLibraryMapper.insertHeLibrary(heLibrary); |
| | | heLibraryMapper.insertHeLibrary(heLibrary); |
| | | } else if (heLibraryVO.getIsoperation() != null && heLibraryVO.getIsoperation() == 2) { |
| | | //修改 |
| | | i = heLibraryMapper.updateHeLibrary(heLibrary); |
| | | heLibraryMapper.updateHeLibrary(heLibrary); |
| | | } |
| | | log.info("新增或修改宣教详情的id为:{}", heLibrary.getId()); |
| | | // |
| | | // //对标签进行处理 |
| | | // for (HeLibraryTag heLibraryTag : heLibraryVO.getHeLibraryTagList()) { |
| | | // if (heLibraryTag.getIsoperation() != null && heLibraryTag.getIsoperation() == 1) { |
| | | // //新增 |
| | | // heLibraryTag.setHeid(heLibrary.getId()); |
| | | // heLibraryTagMapper.insertHeLibraryTag(heLibraryTag); |
| | | // } else if (heLibraryTag.getIsoperation() != null && heLibraryTag.getIsoperation() == 2) { |
| | | // //修改 |
| | | // heLibraryTag.setHeid(heLibrary.getId()); |
| | | // heLibraryTagMapper.updateHeLibraryTag(heLibraryTag); |
| | | // } else if (heLibraryTag.getIsoperation() != null && heLibraryTag.getIsoperation() == 3) { |
| | | // //删除 |
| | | // if (heLibraryTag.getId() == null) { |
| | | // log.info("删除失败,模板指标id为空"); |
| | | // } else { |
| | | // heLibraryTagMapper.deleteHeLibraryTagById(heLibraryTag.getId()); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // //对科室进行处理 |
| | | // for (TempDetpRelevance tempDetpRelevance : heLibraryVO.getTempDetpRelevances()) { |
| | | // if (tempDetpRelevance.getId() == null) { |
| | | // //新增 |
| | | // tempDetpRelevance.setTempid(heLibrary.getId()); |
| | | // tempDetpRelevance.setType(3L); |
| | | // tempDetpRelevanceMapper.insertTempDetpRelevance(tempDetpRelevance); |
| | | // } else { |
| | | // tempDetpRelevanceMapper.updateTempDetpRelevance(tempDetpRelevance); |
| | | // } |
| | | // } |
| | | |
| | | //对标签进行处理 |
| | | for (HeLibraryTag heLibraryTag : heLibraryVO.getHeLibraryTagList()) { |
| | | if (heLibraryTag.getIsoperation() != null && heLibraryTag.getIsoperation() == 1) { |
| | | //新增 |
| | | heLibraryTag.setHeid(heLibrary.getId()); |
| | | heLibraryTagMapper.insertHeLibraryTag(heLibraryTag); |
| | | } else if (heLibraryTag.getIsoperation() != null && heLibraryTag.getIsoperation() == 2) { |
| | | //修改 |
| | | heLibraryTag.setHeid(heLibrary.getId()); |
| | | heLibraryTagMapper.updateHeLibraryTag(heLibraryTag); |
| | | } else if (heLibraryTag.getIsoperation() != null && heLibraryTag.getIsoperation() == 3) { |
| | | //删除 |
| | | if (heLibraryTag.getId() == null) { |
| | | log.info("删除失败,模板指标id为空"); |
| | | } else { |
| | | heLibraryTagMapper.deleteHeLibraryTagById(heLibraryTag.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return i; |
| | | return heLibrary.getId().intValue(); |
| | | } |
| | | |
| | | @Override |
| | | public HeLibraryVO selectInfoByCondition(HeLibrary heLibrary) { |
| | | public List<HeLibraryVO> selectInfoByCondition(HeLibrary heLibrary) { |
| | | log.info("查询模板详情根据条件的入参为:{}", heLibrary); |
| | | List<HeLibrary> heLibraries = selectHeLibraryList(heLibrary); |
| | | if (CollectionUtils.isEmpty(heLibraries)) { |
| | | log.info("提供的条件,查询宣教数据为空:{}", heLibraries); |
| | | throw new BaseException("提供的条件,查询宣教数据为空"); |
| | | } |
| | | |
| | | //用于返参 |
| | | HeLibraryVO heLibraryVO = DtoConversionUtils.sourceToTarget(heLibraries.get(0), HeLibraryVO.class); |
| | | //根据宣教ID查询宣教指标集合 |
| | | HeLibraryTag heLibraryTag = new HeLibraryTag(); |
| | | heLibraryTag.setHeid(heLibraryVO.getId()); |
| | | List<HeLibraryTag> heLibraryTags = heLibraryTagMapper.selectHeLibraryTagList(heLibraryTag); |
| | | heLibraryVO.setHeLibraryTagList(heLibraryTags); |
| | | |
| | | return heLibraryVO; |
| | | List<HeLibraryVO> heLibraryVOS = DtoConversionUtils.sourceToTarget(heLibraries, HeLibraryVO.class); |
| | | if (CollectionUtils.isNotEmpty(heLibraryVOS) && heLibraryVOS.size() == 1) { |
| | | //根据宣教ID查询宣教指标集合 |
| | | HeLibraryTag heLibraryTag = new HeLibraryTag(); |
| | | heLibraryTag.setHeid(heLibraryVOS.get(0).getId()); |
| | | List<HeLibraryTag> heLibraryTags = heLibraryTagMapper.selectHeLibraryTagList(heLibraryTag); |
| | | heLibraryVOS.get(0).setHeLibraryTagList(heLibraryTags); |
| | | } |
| | | return heLibraryVOS; |
| | | } |
| | | } |