| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.vci.ubcs.code.mapper.CodeClassifyTemplateButtonMapper; |
| | | import com.vci.ubcs.code.entity.CodeClassifyTemplateButtonDO; |
| | | import com.vci.ubcs.code.service.CodeButtonServiceI; |
| | | import com.vci.ubcs.code.service.CodeClassifyTemplateButtonServiceI; |
| | | import com.vci.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.BaseResult; |
| | | import com.vci.starter.web.pagemodel.DataGrid; |
| | | import com.vci.starter.web.pagemodel.PageHelper; |
| | | import com.vci.starter.web.util.BeanUtil; |
| | | import com.vci.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.web.pageModel.BatchCBO; |
| | | import com.vci.web.service.WebBoServiceI; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | |
| | | import com.vci.ubcs.code.dto.CodeClassifyTemplateButtonDTO; |
| | | import com.vci.ubcs.code.entity.*; |
| | | import com.vci.ubcs.code.enumpack.CodeButtonUseEnum; |
| | | import com.vci.ubcs.code.mapper.CodeClassifyTemplateButtonMapper; |
| | | import com.vci.ubcs.code.service.ICodeButtonService; |
| | | import com.vci.ubcs.code.service.ICodeClassifyTemplateButtonService; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeButtonVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateButtonVO; |
| | | import com.vci.ubcs.code.wrapper.CodeTempbuttonWrapper; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; |
| | | import com.vci.ubcs.starter.util.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.starter.util.UBCSCondition; |
| | | import com.vci.ubcs.starter.web.pagemodel.PageHelper; |
| | | import com.vci.ubcs.starter.web.util.BeanUtil; |
| | | import com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.cglib.beans.BeanMap; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.frameworkcore.constant.FrameWorkLangCodeConstant.*; |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*; |
| | | |
| | | /** |
| | | * 主题库里模板包含的按钮服务 |
| | | * @author weidy |
| | | * @date 2022-01-24 |
| | | * 编码库定义-模板按钮扩展 服务实现类 |
| | | * |
| | | * @author yuxc |
| | | * @since 2023-04-20 |
| | | */ |
| | | @Service |
| | | public class CodeClassifyTemplateButtonServiceImpl implements CodeClassifyTemplateButtonServiceI { |
| | | public class CodeClassifyTemplateButtonServiceImpl extends ServiceImpl<CodeClassifyTemplateButtonMapper, CodeClassifyTemplateButton> implements ICodeClassifyTemplateButtonService { |
| | | |
| | | /** |
| | | * 日志 |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | /** |
| | | * 数据操作层 |
| | | */ |
| | | @Autowired |
| | | private CodeClassifyTemplateButtonMapper codeClassifyTemplateButtonMapper; |
| | | |
| | | /** |
| | | * 数据操作层 |
| | | */ |
| | | @Resource |
| | | private CodeClassifyTemplateButtonMapper codeClassifyTemplateButtonMapper; |
| | | /** |
| | | * 按钮的服务 |
| | | */ |
| | | @Autowired |
| | | private ICodeButtonService buttonService; |
| | | |
| | | /** |
| | | * 按钮的服务 |
| | | */ |
| | | @Autowired |
| | | private CodeButtonServiceI buttonService; |
| | | /** |
| | | * 对象的操作 |
| | | */ |
| | | @Autowired |
| | | private RevisionModelUtil revisionModelUtil; |
| | | |
| | | /** |
| | | * 业务类型操作的服务 |
| | | */ |
| | | @Autowired |
| | | @Lazy |
| | | private WebBoServiceI boService; |
| | | /** |
| | | * 查询所有的主题库里模板包含的按钮 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public IPage<CodeClassifyTemplateButtonVO> gridCodeClassifyTemplateButton(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException { |
| | | Query query = new Query(); |
| | | if (pageHelper == null) { |
| | | query.setSize(-1); |
| | | }else { |
| | | query.setSize(pageHelper.getLimit()); |
| | | query.setCurrent(pageHelper.getPage()); |
| | | } |
| | | query.setDescs("createTime"); |
| | | if(StringUtils.isBlank(conditionMap.getOrDefault("classifyTemplateOid",null))){ |
| | | return new Page<>(); |
| | | } |
| | | |
| | | /** |
| | | * 对象的操作 |
| | | */ |
| | | @Autowired |
| | | private RevisionModelUtil revisionModelUtil; |
| | | IPage<CodeClassifyTemplateButton> doList = codeClassifyTemplateButtonMapper.selectPage(Condition.getPage(query),getMPJLambdaWrapper(conditionMap)); |
| | | IPage<CodeClassifyTemplateButtonVO> voList = new Page<>(); |
| | | if (!CollectionUtils.isEmpty(doList.getRecords())) { |
| | | voList = CodeTempbuttonWrapper.build().pageVO(doList); |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * @param codeClassifyTemplateButtonDOs 数据对象列表 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateButtonVO> codeClassifyTemplateButtonDO2VOs(Collection<CodeClassifyTemplateButton> codeClassifyTemplateButtonDOs) throws VciBaseException{ |
| | | return codeClassifyTemplateButtonDO2VOs(codeClassifyTemplateButtonDOs,false); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有的主题库里模板包含的按钮 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeClassifyTemplateButtonVO> gridCodeClassifyTemplateButton(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if (pageHelper == null) { |
| | | pageHelper = new PageHelper(-1); |
| | | } |
| | | pageHelper.addDefaultDesc("createTime"); |
| | | final String[] classifyTemplateOid = {""}; |
| | | if(conditionMap!=null){ |
| | | conditionMap.forEach((key,value)->{ |
| | | if("classifytemplateoid".equalsIgnoreCase(key)){ |
| | | classifyTemplateOid[0] = value; |
| | | } |
| | | }); |
| | | } |
| | | if(StringUtils.isBlank(classifyTemplateOid[0])){ |
| | | return new DataGrid<>(); |
| | | } |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * @param codeClassifyTemplateButtonDOs 数据对象列表 |
| | | * @param hasButtonVO 是否包含按钮的信息 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateButtonVO> codeClassifyTemplateButtonDO2VOs(Collection<CodeClassifyTemplateButton> codeClassifyTemplateButtonDOs, boolean hasButtonVO) throws VciBaseException{ |
| | | List<CodeClassifyTemplateButtonVO> voList = new ArrayList<CodeClassifyTemplateButtonVO>(); |
| | | if(!CollectionUtils.isEmpty(codeClassifyTemplateButtonDOs)){ |
| | | for(CodeClassifyTemplateButton s: codeClassifyTemplateButtonDOs){ |
| | | CodeClassifyTemplateButtonVO vo = codeClassifyTemplateButtonDO2VO(s); |
| | | if(vo != null){ |
| | | voList.add(vo); |
| | | } |
| | | } |
| | | } |
| | | if(hasButtonVO && !CollectionUtils.isEmpty(voList)){ |
| | | //获取按钮的显示对象 |
| | | List<CodeButtonVO> buttonVOList = new ArrayList<>(); |
| | | VciBaseUtil.switchCollectionForOracleIn(voList.stream().map(CodeClassifyTemplateButtonVO::getClassifyButtonOid).collect(Collectors.toList())).stream().forEach(buttonOids->{ |
| | | buttonVOList.addAll(buttonService.listCodeButtonByOids(buttonOids)); |
| | | }); |
| | | Map<String, CodeButtonVO> buttonVOMap = Optional.ofNullable(buttonVOList).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | voList.stream().forEach(vo->{ |
| | | vo.setButtonVO(buttonVOMap.getOrDefault(vo.getClassifyButtonOid(),null)); |
| | | }); |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | List<CodeClassifyTemplateButtonDO> doList = codeClassifyTemplateButtonMapper.selectByCondition(conditionMap,pageHelper); |
| | | DataGrid<CodeClassifyTemplateButtonVO> dataGrid=new DataGrid<CodeClassifyTemplateButtonVO>(); |
| | | if (!CollectionUtils.isEmpty(doList)) { |
| | | dataGrid.setData(codeClassifyTemplateButtonDO2VOs(doList)); |
| | | dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(codeClassifyTemplateButtonMapper.countByCondition(conditionMap)))); |
| | | } |
| | | return dataGrid; |
| | | } |
| | | /** |
| | | * 数据对象转换为显示对象 |
| | | * @param codeClassifyTemplateButtonDO 数据对象 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 拷贝属性出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateButtonVO codeClassifyTemplateButtonDO2VO(CodeClassifyTemplateButton codeClassifyTemplateButtonDO) throws VciBaseException{ |
| | | CodeClassifyTemplateButtonVO vo = new CodeClassifyTemplateButtonVO(); |
| | | if(codeClassifyTemplateButtonDO != null){ |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateButtonDO,vo); |
| | | //如果有lcstatus的类的话 |
| | | vo.setButtonUseText(CodeButtonUseEnum.getTextByValue(codeClassifyTemplateButtonDO.getButtonUse())); |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * @param codeClassifyTemplateButtonDOs 数据对象列表 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateButtonVO> codeClassifyTemplateButtonDO2VOs(Collection<CodeClassifyTemplateButtonDO> codeClassifyTemplateButtonDOs) throws VciBaseException{ |
| | | return codeClassifyTemplateButtonDO2VOs(codeClassifyTemplateButtonDOs,false); |
| | | } |
| | | @Override |
| | | public IPage<CodeClassifyTemplateButtonVO> selectCodeTempbuttonPage(IPage<CodeClassifyTemplateButtonVO> page, CodeClassifyTemplateButtonVO CodeTempbutton) { |
| | | return page.setRecords(baseMapper.selectCodeTempbuttonPage(page, CodeTempbutton)); |
| | | } |
| | | |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * @param codeClassifyTemplateButtonDOs 数据对象列表 |
| | | * @param hasButtonVO 是否包含按钮的信息 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateButtonVO> codeClassifyTemplateButtonDO2VOs(Collection<CodeClassifyTemplateButtonDO> codeClassifyTemplateButtonDOs, boolean hasButtonVO) throws VciBaseException{ |
| | | List<CodeClassifyTemplateButtonVO> voList = new ArrayList<CodeClassifyTemplateButtonVO>(); |
| | | if(!CollectionUtils.isEmpty(codeClassifyTemplateButtonDOs)){ |
| | | for(CodeClassifyTemplateButtonDO s: codeClassifyTemplateButtonDOs){ |
| | | CodeClassifyTemplateButtonVO vo = codeClassifyTemplateButtonDO2VO(s); |
| | | if(vo != null){ |
| | | voList.add(vo); |
| | | } |
| | | } |
| | | } |
| | | if(hasButtonVO && !CollectionUtils.isEmpty(voList)){ |
| | | //获取按钮的显示对象 |
| | | List<CodeButtonVO> buttonVOList = new ArrayList<>(); |
| | | VciBaseUtil.switchCollectionForOracleIn(voList.stream().map(CodeClassifyTemplateButtonVO::getClassifybuttonoid).collect(Collectors.toList())).stream().forEach(buttonOids->{ |
| | | buttonVOList.addAll(buttonService.listCodeButtonByOids(buttonOids)); |
| | | }); |
| | | Map<String, CodeButtonVO> buttonVOMap = Optional.ofNullable(buttonVOList).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | voList.stream().forEach(vo->{ |
| | | vo.setButtonVO(buttonVOMap.getOrDefault(vo.getClassifybuttonoid(),null)); |
| | | }); |
| | | } |
| | | return voList; |
| | | } |
| | | /** |
| | | * 增加主题库里模板包含的按钮 |
| | | * @param codeClassifyTemplateButtonDTO 主题库里模板包含的按钮数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public CodeClassifyTemplateButtonVO addSave(CodeClassifyTemplateButtonDTO codeClassifyTemplateButtonDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateButtonDTO,"需要添加的数据对象",codeClassifyTemplateButtonDTO.getClassifyTemplateOid(),"模板的主键"); |
| | | //将DTO转换为DO |
| | | CodeClassifyTemplateButton codeClassifyTemplateButtonDO = new CodeClassifyTemplateButton(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateButtonDTO,codeClassifyTemplateButtonDO); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeClassifyTemplateButtonDO, MdmBtmTypeConstant.CODE_TEMPLATE_BUTTON,null); |
| | | if(codeClassifyTemplateButtonDO.getOrderNum()== null){ |
| | | //查询全部 |
| | | Long count = codeClassifyTemplateButtonMapper.selectCount(Wrappers.<CodeClassifyTemplateButton>query() |
| | | .lambda().eq(CodeClassifyTemplateButton::getClassifyTemplateOid,codeClassifyTemplateButtonDTO.getClassifyTemplateOid()) |
| | | ); |
| | | if(count == null){ |
| | | count = 0L; |
| | | } |
| | | codeClassifyTemplateButtonDO.setOrderNum(Long.valueOf(count + 1L).intValue()); |
| | | } |
| | | boolean resInsertClsTempButton = codeClassifyTemplateButtonMapper.insert(codeClassifyTemplateButtonDO) > 0; |
| | | return resInsertClsTempButton ? codeClassifyTemplateButtonDO2VO(codeClassifyTemplateButtonDO):null; |
| | | } |
| | | |
| | | /** |
| | | * 数据对象转换为显示对象 |
| | | * @param codeClassifyTemplateButtonDO 数据对象 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 拷贝属性出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateButtonVO codeClassifyTemplateButtonDO2VO(CodeClassifyTemplateButtonDO codeClassifyTemplateButtonDO) throws VciBaseException{ |
| | | CodeClassifyTemplateButtonVO vo = new CodeClassifyTemplateButtonVO(); |
| | | if(codeClassifyTemplateButtonDO != null){ |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateButtonDO,vo); |
| | | //如果有lcstatus的类的话 |
| | | /** |
| | | * 修改主题库里模板包含的按钮 |
| | | * @param codeClassifyTemplateButtonDTO 主题库里模板包含的按钮数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public CodeClassifyTemplateButtonVO editSave(CodeClassifyTemplateButtonDTO codeClassifyTemplateButtonDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateButtonDTO,"数据对象",codeClassifyTemplateButtonDTO.getOid(),"主题库里模板包含的按钮主键"); |
| | | //将DTO转换为DO |
| | | CodeClassifyTemplateButton codeClassifyTemplateButtonDO = selectByOid(codeClassifyTemplateButtonDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeClassifyTemplateButtonDTO,codeClassifyTemplateButtonDO); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeClassifyTemplateButtonDO,null); |
| | | boolean resUpdateClsTempButton = codeClassifyTemplateButtonMapper.updateById(codeClassifyTemplateButtonDO) > 0; |
| | | return resUpdateClsTempButton ? codeClassifyTemplateButtonDO2VO(codeClassifyTemplateButtonDO):null; |
| | | } |
| | | |
| | | } |
| | | return vo; |
| | | } |
| | | /** |
| | | * 删除主题库里模板包含的按钮 |
| | | * @param codeClassifyTemplateButtonDTO 主题库里模板包含的按钮数据传输对象,oid和ts需要传输 |
| | | * @return 删除结果反馈::success:成功,fail:失败 |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R deleteCodeClassifyTemplateButton(CodeClassifyTemplateButtonDTO codeClassifyTemplateButtonDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateButtonDTO,"主题库里模板包含的按钮数据对象",codeClassifyTemplateButtonDTO.getOid(),"主题库里模板包含的按钮的主键"); |
| | | CodeClassifyTemplateButton codeClassifyTemplateButtonDO = selectByOid(codeClassifyTemplateButtonDTO.getOid()); |
| | | R baseResult = checkIsCanDeleteForDO(codeClassifyTemplateButtonDTO,codeClassifyTemplateButtonDO); |
| | | if(baseResult.isSuccess()) { |
| | | }else{ |
| | | return baseResult; |
| | | } |
| | | //执行删除操作 |
| | | boolean b = codeClassifyTemplateButtonMapper.deleteById(codeClassifyTemplateButtonDO.getOid()) > 0; |
| | | return R.status(b); |
| | | } |
| | | |
| | | /** |
| | | * 增加主题库里模板包含的按钮 |
| | | * @param codeClassifyTemplateButtonDTO 主题库里模板包含的按钮数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateButtonVO addSave(CodeClassifyTemplateButtonDTO codeClassifyTemplateButtonDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateButtonDTO,"需要添加的数据对象",codeClassifyTemplateButtonDTO.getClassifytemplateoid(),"模板的主键"); |
| | | //将DTO转换为DO |
| | | CodeClassifyTemplateButtonDO codeClassifyTemplateButtonDO = new CodeClassifyTemplateButtonDO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateButtonDTO,codeClassifyTemplateButtonDO); |
| | | if(codeClassifyTemplateButtonDO.getOrderNum()== null){ |
| | | //查询全部 |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("classifytemplateoid",codeClassifyTemplateButtonDTO.getClassifytemplateoid()); |
| | | Long count = codeClassifyTemplateButtonMapper.countByCondition(conditionMap); |
| | | if(count == null){ |
| | | count = 0L; |
| | | } |
| | | codeClassifyTemplateButtonDO.setOrderNum(Long.valueOf(count + 1L).intValue()); |
| | | } |
| | | codeClassifyTemplateButtonMapper.insert(codeClassifyTemplateButtonDO); |
| | | return codeClassifyTemplateButtonDO2VO(codeClassifyTemplateButtonDO); |
| | | } |
| | | /** |
| | | * 校验是否可以删除,如果存在下级,并且下级有数据引用则不能删除 |
| | | * @param codeClassifyTemplateButtonDTO 数据传输对象 |
| | | * @param codeClassifyTemplateButtonDO 数据库中的数据对象 |
| | | * @return success为true为可以删除,false表示有数据引用,obj为true表示有下级 |
| | | */ |
| | | private R checkIsCanDeleteForDO(CodeClassifyTemplateButtonDTO codeClassifyTemplateButtonDTO, CodeClassifyTemplateButton codeClassifyTemplateButtonDO) { |
| | | CodeClassifyTemplateButton tsDO = new CodeClassifyTemplateButton(); |
| | | BeanUtil.convert(codeClassifyTemplateButtonDTO,tsDO); |
| | | if (!checkTs(tsDO,codeClassifyTemplateButtonDO)) { |
| | | return R.fail(TS_NOT_PROCESS); |
| | | } |
| | | if(!checkIsLinked(codeClassifyTemplateButtonDO.getOid())) { |
| | | return R.success("success"); |
| | | }else{ |
| | | return R.fail(DATA_LINKED_NOT_DELETE); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改主题库里模板包含的按钮 |
| | | * @param codeClassifyTemplateButtonDTO 主题库里模板包含的按钮数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateButtonVO editSave(CodeClassifyTemplateButtonDTO codeClassifyTemplateButtonDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateButtonDTO,"数据对象",codeClassifyTemplateButtonDTO.getOid(),"主题库里模板包含的按钮主键"); |
| | | //将DTO转换为DO |
| | | CodeClassifyTemplateButtonDO codeClassifyTemplateButtonDO = selectByOid(codeClassifyTemplateButtonDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeClassifyTemplateButtonDTO,codeClassifyTemplateButtonDO); |
| | | codeClassifyTemplateButtonMapper.updateByPrimaryKey(codeClassifyTemplateButtonDO); |
| | | return codeClassifyTemplateButtonDO2VO(codeClassifyTemplateButtonDO); |
| | | } |
| | | /** |
| | | * 检查ts |
| | | * @param tempDO |
| | | * @param codeClassifyTemplateButtonDO |
| | | * @return |
| | | */ |
| | | private boolean checkTs(CodeClassifyTemplateButton tempDO,CodeClassifyTemplateButton codeClassifyTemplateButtonDO){ |
| | | Date dbTs = codeClassifyTemplateButtonDO.getTs(); |
| | | Date currentTs = tempDO.getTs(); |
| | | if(currentTs == null ? dbTs == null:currentTs.compareTo(dbTs)==0){ |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 获取连表查询条件对象 |
| | | * @param conditionMap |
| | | * @return |
| | | */ |
| | | private MPJLambdaWrapper<CodeClassifyTemplateButton> getMPJLambdaWrapper(Map<String,String> conditionMap){ |
| | | CodeClassifyTemplateButton codeClassifyTemplateButton = new CodeClassifyTemplateButton(); |
| | | BeanMap beanMap = BeanMap.create(codeClassifyTemplateButton); |
| | | beanMap.putAll(conditionMap); |
| | | MPJLambdaWrapper<CodeClassifyTemplateButton> mpjLambdaWrapper = UBCSCondition.getMPJLambdaWrapper(codeClassifyTemplateButton) |
| | | .selectAll(CodeClassifyTemplateButton.class) |
| | | .selectAs(CodeButton::getName, CodeClassifyTemplateButton::getClassifyButtonOidName) |
| | | .selectAs(CodeButton::getId, CodeClassifyTemplateButton::getClassifyButtonId) |
| | | .leftJoin(CodeButton.class, CodeButton::getOid, CodeClassifyTemplateButton::getClassifyButtonOid); |
| | | return mpjLambdaWrapper; |
| | | } |
| | | |
| | | /** |
| | | * 校验是否可以删除,如果存在下级,并且下级有数据引用则不能删除 |
| | | * @param codeClassifyTemplateButtonDTO 数据传输对象 |
| | | * @param codeClassifyTemplateButtonDO 数据库中的数据对象 |
| | | * @return success为true为可以删除,false表示有数据引用,obj为true表示有下级 |
| | | */ |
| | | private BaseResult checkIsCanDeleteForDO(CodeClassifyTemplateButtonDTO codeClassifyTemplateButtonDTO, CodeClassifyTemplateButtonDO codeClassifyTemplateButtonDO) { |
| | | CodeClassifyTemplateButtonDO tsDO = new CodeClassifyTemplateButtonDO(); |
| | | BeanUtil.convert(codeClassifyTemplateButtonDTO,tsDO); |
| | | boService.checkTs(tsDO); |
| | | if(!checkIsLinked(codeClassifyTemplateButtonDO.getOid())) { |
| | | return BaseResult.success(); |
| | | }else{ |
| | | return BaseResult.fail(DATA_LINKED_NOT_DELETE,new String[]{""}); |
| | | } |
| | | } |
| | | /** |
| | | * 主键获取主题库里模板包含的按钮 |
| | | * @param oid 主键 |
| | | * @return 主题库里模板包含的按钮显示对象 |
| | | * @throws VciBaseException 参数为空,数据不存在时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateButtonVO getObjectByOid(String oid) throws VciBaseException{ |
| | | return codeClassifyTemplateButtonDO2VO(selectByOid(oid)); |
| | | } |
| | | |
| | | /** |
| | | * 校验是否被引用 |
| | | * @param oid 主键 |
| | | * @throws VciBaseException 被引用的时候会抛出异常 |
| | | */ |
| | | private boolean checkIsLinked(String oid) throws VciBaseException{ |
| | | //TODO 添加需要校验引用的地方 |
| | | return false; |
| | | } |
| | | /** |
| | | * 主键批量获取主题库里模板包含的按钮 |
| | | * @param oidCollections 主键集合,但是受性能影响,建议一次查询不超过10000个 |
| | | * @return 主题库里模板包含的按钮显示对象 |
| | | * @throws VciBaseException 查询出现异常时会抛出 |
| | | */ |
| | | @Override |
| | | public Collection<CodeClassifyTemplateButtonVO> listCodeClassifyTemplateButtonByOids(Collection<String> oidCollections) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oidCollections,"数据对象主键集合"); |
| | | List<CodeClassifyTemplateButton> codeClassifyTemplateButtonDOList = listCodeClassifyTemplateButtonDOByOidCollections(oidCollections); |
| | | return codeClassifyTemplateButtonDO2VOs(codeClassifyTemplateButtonDOList); |
| | | } |
| | | |
| | | /** |
| | | * 删除主题库里模板包含的按钮 |
| | | * @param codeClassifyTemplateButtonDTO 主题库里模板包含的按钮数据传输对象,oid和ts需要传输 |
| | | * @return 删除结果反馈::success:成功,fail:失败 |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | public BaseResult deleteCodeClassifyTemplateButton(CodeClassifyTemplateButtonDTO codeClassifyTemplateButtonDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateButtonDTO,"主题库里模板包含的按钮数据对象",codeClassifyTemplateButtonDTO.getOid(),"主题库里模板包含的按钮的主键"); |
| | | CodeClassifyTemplateButtonDO codeClassifyTemplateButtonDO = selectByOid(codeClassifyTemplateButtonDTO.getOid()); |
| | | BaseResult baseResult = checkIsCanDeleteForDO(codeClassifyTemplateButtonDTO,codeClassifyTemplateButtonDO); |
| | | if(baseResult.isSuccess()) { |
| | | }else{ |
| | | return baseResult; |
| | | } |
| | | //执行删除操作 |
| | | BatchCBO batchCBO = codeClassifyTemplateButtonMapper.deleteByPrimaryKey(codeClassifyTemplateButtonDO.getOid()); |
| | | return (batchCBO!=null && batchCBO.getDeleteCbos() !=null &&batchCBO.getDeleteCbos().size() > 0)?BaseResult.successMsg(DELETE_SUCCESS):BaseResult.fail(DELETE_FAIL); |
| | | } |
| | | /** |
| | | * 参照主题库里模板包含的按钮列表 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 主题库里模板包含的按钮显示对象列表,生效的内容 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public IPage<CodeClassifyTemplateButtonVO> refDataGridCodeClassifyTemplateButton(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if(conditionMap == null){ |
| | | conditionMap = new HashMap<String, String>(); |
| | | } |
| | | return gridCodeClassifyTemplateButton(conditionMap, pageHelper); |
| | | } |
| | | |
| | | /** |
| | | * 主键获取主题库里模板包含的按钮 |
| | | * @param oid 主键 |
| | | * @return 主题库里模板包含的按钮显示对象 |
| | | * @throws VciBaseException 参数为空,数据不存在时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateButtonVO getObjectByOid(String oid) throws VciBaseException{ |
| | | return codeClassifyTemplateButtonDO2VO(selectByOid(oid)); |
| | | } |
| | | /** |
| | | * 使用主键集合查询数据对象 |
| | | * @param oidCollections 主键的集合 |
| | | * @return 数据对象列表 |
| | | */ |
| | | private List<CodeClassifyTemplateButton> listCodeClassifyTemplateButtonDOByOidCollections(Collection<String> oidCollections){ |
| | | List<CodeClassifyTemplateButton> codeClassifyTemplateButtonDOList = new ArrayList<CodeClassifyTemplateButton>(); |
| | | if(!CollectionUtils.isEmpty(oidCollections)){ |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for(Collection<String> oids: oidCollectionsList){ |
| | | List<CodeClassifyTemplateButton> tempDOList = codeClassifyTemplateButtonMapper.selectBatchIds(oids); |
| | | if(!CollectionUtils.isEmpty(tempDOList)){ |
| | | codeClassifyTemplateButtonDOList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeClassifyTemplateButtonDOList; |
| | | } |
| | | |
| | | /** |
| | | * 主键查询数据对象 |
| | | * @param oid 主键 |
| | | * @return 数据对象 |
| | | * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常 |
| | | */ |
| | | private CodeClassifyTemplateButtonDO selectByOid(String oid) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oid,"主键"); |
| | | CodeClassifyTemplateButtonDO codeClassifyTemplateButtonDO = codeClassifyTemplateButtonMapper.selectByPrimaryKey(oid.trim()); |
| | | if(codeClassifyTemplateButtonDO == null || StringUtils.isBlank(codeClassifyTemplateButtonDO.getOid())){ |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | return codeClassifyTemplateButtonDO; |
| | | } |
| | | /** |
| | | * 校验是否被引用 |
| | | * @param oid 主键 |
| | | * @throws VciBaseException 被引用的时候会抛出异常 |
| | | */ |
| | | private boolean checkIsLinked(String oid) throws VciBaseException{ |
| | | //TODO 添加需要校验引用的地方 |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 主键批量获取主题库里模板包含的按钮 |
| | | * @param oidCollections 主键集合,但是受性能影响,建议一次查询不超过10000个 |
| | | * @return 主题库里模板包含的按钮显示对象 |
| | | * @throws VciBaseException 查询出现异常时会抛出 |
| | | */ |
| | | @Override |
| | | public Collection<CodeClassifyTemplateButtonVO> listCodeClassifyTemplateButtonByOids(Collection<String> oidCollections) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oidCollections,"数据对象主键集合"); |
| | | List<CodeClassifyTemplateButtonDO> codeClassifyTemplateButtonDOList = listCodeClassifyTemplateButtonDOByOidCollections(oidCollections); |
| | | return codeClassifyTemplateButtonDO2VOs(codeClassifyTemplateButtonDOList); |
| | | } |
| | | /** |
| | | * 主键查询数据对象 |
| | | * @param oid 主键 |
| | | * @return 数据对象 |
| | | * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常 |
| | | */ |
| | | private CodeClassifyTemplateButton selectByOid(String oid) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oid,"主键"); |
| | | HashMap<String, String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("oid",oid); |
| | | MPJLambdaWrapper<CodeClassifyTemplateButton> mpjLambdaWrapper = getMPJLambdaWrapper(conditionMap); |
| | | CodeClassifyTemplateButton codeClassifyTemplateButtonDO = codeClassifyTemplateButtonMapper.selectOne(mpjLambdaWrapper); |
| | | if(codeClassifyTemplateButtonDO == null || StringUtils.isBlank(codeClassifyTemplateButtonDO.getOid())){ |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | return codeClassifyTemplateButtonDO; |
| | | } |
| | | |
| | | /** |
| | | * 使用主键集合查询数据对象 |
| | | * @param oidCollections 主键的集合 |
| | | * @return 数据对象列表 |
| | | */ |
| | | private List<CodeClassifyTemplateButtonDO> listCodeClassifyTemplateButtonDOByOidCollections(Collection<String> oidCollections){ |
| | | List<CodeClassifyTemplateButtonDO> codeClassifyTemplateButtonDOList = new ArrayList<CodeClassifyTemplateButtonDO>(); |
| | | if(!CollectionUtils.isEmpty(oidCollections)){ |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for(Collection<String> oids: oidCollectionsList){ |
| | | List<CodeClassifyTemplateButtonDO> tempDOList = codeClassifyTemplateButtonMapper.selectByPrimaryKeyCollection(oids); |
| | | if(!CollectionUtils.isEmpty(tempDOList)){ |
| | | codeClassifyTemplateButtonDOList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeClassifyTemplateButtonDOList; |
| | | } |
| | | /** |
| | | * 模板删除的时候触发 |
| | | * |
| | | * @param classifyTemplateOid 模板的主键 |
| | | * @return 受影响的数据行 |
| | | */ |
| | | @Override |
| | | public int codeTemplateDeleteTrigger(String classifyTemplateOid) { |
| | | int updateCount = 0; |
| | | if(StringUtils.isNotBlank(classifyTemplateOid)){ |
| | | Map<String,Object> conditionMap = new HashMap<>(); |
| | | conditionMap.put("classifyTemplateOid",classifyTemplateOid); |
| | | List<CodeClassifyTemplateButton> codeTempbuttonEntities = baseMapper.selectByMap(conditionMap); |
| | | if(!CollectionUtils.isEmpty(codeTempbuttonEntities)){ |
| | | updateCount += baseMapper.deleteBatchIds(codeTempbuttonEntities.stream() |
| | | .map(CodeClassifyTemplateButton::getOid).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | return updateCount; |
| | | } |
| | | |
| | | /** |
| | | * 使用模板主键获取扩展的按钮 |
| | | * |
| | | * @param templateOid 模板的主键 |
| | | * @param hasButtonVO 是否包含按钮的显示信息 |
| | | * @return 按钮的相关的信息 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateButtonVO> listButtonByTemplateOid(String templateOid, boolean hasButtonVO) { |
| | | if(StringUtils.isBlank(templateOid)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | // Map<String,String> conditionMap = new HashMap<>(); |
| | | // conditionMap.put("classifyTemplateOid",templateOid); |
| | | // PageHelper pageHelper = new PageHelper(-1); |
| | | // pageHelper.addDefaultAsc("orderNum"); |
| | | QueryWrapper<CodeClassifyTemplateButton> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("classifyTemplateOid",templateOid); |
| | | wrapper.orderByAsc("orderNum"); |
| | | List<CodeClassifyTemplateButton> templateButtonDOS = codeClassifyTemplateButtonMapper.selectList(wrapper); |
| | | return codeClassifyTemplateButtonDO2VOs(templateButtonDOS,hasButtonVO); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 参照主题库里模板包含的按钮列表 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 主题库里模板包含的按钮显示对象列表,生效的内容 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeClassifyTemplateButtonVO> refDataGridCodeClassifyTemplateButton(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if(conditionMap == null){ |
| | | conditionMap = new HashMap<String, String>(); |
| | | } |
| | | return gridCodeClassifyTemplateButton(conditionMap,pageHelper); |
| | | } |
| | | |
| | | /** |
| | | * 模板删除的时候触发 |
| | | * |
| | | * @param classifyTemplateOid 模板的主键 |
| | | * @return 受影响的数据 |
| | | */ |
| | | @Override |
| | | public BatchCBO codeTemplateDeleteTrigger(String classifyTemplateOid) { |
| | | BatchCBO batchCBO = new BatchCBO(); |
| | | if(StringUtils.isNotBlank(classifyTemplateOid)){ |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("classifyTemplateOid",classifyTemplateOid); |
| | | List<CodeClassifyTemplateButtonDO> templateButtonDOS = codeClassifyTemplateButtonMapper.selectByCondition(conditionMap, new PageHelper(-1)); |
| | | if(!CollectionUtils.isEmpty(templateButtonDOS)){ |
| | | batchCBO.copyFromOther(codeClassifyTemplateButtonMapper.batchDeleteByOids(templateButtonDOS.stream().map(CodeClassifyTemplateButtonDO::getOid).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | return batchCBO; |
| | | } |
| | | |
| | | /** |
| | | * 使用模板主键获取扩展的按钮 |
| | | * |
| | | * @param templateOid 模板的主键 |
| | | * @return 按钮的相关的信息 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateButtonVO> listButtonByTemplateOid(String templateOid) { |
| | | return listButtonByTemplateOid(templateOid,false); |
| | | } |
| | | |
| | | /** |
| | | * 使用模板主键获取扩展的按钮 |
| | | * |
| | | * @param templateOid 模板的主键 |
| | | * @param hasButtonVO 是否包含按钮的显示信息 |
| | | * @return 按钮的相关的信息 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateButtonVO> listButtonByTemplateOid(String templateOid, boolean hasButtonVO) { |
| | | if(StringUtils.isBlank(templateOid)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("classifyTemplateOid",templateOid); |
| | | PageHelper pageHelper = new PageHelper(-1); |
| | | pageHelper.addDefaultAsc("orderNum"); |
| | | List<CodeClassifyTemplateButtonDO> templateButtonDOS = codeClassifyTemplateButtonMapper.selectByCondition(conditionMap, pageHelper); |
| | | return codeClassifyTemplateButtonDO2VOs(templateButtonDOS,hasButtonVO); |
| | | } |
| | | } |
| | | |