| | |
| | | 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.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Description: 业务类型关联属性的服务实现类 |
| | |
| | | * @return 受影响的行数 |
| | | */ |
| | | @Override |
| | | public int checkAndInsert(String btmTypeOid, List<BtmTypeLinkAttributesDTO> attributesDTOList, String creator, Date now) { |
| | | 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)) { |
| | |
| | | //检查属性是否都存在 |
| | | boolean exists = attributeService.checkAttributeExists(attributeIdList); |
| | | if (!exists){ |
| | | return -1; |
| | | return null; |
| | | } |
| | | return batchInsert(btmTypeAttributeDOList); |
| | | batchInsert(btmTypeAttributeDOList); |
| | | return BtmTypeAttributeWrapper.build().listEntityVO(btmTypeAttributeDOList); |
| | | // btmTypeAttributeDOList.stream().forEachOrdered(s -> { |
| | | // btmTypeAttributeDOMapper.insert(s); |
| | | // }); |
| | | } |
| | | return 0; |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | ).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); |
| | | } |
| | | } |