¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.omd.dto.BtmTypeLinkAttributesDTO; |
| | | import com.vci.ubcs.omd.entity.BtmTypeAttribute; |
| | | import com.vci.ubcs.omd.mapper.BtmTypeAttributeMapper; |
| | | import com.vci.ubcs.omd.service.IAttributeService; |
| | | import com.vci.ubcs.omd.service.IBtmTypeAttributeService; |
| | | import com.vci.ubcs.omd.vo.BtmTypeAttributeVO; |
| | | import com.vci.ubcs.omd.wrapper.BtmTypeAttributeWrapper; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Description: ä¸å¡ç±»åå
³è屿§çæå¡å®ç°ç±» |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/23 |
| | | */ |
| | | @Service |
| | | public class BtmAttributeServiceImpl extends ServiceImpl<BtmTypeAttributeMapper, BtmTypeAttribute> implements IBtmTypeAttributeService { |
| | | |
| | | @Autowired |
| | | private IAttributeService attributeService; |
| | | |
| | | @Override |
| | | public boolean deleteLogic(@NotEmpty List<Long> ids) { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean changeStatus(@NotEmpty List<Long> ids, Integer status) { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥å±æ§åå¨å¹¶æ·»å |
| | | * |
| | | * @param attributesDTOList 页é¢ä¼ è¾å¯¹è±¡éå |
| | | * @return åå½±åçè¡æ° |
| | | */ |
| | | @Override |
| | | public List<BtmTypeAttributeVO> checkAndInsert(String btmTypeOid, List<BtmTypeLinkAttributesDTO> attributesDTOList, String creator, Date now) { |
| | | List<String> attributeIdList = new ArrayList<>(); |
| | | List<BtmTypeAttribute> btmTypeAttributeDOList = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(attributesDTOList)) { |
| | | attributesDTOList.stream().forEachOrdered(s -> { |
| | | attributeService.checkAttribute(s); |
| | | btmTypeAttributeDOList.add(BtmTypeAttributeWrapper.build().copyBtmTypeAttributeDTO2Entity(s,btmTypeOid, creator, now)); |
| | | attributeIdList.add(s.getId().toLowerCase().trim()); |
| | | }); |
| | | //æ£æ¥å±æ§æ¯å¦é½åå¨ |
| | | boolean exists = attributeService.checkAttributeExists(attributeIdList); |
| | | if (!exists){ |
| | | return null; |
| | | } |
| | | batchInsert(btmTypeAttributeDOList); |
| | | return BtmTypeAttributeWrapper.build().listEntityVO(btmTypeAttributeDOList); |
| | | // btmTypeAttributeDOList.stream().forEachOrdered(s -> { |
| | | // btmTypeAttributeDOMapper.insert(s); |
| | | // }); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥å±æ§åå¨å¹¶å é¤ |
| | | * |
| | | * @param records 主é®éå |
| | | * @return åå½±åçè¡æ° |
| | | */ |
| | | @Override |
| | | public int checkAndRemove(List<String> records) { |
| | | if (CollectionUtils.isEmpty(records)){ |
| | | return 0; |
| | | } |
| | | return baseMapper.batchDelete(records); |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥å±æ§åå¨å¹¶æ·»å |
| | | * |
| | | * @param btmTypeOid ä¸å¡ç±»åä¸»é® |
| | | * @param attributesDTOList 页é¢ä¼ è¾å¯¹è±¡éå |
| | | * @param creator å建人 |
| | | * @param now tsæ¶é´æ³ |
| | | * @return åå½±åçè¡æ° |
| | | */ |
| | | @Override |
| | | public List<BtmTypeAttributeVO> checkAndUpdate(String btmTypeOid, List<BtmTypeLinkAttributesDTO> attributesDTOList, String creator, Date now) { |
| | | List<String> attributeIdList = new ArrayList<>(); |
| | | List<BtmTypeAttribute> btmTypeAttributeDOList = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(attributesDTOList)) { |
| | | attributesDTOList.stream().forEachOrdered(s -> { |
| | | attributeService.checkAttribute(s); |
| | | btmTypeAttributeDOList.add(BtmTypeAttributeWrapper.build().copyBtmTypeAttributeDTO2Entity(s,btmTypeOid, creator, now)); |
| | | attributeIdList.add(s.getId().toLowerCase().trim()); |
| | | }); |
| | | //æ£æ¥å±æ§æ¯å¦é½åå¨ |
| | | boolean exists = attributeService.checkAttributeExists(attributeIdList); |
| | | if (!exists){ |
| | | return null; |
| | | } |
| | | baseMapper.batchUpdate(btmTypeAttributeDOList); |
| | | return BtmTypeAttributeWrapper.build().listEntityVO(btmTypeAttributeDOList); |
| | | // btmTypeAttributeDOList.stream().forEachOrdered(s -> { |
| | | // btmTypeAttributeDOMapper.insert(s); |
| | | // }); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æ¹éæå
¥ |
| | | * |
| | | * @param records æ°æ®å¯¹è±¡éå |
| | | */ |
| | | @Override |
| | | public int batchInsert(List<BtmTypeAttribute> records) { |
| | | return baseMapper.insertBatchSomeColumn(records); |
| | | } |
| | | |
| | | /** |
| | | * ä¸å¡ç±»å䏻鮿¥å±æ§ |
| | | * @param btmTypeOid ä¸å¡ç±»åä¸»é® |
| | | * @return æ¥è¯¢ç»æ |
| | | */ |
| | | @Override |
| | | public List<BtmTypeAttributeVO> getAttributeByBtmTypeOid(String btmTypeOid){ |
| | | Func.requireNotNull(btmTypeOid,"ä¸å¡ç±»å主é®"); |
| | | return BtmTypeAttributeWrapper.build().listEntityVO( |
| | | Optional.ofNullable( |
| | | baseMapper.selectList(Wrappers.<BtmTypeAttribute>query().lambda().eq(BtmTypeAttribute::getPkBtmType, btmTypeOid)) |
| | | ).orElseGet(ArrayList::new) |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ä¸å¡ç±»å主é®è·åå
³èçææå±æ§å¯¹è±¡ |
| | | * |
| | | * @param oidCollection ä¸å¡ç±»å主é®éå |
| | | * @return ææç屿§å¯¹è±¡ï¼å
æ¬ç³»ç»å
ç½®å±æ§ï¼keyæ¯ä¸å¡ç±»å主é®ï¼valueæ¯å
å«ç屿§ |
| | | * @throws VciBaseException ä¸å¡ç±»åä¸åå¨ï¼åæ°ä¸ºç©ºæè
æ¥è¯¢åºéæ¶ä¼æåºå¼å¸¸ |
| | | */ |
| | | @Override |
| | | public List<BtmTypeAttributeVO> batchListHasAttributesByBtmTypeOidCollection(Collection<String> oidCollection) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(oidCollection,"ä¸å¡ç±»å主é®"); |
| | | List<BtmTypeAttribute> doList = baseMapper.selectList(Wrappers.<BtmTypeAttribute>query().lambda().in(BtmTypeAttribute::getPkBtmType, oidCollection)); |
| | | return BtmTypeAttributeWrapper.build().listEntityVO(doList); |
| | | } |
| | | |
| | | /** |
| | | * è·åä¸å¡ç±»åä¸çæå®å±æ§ |
| | | * |
| | | * @param id ä¸å¡ç±»åçä¸»é® |
| | | * @param attributeIdCollection 屿§çid,è¥ä¸ºç©ºåè·åå
¨é¨ |
| | | * @return 屿§çæ°æ®å¯¹è±¡ |
| | | */ |
| | | @Override |
| | | public List<BtmTypeAttribute> selectByBtmTypeIdAndAttributeIds(String id, Collection<String> attributeIdCollection) { |
| | | return baseMapper.selectByBtmTypeIdAndAttributeIds(id,attributeIdCollection); |
| | | } |
| | | |
| | | /** |
| | | * éè¿ä¸å¡ç±»åçè±æåç§°è·åå
³èç屿§ |
| | | * |
| | | * @param idList ä¸å¡ç±»åçè±æåç§°éå |
| | | * @return å
å«ç屿§ |
| | | */ |
| | | @Override |
| | | public List<BtmTypeAttribute> selectByBtmTypeIds(List<String> idList) { |
| | | return baseMapper.selectByBtmTypeIds(idList); |
| | | } |
| | | } |