lihang
2023-04-25 dd3a6c681f938fd53d5f6cc3a4fcee40e71b259c
Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmTypeServiceImpl.java
ÎļþÃû´Ó Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/OmdBtmTypeServiceImpl.java ÐÞ¸Ä
@@ -4,21 +4,21 @@
import com.alibaba.nacos.api.exception.NacosException;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vci.ubcs.omd.constant.OmdBtmTypeConstant;
import com.vci.ubcs.omd.constant.BtmTypeConstant;
import com.vci.ubcs.omd.repeater.DomainRepeater;
import com.vci.ubcs.omd.service.IOmdBtmTypeAttributeService;
import com.vci.ubcs.omd.wrapper.OmdBtmTypeWrapper;
import com.vci.ubcs.omd.service.IBtmTypeAttributeService;
import com.vci.ubcs.omd.wrapper.BtmTypeWrapper;
import com.vci.ubcs.starter.web.constant.OmdRegExpConstant;
import com.vci.ubcs.omd.dto.OmdBtmTypeDTO;
import com.vci.ubcs.omd.dto.OmdBtmTypeLinkAttributesDTO;
import com.vci.ubcs.omd.entity.OmdBtmType;
import com.vci.ubcs.omd.entity.OmdBtmTypeAttribute;
import com.vci.ubcs.omd.entity.OsModifyAttributeInfoDO;
import com.vci.ubcs.omd.mapper.OmdBtmTypeMapper;
import com.vci.ubcs.omd.service.IOmdBtmTypeService;
import com.vci.ubcs.omd.vo.OmdBtmTypeVO;
import com.vci.ubcs.omd.vo.OmdBtmTypeAttributeVO;
import com.vci.ubcs.omd.vo.OsLinkTypeVO;
import com.vci.ubcs.omd.dto.BtmTypeDTO;
import com.vci.ubcs.omd.dto.BtmTypeLinkAttributesDTO;
import com.vci.ubcs.omd.entity.BtmType;
import com.vci.ubcs.omd.entity.BtmTypeAttribute;
import com.vci.ubcs.omd.entity.ModifyAttributeInfoDO;
import com.vci.ubcs.omd.mapper.BtmTypeMapper;
import com.vci.ubcs.omd.service.IBtmTypeService;
import com.vci.ubcs.omd.vo.BtmTypeVO;
import com.vci.ubcs.omd.vo.BtmTypeAttributeVO;
import com.vci.ubcs.omd.vo.LinkTypeVO;
import com.vci.ubcs.starter.exception.VciBaseException;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import com.vci.ubcs.starter.web.util.VciDateUtil;
@@ -35,7 +35,6 @@
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import java.util.*;
@@ -46,7 +45,7 @@
 * @date 2023/4/23
 */
@Service
public class OmdBtmTypeServiceImpl extends ServiceImpl<OmdBtmTypeMapper, OmdBtmType> implements IOmdBtmTypeService {
public class BtmTypeServiceImpl extends ServiceImpl<BtmTypeMapper, BtmType> implements IBtmTypeService {
   /**
    * äº‹åŠ¡ç®¡ç†
@@ -58,10 +57,7 @@
    * ä¸šåŠ¡ç±»åž‹å…³è”å±žæ€§æœåŠ¡
    */
   @Autowired
   private IOmdBtmTypeAttributeService btmTypeAttributeService;
   @Autowired
   private DomainRepeater domainRepeater;
   private IBtmTypeAttributeService btmTypeAttributeService;
   /**
    * è®¾ç½®å¹³å°æœ¬èº«çš„业务类型
@@ -81,9 +77,9 @@
    * @throws ServiceException å‚数为空或者查询出错时会抛出错误
    */
   @Override
   public OmdBtmTypeVO getBtmTypeByOid(String pkBtmType) throws ServiceException {
   public BtmTypeVO getBtmTypeByOid(String pkBtmType) throws ServiceException {
      Func.requireNotNull(pkBtmType,"业务类型主键不能为空");
      OmdBtmTypeVO btmTypeVO = OmdBtmTypeWrapper.build().entityVO(baseMapper.selectOne(Wrappers.<OmdBtmType>query().lambda().eq(OmdBtmType::getOid, pkBtmType)));
      BtmTypeVO btmTypeVO = BtmTypeWrapper.build().entityVO(baseMapper.selectOne(Wrappers.<BtmType>query().lambda().eq(BtmType::getOid, pkBtmType)));
      btmTypeVO.setAttributes(btmTypeAttributeService.getAttributeByBtmTypeOid(pkBtmType));
      return btmTypeVO;
   }
@@ -96,7 +92,7 @@
    * @throws ServiceException å‚数为空或者查询出错时会抛出错误
    */
   @Override
   public List<OmdBtmTypeVO> listBtmTypeByOids(String pkBtmTypes) throws ServiceException {
   public List<BtmTypeVO> listBtmTypeByOids(String pkBtmTypes) throws ServiceException {
      return null;
   }
@@ -108,7 +104,7 @@
    * @throws ServiceException å‚数为空或者查询出错时会抛出错误
    */
   @Override
   public List<OmdBtmTypeVO> listBtmTypeByOidCollection(Collection<String> pkBtmTypeCollection) throws ServiceException {
   public List<BtmTypeVO> listBtmTypeByOidCollection(Collection<String> pkBtmTypeCollection) throws ServiceException {
      return null;
   }
@@ -120,7 +116,7 @@
    * @throws ServiceException å‚数为空或者查询出错时会抛出错误
    */
   @Override
   public OmdBtmTypeVO getBtmTypeById(String id) throws ServiceException {
   public BtmTypeVO getBtmTypeById(String id) throws ServiceException {
      return null;
   }
@@ -132,7 +128,7 @@
    * @throws ServiceException å‚数为空或者查询出错时会抛出错误
    */
   @Override
   public List<OmdBtmTypeVO> listBtmTypeByIds(String ids) throws ServiceException {
   public List<BtmTypeVO> listBtmTypeByIds(String ids) throws ServiceException {
      return null;
   }
@@ -144,7 +140,7 @@
    * @throws ServiceException å‚数为空或者查询出错时会抛出错误
    */
   @Override
   public List<OmdBtmTypeVO> listBtmTypeByIdCollection(Collection<String> idCollection) throws ServiceException {
   public List<BtmTypeVO> listBtmTypeByIdCollection(Collection<String> idCollection) throws ServiceException {
      return null;
   }
@@ -156,7 +152,7 @@
    * @throws ServiceException å‚数为空或者查询出错时会抛出错误
    */
   @Override
   public List<OmdBtmType> listBtmTypeDOByIdCollection(Collection<String> idCollection) throws ServiceException {
   public List<BtmType> listBtmTypeDOByIdCollection(Collection<String> idCollection) throws ServiceException {
      return null;
   }
@@ -168,7 +164,7 @@
    * @throws ServiceException å‚数为空或者查询出错时会抛出错误
    */
   @Override
   public List<OmdBtmType> listBtmTypeDOByOidCollection(Collection<String> oidCollection) throws ServiceException {
   public List<BtmType> listBtmTypeDOByOidCollection(Collection<String> oidCollection) throws ServiceException {
      return null;
   }
@@ -204,7 +200,7 @@
    * @throws ServiceException ä¸šåŠ¡ç±»åž‹ä¸å­˜åœ¨ï¼Œå‚æ•°ä¸ºç©ºæˆ–æŸ¥è¯¢å‡ºé”™æ—¶ä¼šæŠ›å‡ºé”™è¯¯
    */
   @Override
   public List<OmdBtmTypeAttributeVO> listHasAttributesByOid(String oid) throws ServiceException {
   public List<BtmTypeAttributeVO> listHasAttributesByOid(String oid) throws ServiceException {
      return null;
   }
@@ -216,7 +212,7 @@
    * @throws ServiceException ä¸šåŠ¡ç±»åž‹ä¸å­˜åœ¨ï¼Œå‚æ•°ä¸ºç©ºæˆ–è€…æŸ¥è¯¢å‡ºé”™æ—¶ä¼šæŠ›å‡ºå¼‚å¸¸
    */
   @Override
   public List<OmdBtmTypeAttributeVO> listHasAttributeById(String id) throws ServiceException {
   public List<BtmTypeAttributeVO> listHasAttributeById(String id) throws ServiceException {
      return null;
   }
@@ -228,7 +224,7 @@
    * @throws ServiceException ä¸šåŠ¡ç±»åž‹ä¸å­˜åœ¨ï¼Œå‚æ•°ä¸ºç©ºæˆ–è€…æŸ¥è¯¢å‡ºé”™æ—¶ä¼šæŠ›å‡ºå¼‚å¸¸
    */
   @Override
   public Map<String, List<OmdBtmTypeAttributeVO>> batchListHasAttributesByOidCollection(Collection<String> oidCollection) throws ServiceException {
   public Map<String, List<BtmTypeAttributeVO>> batchListHasAttributesByOidCollection(Collection<String> oidCollection) throws ServiceException {
      return null;
   }
@@ -240,7 +236,7 @@
    * @throws ServiceException ä¸šåŠ¡ç±»åž‹ä¸å­˜åœ¨ï¼Œå‚æ•°ä¸ºç©ºæˆ–è€…æŸ¥è¯¢å‡ºé”™æ—¶ä¼šæŠ›å‡ºå¼‚å¸¸
    */
   @Override
   public Map<String, List<OmdBtmTypeAttributeVO>> batchListHasAttributesByIdCollection(Collection<String> idCollection) throws ServiceException {
   public Map<String, List<BtmTypeAttributeVO>> batchListHasAttributesByIdCollection(Collection<String> idCollection) throws ServiceException {
      return null;
   }
@@ -252,7 +248,7 @@
    * @throws ServiceException å‚数为空或者查询出错时会抛出异常
    */
   @Override
   public List<OsLinkTypeVO> listLinkTypeForUsedBtmType(String pkBtmType) throws ServiceException {
   public List<LinkTypeVO> listLinkTypeForUsedBtmType(String pkBtmType) throws ServiceException {
      return null;
   }
@@ -289,7 +285,7 @@
    * @throws ServiceException æ·»åŠ å‡ºé”™çš„æ—¶å€™ä¼šæŠ›å‡ºå¼‚å¸¸
    */
   @Override
   public OmdBtmTypeDTO addSave(OmdBtmTypeDTO btmTypeDTO, boolean autoCreateTable) throws ServiceException {
   public BtmTypeDTO addSave(BtmTypeDTO btmTypeDTO, boolean autoCreateTable) throws ServiceException {
      TransactionStatus transaction = null;
      DefaultTransactionDefinition def = null;
      if (autoCreateTable) {
@@ -299,7 +295,7 @@
         transaction = dataSourceTransactionManager.getTransaction(def);
         // èŽ·å¾—äº‹åŠ¡çŠ¶æ€
      }
      OmdBtmType btmTypeDO = new OmdBtmType();
      BtmType btmTypeDO = new BtmType();
      try {
         VciBaseUtil.alertNotNull(btmTypeDTO, "要添加的业务类型", btmTypeDTO.getId(), "业务类型的英文名称", btmTypeDTO.getName(), "业务类型中文名称");
         if (btmTypeDTO.isViewFlag() && (StringUtils.isBlank(btmTypeDTO.getViewCreateSql())
@@ -315,9 +311,9 @@
         if (btmTypeDTO.getId().length() > 24) {
            throw new VciBaseException("业务类型英文名称不能超过18,目前长度为{0}", new Object[]{btmTypeDTO.getId().length()});
         }
         List<OmdBtmType> btmTypeDOList = listBtmTypeDOByIdCollection(VciBaseUtil.str2List(btmTypeDTO.getId()));
         List<BtmType> btmTypeDOList = listBtmTypeDOByIdCollection(VciBaseUtil.str2List(btmTypeDTO.getId()));
         if (!CollectionUtils.isEmpty(btmTypeDOList) && btmTypeDOList.size() > 0) {
            OmdBtmType existBtmType = btmTypeDOList.get(0);
            BtmType existBtmType = btmTypeDOList.get(0);
            throw new VciBaseException("业务类型英文名称已经存在(不区分大小写),这个英文名称对应的中文名称为{0},创建人{1},创建时间{2}"
               , new Object[]{existBtmType.getName(), existBtmType.getCreator(), VciDateUtil.date2Str(existBtmType.getCreateTime(), VciDateUtil.DateFormat)});
         }
@@ -354,7 +350,7 @@
         btmTypeDO.setCreator(creator);
         btmTypeDO.setCreateTime(now);
         btmTypeDO.setOwner(creator);
         btmTypeDO.setBtmname(OmdBtmTypeConstant.OMD_BTMTYPE);
         btmTypeDO.setBtmname(BtmTypeConstant.OMD_BTMTYPE);
         btmTypeDO.setTs(now);
         if (StringUtils.isBlank(btmTypeDO.getTableName())) {
            btmTypeDO.setTableName(getTableName(btmTypeDO.getId()));
@@ -379,7 +375,7 @@
         throw e;
      }
      if (autoCreateTable) {
         OmdBtmTypeVO btmTypeVO = OmdBtmTypeWrapper.build().entityVO(btmTypeDO);
         BtmTypeVO btmTypeVO = BtmTypeWrapper.build().entityVO(btmTypeDO);
         btmTypeVO.setAttributes(listHasAttributesByOid(btmTypeDO.getOid()));
         checkTableSame(btmTypeVO);
      }
@@ -391,7 +387,7 @@
    *
    * @param btmTypeVO ä¸šåŠ¡ç±»åž‹çš„æ˜¾ç¤ºå¯¹è±¡
    */
   private void checkTableSame(OmdBtmTypeVO btmTypeVO) {
   private void checkTableSame(BtmTypeVO btmTypeVO) {
      /*List<OmdBtmTypeVO> btmTypeVOList = new ArrayList<>();
      btmTypeVOList.add(btmTypeVO);
      List<OsModifyAttributeInfoDO> modifyAttributeInfoDOList = ddlServiceI.checkDifferent(btmTypeVOList, null);
@@ -413,8 +409,8 @@
    * @param creator    åˆ›å»ºäºº
    * @param now        å½“前时间
    */
   private void addAttributeForBtm(OmdBtmTypeDTO btmTypeDTO, String creator, Date now) throws VciBaseException{
      List<OmdBtmTypeLinkAttributesDTO> attributesDTOList = btmTypeDTO.getAttributesDTOList();
   private void addAttributeForBtm(BtmTypeDTO btmTypeDTO, String creator, Date now) throws VciBaseException{
      List<BtmTypeLinkAttributesDTO> attributesDTOList = btmTypeDTO.getAttributesDTOList();
      btmTypeAttributeService.checkAndInsert(btmTypeDTO.getOid(),attributesDTOList,creator,now);
   }
@@ -427,7 +423,7 @@
    * @throws ServiceException ä¿®æ”¹å‡ºé”™çš„æ—¶å€™ä¼šæŠ›å‡ºå¼‚常
    */
   @Override
   public OmdBtmTypeDTO editSave(OmdBtmTypeDTO btmTypeDTO, boolean autoEditTable) throws ServiceException {
   public BtmTypeDTO editSave(BtmTypeDTO btmTypeDTO, boolean autoEditTable) throws ServiceException {
      return null;
   }
@@ -439,7 +435,7 @@
    * @throws ServiceException å¦‚果业务类型被引用,或者删除出错时会抛出异常
    */
   @Override
   public void delete(OmdBtmTypeVO btmTypeVO, boolean autoDeleteTable) throws ServiceException {
   public void delete(BtmTypeVO btmTypeVO, boolean autoDeleteTable) throws ServiceException {
   }
@@ -451,7 +447,7 @@
    * @throws ServiceException å¦‚果业务类型被引用,或者删除出错时会抛出异常
    */
   @Override
   public void batchDelete(List<OmdBtmTypeVO> btmTypeVOList, boolean autoDeleteTable) throws ServiceException {
   public void batchDelete(List<BtmTypeVO> btmTypeVOList, boolean autoDeleteTable) throws ServiceException {
   }
@@ -463,7 +459,7 @@
    * @throws ServiceException å‚数为空或者查询出错时会抛出异常
    */
   @Override
   public List<OsModifyAttributeInfoDO> checkDbTableSame(String pkBtmType) throws ServiceException {
   public List<ModifyAttributeInfoDO> checkDbTableSame(String pkBtmType) throws ServiceException {
      return null;
   }
@@ -489,7 +485,7 @@
    * @return å±žæ€§çš„æ•°æ®å¯¹è±¡
    */
   @Override
   public OmdBtmTypeAttribute btmTypeAttributeDTO2DO(OmdBtmTypeLinkAttributesDTO attributesDTO, String pkBtmType, String creator, Date now) {
   public BtmTypeAttribute btmTypeAttributeDTO2DO(BtmTypeLinkAttributesDTO attributesDTO, String pkBtmType, String creator, Date now) {
      return null;
   }
@@ -500,7 +496,7 @@
    * @return æ•°æ®å¯¹è±¡
    */
   @Override
   public List<OmdBtmTypeAttribute> btmTypeAttributeVO2DO(List<OmdBtmTypeAttributeVO> thisBtmTypeHasAttributeVOList) {
   public List<BtmTypeAttribute> btmTypeAttributeVO2DO(List<BtmTypeAttributeVO> thisBtmTypeHasAttributeVOList) {
      return null;
   }
@@ -511,7 +507,7 @@
    * @return å±žæ€§çš„æ˜¾ç¤ºå¯¹è±¡åˆ—表
    */
   @Override
   public List<OmdBtmTypeAttributeVO> batchBtmTypeAttributeDO2VO(List<OmdBtmTypeAttribute> attributeDOList) {
   public List<BtmTypeAttributeVO> batchBtmTypeAttributeDO2VO(List<BtmTypeAttribute> attributeDOList) {
      return null;
   }
@@ -522,7 +518,7 @@
    * @return å±žæ€§çš„æ˜¾ç¤ºå¯¹è±¡åˆ—表
    */
   @Override
   public OmdBtmTypeAttributeVO btmTypeAttributeDO2VO(OmdBtmTypeAttribute attributesDO) {
   public BtmTypeAttributeVO btmTypeAttributeDO2VO(BtmTypeAttribute attributesDO) {
      return null;
   }
@@ -534,7 +530,7 @@
    * @return å±žæ€§çš„æ˜¾ç¤ºå¯¹è±¡
    */
   @Override
   public List<OmdBtmTypeAttribute> listAttributeDOByIdsForBtm(String id, Collection<String> attributeIdCollection) {
   public List<BtmTypeAttribute> listAttributeDOByIdsForBtm(String id, Collection<String> attributeIdCollection) {
      return null;
   }
@@ -545,7 +541,7 @@
    * @return å±žæ€§çš„æ˜¾ç¤ºå¯¹è±¡
    */
   @Override
   public List<OmdBtmTypeAttributeVO> listAttributeByBtmTypeId(String id) {
   public List<BtmTypeAttributeVO> listAttributeByBtmTypeId(String id) {
      return null;
   }
@@ -556,7 +552,7 @@
    * @return å±žæ€§çš„æ˜¾ç¤ºå¯¹è±¡
    */
   @Override
   public List<OmdBtmTypeAttributeVO> listAttributeByBtmTypeOid(String oid) {
   public List<BtmTypeAttributeVO> listAttributeByBtmTypeOid(String oid) {
      return null;
   }
@@ -569,7 +565,7 @@
    * @throws ServiceException å‚数为空或者查询出错会抛出异常
    */
   @Override
   public List<OmdBtmTypeAttributeVO> batchListAttributeByBtmType(Collection<String> oidsOrIds, boolean queryById) throws ServiceException {
   public List<BtmTypeAttributeVO> batchListAttributeByBtmType(Collection<String> oidsOrIds, boolean queryById) throws ServiceException {
      return null;
   }
@@ -580,22 +576,14 @@
    * @return æ‰§è¡Œç»“æžœ
    */
   @Override
   public boolean submit(OmdBtmTypeDTO btmTypeDTO) {
      //addSave(btmTypeDTO,false);
   public boolean submit(BtmTypeDTO btmTypeDTO) {
      addSave(btmTypeDTO,false);
      try {
         Object result = domainRepeater.submitBtmType(btmTypeDTO.getDomain(), Objects.requireNonNull(BeanUtil.copy(btmTypeDTO, OmdBtmTypeVO.class)));
         if (result instanceof R){
             R r = (R) result;
             if (r.isSuccess()){
                return true;
             }else {
                return false;
             }
         }
         R result = DomainRepeater.submitBtmType(btmTypeDTO.getDomain(), Objects.requireNonNull(BeanUtil.copy(btmTypeDTO, BtmTypeVO.class)));
         return result.isSuccess();
      } catch (NacosException e) {
         throw new RuntimeException(e);
      }
      return true;
   }
   @Override