| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | |
| | | import com.vci.ubcs.code.dao.CodeClassifyProcessTempDaoI; |
| | | import com.vci.ubcs.code.model.CodeClassifyProcessTempDO; |
| | | import com.vci.ubcs.code.service.CodeClassifyProcessTempServiceI; |
| | | 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.starter.web.wrapper.VciQueryWrapperForDO; |
| | | import com.vci.web.pageModel.BatchCBO; |
| | | import com.vci.web.service.WebBoServiceI; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | 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.vci.ubcs.code.constant.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.code.dto.CodeClassifyProcessTempDTO; |
| | | import com.vci.ubcs.code.entity.CodeClassifyProcessTemp; |
| | | import com.vci.ubcs.code.mapper.CodeClassifyProcessTempMapper; |
| | | import com.vci.ubcs.code.service.ICodeClassifyProcessTempService; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyProcessTempVO; |
| | | import com.vci.ubcs.code.wrapper.CodeClassifyProcessTempWrapper; |
| | | 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.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.FrameWorkBusLangCodeConstant.*; |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*; |
| | | |
| | | /** |
| | | * 分类使用的流程模板服务 |
| | | * @author weidy |
| | | * @date 2022-01-24 |
| | | * 分类使用的流程模板服务接口 |
| | | * |
| | | * @author ludc |
| | | * @date 2023/5/5 |
| | | */ |
| | | @Service |
| | | public class CodeClassifyProcessTempServiceImpl implements CodeClassifyProcessTempServiceI { |
| | | public class CodeClassifyProcessTempServiceImpl extends ServiceImpl<CodeClassifyProcessTempMapper, CodeClassifyProcessTemp> implements ICodeClassifyProcessTempService { |
| | | |
| | | /** |
| | | * 日志 |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | /** |
| | | * 数据操作层 |
| | | */ |
| | | @Resource |
| | | private CodeClassifyProcessTempMapper codeClassifyProcessTempMapper; |
| | | |
| | | /** |
| | | * 数据操作层 |
| | | */ |
| | | @Resource |
| | | private CodeClassifyProcessTempDaoI codeClassifyProcessTempMapper; |
| | | /** |
| | | * 对象的操作 |
| | | */ |
| | | @Autowired |
| | | private RevisionModelUtil revisionModelUtil; |
| | | |
| | | /** |
| | | * 查询所有的分类使用的流程模板 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public IPage<CodeClassifyProcessTempVO> gridCodeClassifyProcessTemp(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException { |
| | | Query query = new Query(); |
| | | if (pageHelper == null) { |
| | | //pageHelper = new PageHelper(-1); |
| | | query.setSize(-1); |
| | | }else { |
| | | query.setSize(pageHelper.getLimit()); |
| | | query.setCurrent(pageHelper.getPage()); |
| | | } |
| | | query.setDescs("createTime"); |
| | | CodeClassifyProcessTemp codeClassifyProcessTemp = new CodeClassifyProcessTemp(); |
| | | BeanMap beanMap = BeanMap.create(codeClassifyProcessTemp); |
| | | beanMap.putAll(conditionMap); |
| | | IPage<CodeClassifyProcessTemp> doList = codeClassifyProcessTempMapper.selectPage(Condition.getPage(query), Condition.getQueryWrapper(codeClassifyProcessTemp)); |
| | | IPage<CodeClassifyProcessTempVO> voList = new Page<>(); |
| | | //DataGrid<CodeClassifyProcessTempVO> dataGrid=new DataGrid<>(); |
| | | if (!CollectionUtils.isEmpty(doList.getRecords())) { |
| | | voList = CodeClassifyProcessTempWrapper.build().pageVO(doList); |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | /** |
| | | * 业务类型操作的服务 |
| | | */ |
| | | @Autowired |
| | | @Lazy |
| | | private WebBoServiceI boService; |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * @param codeClassifyProcessTempDOs 数据对象列表 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyProcessTempVO> codeClassifyProcessTempDO2VOs(Collection<CodeClassifyProcessTemp> codeClassifyProcessTempDOs) throws VciBaseException{ |
| | | List<CodeClassifyProcessTempVO> voList = new ArrayList<CodeClassifyProcessTempVO>(); |
| | | if(!CollectionUtils.isEmpty(codeClassifyProcessTempDOs)){ |
| | | codeClassifyProcessTempDOs.forEach(temp -> { |
| | | CodeClassifyProcessTempVO tempVO = codeClassifyProcessTempDO2VO(temp); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(temp,tempVO); |
| | | voList.add(tempVO); |
| | | }); |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | /** |
| | | * 对象的操作 |
| | | */ |
| | | @Autowired |
| | | private RevisionModelUtil revisionModelUtil; |
| | | /** |
| | | * 数据对象转换为显示对象 |
| | | * @param codeClassifyProcessTempDO 数据对象 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 拷贝属性出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyProcessTempVO codeClassifyProcessTempDO2VO(CodeClassifyProcessTemp codeClassifyProcessTempDO) throws VciBaseException{ |
| | | CodeClassifyProcessTempVO vo = new CodeClassifyProcessTempVO(); |
| | | if(codeClassifyProcessTempDO != null){ |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyProcessTempDO,vo); |
| | | //如果有lcstatus的类的话 |
| | | //处理关联的模板属性 |
| | | |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * 查询所有的分类使用的流程模板 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeClassifyProcessTempVO> gridCodeClassifyProcessTemp(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException { |
| | | if (pageHelper == null) { |
| | | pageHelper = new PageHelper(-1); |
| | | } |
| | | pageHelper.addDefaultDesc("createTime"); |
| | | List<CodeClassifyProcessTempDO> doList = codeClassifyProcessTempMapper.selectByCondition(conditionMap,pageHelper); |
| | | DataGrid<CodeClassifyProcessTempVO> dataGrid=new DataGrid<CodeClassifyProcessTempVO>(); |
| | | if (!CollectionUtils.isEmpty(doList)) { |
| | | dataGrid.setData(codeClassifyProcessTempDO2VOs(doList)); |
| | | dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(codeClassifyProcessTempMapper.countByCondition(conditionMap)))); |
| | | } |
| | | return dataGrid; |
| | | } |
| | | /** |
| | | * 增加分类使用的流程模板 |
| | | * @param codeClassifyProcessTempDTO 分类使用的流程模板数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public CodeClassifyProcessTempVO addSave(CodeClassifyProcessTempDTO codeClassifyProcessTempDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyProcessTempDTO,"需要添加的数据对象",codeClassifyProcessTempDTO.getProcessVersion(),"流程模板的版本号",codeClassifyProcessTempDTO.getCodeProcessUse(),"模板流程的用途"); |
| | | if (StringUtils.isBlank(codeClassifyProcessTempDTO.getCodeProcessUse())){ |
| | | throw new VciBaseException("模板流程用途不能为空"); |
| | | } |
| | | Long count = countProcessTemplate(codeClassifyProcessTempDTO); |
| | | if(count > 0){ |
| | | throw new VciBaseException("已存在相同的流程模板"); |
| | | } |
| | | //将DTO转换为DO |
| | | CodeClassifyProcessTemp codeClassifyProcessTempDO = new CodeClassifyProcessTemp(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyProcessTempDTO,codeClassifyProcessTempDO); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeClassifyProcessTempDO, MdmBtmTypeConstant.CODE_CLASSIFY_PROCESS_TEMPLATE); |
| | | codeClassifyProcessTempMapper.insert(codeClassifyProcessTempDO); |
| | | //因为业务类型本身没有控制版本,所有强制给版本revisionValue设置值,平台也会变成空。。。。 |
| | | //版本号不能使用默认的属性 |
| | | return CodeClassifyProcessTempWrapper.build().entityVO(codeClassifyProcessTempDO); |
| | | } |
| | | |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * @param codeClassifyProcessTempDOs 数据对象列表 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyProcessTempVO> codeClassifyProcessTempDO2VOs(Collection<CodeClassifyProcessTempDO> codeClassifyProcessTempDOs) throws VciBaseException{ |
| | | List<CodeClassifyProcessTempVO> voList = new ArrayList<CodeClassifyProcessTempVO>(); |
| | | if(!CollectionUtils.isEmpty(codeClassifyProcessTempDOs)){ |
| | | codeClassifyProcessTempDOs.forEach(temp -> { |
| | | CodeClassifyProcessTempVO tempVO = codeClassifyProcessTempDO2VO(temp); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(temp,tempVO); |
| | | voList.add(tempVO); |
| | | }); |
| | | } |
| | | return voList; |
| | | } |
| | | /** |
| | | * 修改分类使用的流程模板 |
| | | * @param codeClassifyProcessTempDTO 分类使用的流程模板数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public CodeClassifyProcessTempVO editSave(CodeClassifyProcessTempDTO codeClassifyProcessTempDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyProcessTempDTO,"数据对象",codeClassifyProcessTempDTO.getOid(),"分类使用的流程模板主键",codeClassifyProcessTempDTO.getProcessVersion(),"流程模板的版本号",codeClassifyProcessTempDTO.getName(),"流程模板的名称"); |
| | | //将DTO转换为DO |
| | | CodeClassifyProcessTemp codeClassifyProcessTempDO = selectByOid(codeClassifyProcessTempDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeClassifyProcessTempDTO,codeClassifyProcessTempDO); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeClassifyProcessTempDO); |
| | | codeClassifyProcessTempMapper.updateById(codeClassifyProcessTempDO); |
| | | return CodeClassifyProcessTempWrapper.build().entityVO(codeClassifyProcessTempDO); |
| | | } |
| | | |
| | | /** |
| | | * 数据对象转换为显示对象 |
| | | * @param codeClassifyProcessTempDO 数据对象 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 拷贝属性出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyProcessTempVO codeClassifyProcessTempDO2VO(CodeClassifyProcessTempDO codeClassifyProcessTempDO) throws VciBaseException{ |
| | | CodeClassifyProcessTempVO vo = new CodeClassifyProcessTempVO(); |
| | | if(codeClassifyProcessTempDO != null){ |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyProcessTempDO,vo); |
| | | //如果有lcstatus的类的话 |
| | | //处理关联的模板属性 |
| | | /** |
| | | * 删除分类使用的流程模板 |
| | | * @param codeClassifyProcessTempDTO 分类使用的流程模板数据传输对象,oid和ts需要传输 |
| | | * @return 删除结果反馈::success:成功,fail:失败 |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R deleteCodeClassifyProcessTemp(CodeClassifyProcessTempDTO codeClassifyProcessTempDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyProcessTempDTO,"分类使用的流程模板数据对象",codeClassifyProcessTempDTO.getOid(),"分类使用的流程模板的主键"); |
| | | CodeClassifyProcessTemp codeClassifyProcessTempDO = selectByOid(codeClassifyProcessTempDTO.getOid()); |
| | | R baseResult = checkIsCanDeleteForDO(codeClassifyProcessTempDTO,codeClassifyProcessTempDO); |
| | | if(baseResult.isSuccess()) { |
| | | }else{ |
| | | return baseResult; |
| | | } |
| | | //执行删除操作 |
| | | boolean batchCBO = codeClassifyProcessTempMapper.deleteById(codeClassifyProcessTempDO.getOid()) > 0; |
| | | return batchCBO?R.success(DELETE_SUCCESS):R.fail(DELETE_FAIL); |
| | | } |
| | | |
| | | } |
| | | return vo; |
| | | } |
| | | /** |
| | | * 主键获取分类使用的流程模板 |
| | | * @param oid 主键 |
| | | * @return 分类使用的流程模板显示对象 |
| | | * @throws VciBaseException 参数为空,数据不存在时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyProcessTempVO getObjectByOid(String oid) throws VciBaseException{ |
| | | return CodeClassifyProcessTempWrapper.build().entityVO((selectByOid(oid))); |
| | | } |
| | | |
| | | /** |
| | | * 增加分类使用的流程模板 |
| | | * @param codeClassifyProcessTempDTO 分类使用的流程模板数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyProcessTempVO addSave(CodeClassifyProcessTempDTO codeClassifyProcessTempDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyProcessTempDTO,"需要添加的数据对象",codeClassifyProcessTempDTO.getProcessVersion(),"流程模板的版本号",codeClassifyProcessTempDTO.getCodeprocessuse(),"模板流程的用途"); |
| | | if (StringUtils.isBlank(codeClassifyProcessTempDTO.getCodeprocessuse())){ |
| | | throw new VciBaseException("模板流程用途不能为空"); |
| | | } |
| | | Long count = countProcessTemplate(codeClassifyProcessTempDTO); |
| | | if(count > 0){ |
| | | throw new VciBaseException("已存在相同的流程模板"); |
| | | } |
| | | //将DTO转换为DO |
| | | CodeClassifyProcessTempDO codeClassifyProcessTempDO = new CodeClassifyProcessTempDO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyProcessTempDTO,codeClassifyProcessTempDO); |
| | | codeClassifyProcessTempMapper.insert(codeClassifyProcessTempDO); |
| | | //因为业务类型本身没有控制版本,所有强制给版本revisionValue设置值,平台也会变成空。。。。 |
| | | //版本号不能使用默认的属性 |
| | | return codeClassifyProcessTempDO2VO(codeClassifyProcessTempDO); |
| | | } |
| | | /** |
| | | * 主键批量获取分类使用的流程模板 |
| | | * @param oidCollections 主键集合,但是受性能影响,建议一次查询不超过10000个 |
| | | * @return 分类使用的流程模板显示对象 |
| | | * @throws VciBaseException 查询出现异常时会抛出 |
| | | */ |
| | | @Override |
| | | public Collection<CodeClassifyProcessTempVO> listCodeClassifyProcessTempByOids(Collection<String> oidCollections) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oidCollections,"数据对象主键集合"); |
| | | List<CodeClassifyProcessTemp> codeClassifyProcessTempDOList = listCodeClassifyProcessTempDOByOidCollections(oidCollections); |
| | | return CodeClassifyProcessTempWrapper.build().listVO(codeClassifyProcessTempDOList); |
| | | } |
| | | |
| | | /** |
| | | * 获取流程模板是否已经存在了 |
| | | * @param codeClassifyProcessTempDTO 数据传输对象 |
| | | * @return 个数 |
| | | */ |
| | | private Long countProcessTemplate(CodeClassifyProcessTempDTO codeClassifyProcessTempDTO) { |
| | | String templateName = codeClassifyProcessTempDTO.getName(); |
| | | if (StringUtils.isBlank(templateName)){ |
| | | throw new VciBaseException("模板流程名称不能为空"); |
| | | } |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("codeProcessUse",codeClassifyProcessTempDTO.getCodeprocessuse()); |
| | | conditionMap.put("id",codeClassifyProcessTempDTO.getId()); |
| | | conditionMap.put("classifyTemplateOid", codeClassifyProcessTempDTO.getClassifyTemplateOid()); |
| | | VciQueryWrapperForDO wrapper = new VciQueryWrapperForDO(conditionMap,CodeClassifyProcessTempDO.class); |
| | | Long count = codeClassifyProcessTempMapper.countByWrapper(wrapper); |
| | | return count; |
| | | } |
| | | /** |
| | | * 参照分类使用的流程模板列表 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 分类使用的流程模板显示对象列表,生效的内容 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public IPage<CodeClassifyProcessTempVO> refDataGridCodeClassifyProcessTemp(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if(conditionMap == null){ |
| | | conditionMap = new HashMap<String, String>(); |
| | | } |
| | | return gridCodeClassifyProcessTemp(conditionMap,pageHelper); |
| | | |
| | | /** |
| | | * 修改分类使用的流程模板 |
| | | * @param codeClassifyProcessTempDTO 分类使用的流程模板数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyProcessTempVO editSave(CodeClassifyProcessTempDTO codeClassifyProcessTempDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyProcessTempDTO,"数据对象",codeClassifyProcessTempDTO.getOid(),"分类使用的流程模板主键",codeClassifyProcessTempDTO.getProcessVersion(),"流程模板的版本号",codeClassifyProcessTempDTO.getName(),"流程模板的名称"); |
| | | //将DTO转换为DO |
| | | CodeClassifyProcessTempDO codeClassifyProcessTempDO = selectByOid(codeClassifyProcessTempDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeClassifyProcessTempDTO,codeClassifyProcessTempDO); |
| | | codeClassifyProcessTempMapper.updateByPrimaryKey(codeClassifyProcessTempDO); |
| | | return codeClassifyProcessTempDO2VO(codeClassifyProcessTempDO); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取流程的模板的信息 |
| | | * |
| | | * @param codeTemplateOid 模板的主键 |
| | | * @param processUse 用途 |
| | | * @return 模板的信息 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyProcessTempVO> listProcessTemplate(String codeTemplateOid, String processUse) { |
| | | if(StringUtils.isBlank(codeTemplateOid) || StringUtils.isBlank(processUse)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | Map<String,String> conditionMap =new HashMap<>(); |
| | | conditionMap.put("classifyTemplateOid",codeTemplateOid); |
| | | conditionMap.put("codeprocessuse",processUse); |
| | | LambdaQueryWrapper<CodeClassifyProcessTemp> wrapper = Wrappers.<CodeClassifyProcessTemp>query() |
| | | .lambda().eq(CodeClassifyProcessTemp::getClassifyTemplateOid, codeTemplateOid) |
| | | .eq(CodeClassifyProcessTemp::getCodeProcessUse, processUse); |
| | | return CodeClassifyProcessTempWrapper.build().listVO(codeClassifyProcessTempMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | /** |
| | | * 校验是否可以删除,如果存在下级,并且下级有数据引用则不能删除 |
| | | * @param codeClassifyProcessTempDTO 数据传输对象 |
| | | * @param codeClassifyProcessTempDO 数据库中的数据对象 |
| | | * @return success为true为可以删除,false表示有数据引用,obj为true表示有下级 |
| | | */ |
| | | private BaseResult checkIsCanDeleteForDO(CodeClassifyProcessTempDTO codeClassifyProcessTempDTO, CodeClassifyProcessTempDO codeClassifyProcessTempDO) { |
| | | CodeClassifyProcessTempDO tempDO = new CodeClassifyProcessTempDO(); |
| | | BeanUtil.convert(codeClassifyProcessTempDTO,tempDO); |
| | | boService.checkTs(tempDO); |
| | | if(!checkIsLinked(codeClassifyProcessTempDO.getOid())) { |
| | | return BaseResult.success(); |
| | | }else{ |
| | | return BaseResult.fail(DATA_LINKED_NOT_DELETE,new String[]{""}); |
| | | } |
| | | } |
| | | /** |
| | | * 使用查询封装器来查询 |
| | | * @param queryWrapper 查询封装器 |
| | | * @return 数据对象 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyProcessTempVO> selectByWrapper(LambdaQueryWrapper<CodeClassifyProcessTemp> queryWrapper) { |
| | | List<CodeClassifyProcessTemp> codeClassifyProcessTempDOList= codeClassifyProcessTempMapper.selectList(queryWrapper); |
| | | return CodeClassifyProcessTempWrapper.build().listVO(codeClassifyProcessTempDOList); |
| | | } |
| | | |
| | | /** |
| | | * 校验是否被引用 |
| | | * @param oid 主键 |
| | | * @throws VciBaseException 被引用的时候会抛出异常 |
| | | */ |
| | | private boolean checkIsLinked(String oid) throws VciBaseException{ |
| | | //TODO 添加需要校验引用的地方 |
| | | return false; |
| | | } |
| | | /** |
| | | * 使用主键集合查询数据对象 |
| | | * @param oidCollections 主键的集合 |
| | | * @return 数据对象列表 |
| | | */ |
| | | private List<CodeClassifyProcessTemp> listCodeClassifyProcessTempDOByOidCollections(Collection<String> oidCollections){ |
| | | List<CodeClassifyProcessTemp> codeClassifyProcessTempDOList = new ArrayList<CodeClassifyProcessTemp>(); |
| | | if(!CollectionUtils.isEmpty(oidCollections)){ |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for(Collection<String> oids: oidCollectionsList){ |
| | | //List<CodeClassifyProcessTemp> tempDOList = codeClassifyProcessTempMapper.selectByPrimaryKeyCollection(oids); |
| | | List<CodeClassifyProcessTemp> tempDOList = codeClassifyProcessTempMapper.selectBatchIds(oids); |
| | | if(!CollectionUtils.isEmpty(tempDOList)){ |
| | | codeClassifyProcessTempDOList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeClassifyProcessTempDOList; |
| | | } |
| | | |
| | | /** |
| | | * 删除分类使用的流程模板 |
| | | * @param codeClassifyProcessTempDTO 分类使用的流程模板数据传输对象,oid和ts需要传输 |
| | | * @return 删除结果反馈::success:成功,fail:失败 |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | public BaseResult deleteCodeClassifyProcessTemp(CodeClassifyProcessTempDTO codeClassifyProcessTempDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyProcessTempDTO,"分类使用的流程模板数据对象",codeClassifyProcessTempDTO.getOid(),"分类使用的流程模板的主键"); |
| | | CodeClassifyProcessTempDO codeClassifyProcessTempDO = selectByOid(codeClassifyProcessTempDTO.getOid()); |
| | | BaseResult baseResult = checkIsCanDeleteForDO(codeClassifyProcessTempDTO,codeClassifyProcessTempDO); |
| | | if(baseResult.isSuccess()) { |
| | | }else{ |
| | | return baseResult; |
| | | } |
| | | //执行删除操作 |
| | | BatchCBO batchCBO = codeClassifyProcessTempMapper.deleteByPrimaryKey(codeClassifyProcessTempDO.getOid()); |
| | | return (batchCBO!=null && batchCBO.getDeleteCbos() !=null &&batchCBO.getDeleteCbos().size() > 0)?BaseResult.successMsg(DELETE_SUCCESS):BaseResult.fail(DELETE_FAIL); |
| | | } |
| | | /** |
| | | * 校验是否可以删除,如果存在下级,并且下级有数据引用则不能删除 |
| | | * @param codeClassifyProcessTempDTO 数据传输对象 |
| | | * @param codeClassifyProcessTempDO 数据库中的数据对象 |
| | | * @return success为true为可以删除,false表示有数据引用,obj为true表示有下级 |
| | | */ |
| | | private R checkIsCanDeleteForDO(CodeClassifyProcessTempDTO codeClassifyProcessTempDTO, CodeClassifyProcessTemp codeClassifyProcessTempDO) { |
| | | CodeClassifyProcessTemp tempDO = new CodeClassifyProcessTemp(); |
| | | BeanUtil.convert(codeClassifyProcessTempDTO,tempDO); |
| | | if (!checkTs(tempDO,codeClassifyProcessTempDO)) { |
| | | return R.fail(TS_NOT_PROCESS); |
| | | } |
| | | if(!checkIsLinked(codeClassifyProcessTempDO.getOid())) { |
| | | return R.success("success"); |
| | | }else{ |
| | | return R.fail(DATA_LINKED_NOT_DELETE); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 主键获取分类使用的流程模板 |
| | | * @param oid 主键 |
| | | * @return 分类使用的流程模板显示对象 |
| | | * @throws VciBaseException 参数为空,数据不存在时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyProcessTempVO getObjectByOid(String oid) throws VciBaseException{ |
| | | return codeClassifyProcessTempDO2VO(selectByOid(oid)); |
| | | } |
| | | /** |
| | | * 检查ts |
| | | * @param tempDO |
| | | * @return |
| | | */ |
| | | private boolean checkTs(CodeClassifyProcessTemp tempDO, CodeClassifyProcessTemp codeClassifyProcessTempDO){ |
| | | Date dbTs = codeClassifyProcessTempDO.getTs(); |
| | | Date currentTs = tempDO.getTs(); |
| | | if(currentTs == null ? dbTs == null:currentTs.compareTo(dbTs)==0){ |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 主键查询数据对象 |
| | | * @param oid 主键 |
| | | * @return 数据对象 |
| | | * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常 |
| | | */ |
| | | private CodeClassifyProcessTempDO selectByOid(String oid) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oid,"主键"); |
| | | CodeClassifyProcessTempDO codeClassifyProcessTempDO = codeClassifyProcessTempMapper.selectByPrimaryKey(oid.trim()); |
| | | if(codeClassifyProcessTempDO == null || StringUtils.isBlank(codeClassifyProcessTempDO.getOid())){ |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | return codeClassifyProcessTempDO; |
| | | } |
| | | /** |
| | | * 校验是否被引用 |
| | | * @param oid 主键 |
| | | * @throws VciBaseException 被引用的时候会抛出异常 |
| | | */ |
| | | private boolean checkIsLinked(String oid) throws VciBaseException{ |
| | | //TODO 添加需要校验引用的地方 |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 主键批量获取分类使用的流程模板 |
| | | * @param oidCollections 主键集合,但是受性能影响,建议一次查询不超过10000个 |
| | | * @return 分类使用的流程模板显示对象 |
| | | * @throws VciBaseException 查询出现异常时会抛出 |
| | | */ |
| | | @Override |
| | | public Collection<CodeClassifyProcessTempVO> listCodeClassifyProcessTempByOids(Collection<String> oidCollections) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oidCollections,"数据对象主键集合"); |
| | | List<CodeClassifyProcessTempDO> codeClassifyProcessTempDOList = listCodeClassifyProcessTempDOByOidCollections(oidCollections); |
| | | return codeClassifyProcessTempDO2VOs(codeClassifyProcessTempDOList); |
| | | } |
| | | /** |
| | | * 主键查询数据对象 |
| | | * @param oid 主键 |
| | | * @return 数据对象 |
| | | * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常 |
| | | */ |
| | | private CodeClassifyProcessTemp selectByOid(String oid) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oid,"主键"); |
| | | CodeClassifyProcessTemp codeClassifyProcessTempDO = codeClassifyProcessTempMapper.selectById(oid.trim()); |
| | | if(codeClassifyProcessTempDO == null || StringUtils.isBlank(codeClassifyProcessTempDO.getOid())){ |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | return codeClassifyProcessTempDO; |
| | | } |
| | | |
| | | /** |
| | | * 使用主键集合查询数据对象 |
| | | * @param oidCollections 主键的集合 |
| | | * @return 数据对象列表 |
| | | */ |
| | | private List<CodeClassifyProcessTempDO> listCodeClassifyProcessTempDOByOidCollections(Collection<String> oidCollections){ |
| | | List<CodeClassifyProcessTempDO> codeClassifyProcessTempDOList = new ArrayList<CodeClassifyProcessTempDO>(); |
| | | if(!CollectionUtils.isEmpty(oidCollections)){ |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for(Collection<String> oids: oidCollectionsList){ |
| | | List<CodeClassifyProcessTempDO> tempDOList = codeClassifyProcessTempMapper.selectByPrimaryKeyCollection(oids); |
| | | if(!CollectionUtils.isEmpty(tempDOList)){ |
| | | codeClassifyProcessTempDOList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeClassifyProcessTempDOList; |
| | | } |
| | | /** |
| | | * 获取流程模板是否已经存在了 |
| | | * @param codeClassifyProcessTempDTO 数据传输对象 |
| | | * @return 个数 |
| | | */ |
| | | private Long countProcessTemplate(CodeClassifyProcessTempDTO codeClassifyProcessTempDTO) { |
| | | String templateName = codeClassifyProcessTempDTO.getName(); |
| | | if (StringUtils.isBlank(templateName)){ |
| | | throw new VciBaseException("模板流程名称不能为空"); |
| | | } |
| | | LambdaQueryWrapper<CodeClassifyProcessTemp> wrapper = Wrappers.<CodeClassifyProcessTemp>query() |
| | | .lambda().eq(CodeClassifyProcessTemp::getCodeProcessUse, codeClassifyProcessTempDTO.getCodeProcessUse()) |
| | | .eq(CodeClassifyProcessTemp::getClassifyTemplateOid, codeClassifyProcessTempDTO.getClassifyTemplateOid()) |
| | | .eq(CodeClassifyProcessTemp::getId, codeClassifyProcessTempDTO.getId()); |
| | | Long count = codeClassifyProcessTempMapper.selectCount(wrapper); |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | | * 模板删除的时候触发 |
| | | * |
| | | * @param classifyTemplateOid 模板的主键 |
| | | * @return 受影响的内容 |
| | | */ |
| | | @Override |
| | | public int codeTemplateDeleteTrigger(String classifyTemplateOid) { |
| | | int updateCount = 0; |
| | | if(com.alibaba.nacos.api.utils.StringUtils.isBlank(classifyTemplateOid)){ |
| | | Map<String,Object> conditionMap = new HashMap<>(); |
| | | conditionMap.put("classifyTemplateOid",classifyTemplateOid); |
| | | List<CodeClassifyProcessTemp> codeClsflowtempEntities = baseMapper.selectByMap(conditionMap); |
| | | if(!CollectionUtils.isEmpty(codeClsflowtempEntities)){ |
| | | updateCount += baseMapper.deleteBatchIds(codeClsflowtempEntities.stream() |
| | | .map(CodeClassifyProcessTemp::getOid).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | return updateCount; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 参照分类使用的流程模板列表 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 分类使用的流程模板显示对象列表,生效的内容 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeClassifyProcessTempVO> refDataGridCodeClassifyProcessTemp(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if(conditionMap == null){ |
| | | conditionMap = new HashMap<String, String>(); |
| | | } |
| | | return gridCodeClassifyProcessTemp(conditionMap,pageHelper); |
| | | } |
| | | |
| | | /** |
| | | * 模板删除的时候触发 |
| | | * |
| | | * @param classifyTemplateOid 模板的主键 |
| | | * @return 受影响的内容 |
| | | */ |
| | | @Override |
| | | public BatchCBO codeTemplateDeleteTrigger(String classifyTemplateOid) { |
| | | BatchCBO batchCBO = new BatchCBO(); |
| | | if(StringUtils.isBlank(classifyTemplateOid)){ |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("classifyTemplateOid",classifyTemplateOid); |
| | | List<CodeClassifyProcessTempDO> processTempDOS = codeClassifyProcessTempMapper.selectByCondition(conditionMap, new PageHelper(-1)); |
| | | if(!CollectionUtils.isEmpty(processTempDOS)){ |
| | | batchCBO.copyFromOther(codeClassifyProcessTempMapper.batchDeleteByOids(processTempDOS.stream().map(CodeClassifyProcessTempDO::getOid).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | return batchCBO; |
| | | } |
| | | |
| | | /** |
| | | * 获取流程的模板的信息 |
| | | * |
| | | * @param codeTemplateOid 模板的主键 |
| | | * @param processUse 用途 |
| | | * @return 模板的信息 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyProcessTempVO> listProcessTemplate(String codeTemplateOid, String processUse) { |
| | | if(StringUtils.isBlank(codeTemplateOid) || StringUtils.isBlank(processUse)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | Map<String,String> conditionMap =new HashMap<>(); |
| | | conditionMap.put("classifyTemplateOid",codeTemplateOid); |
| | | conditionMap.put("codeprocessuse",processUse); |
| | | return codeClassifyProcessTempDO2VOs(codeClassifyProcessTempMapper.selectByCondition(conditionMap,null)); |
| | | } |
| | | |
| | | @Override |
| | | public CodeClassifyProcessTempVO getProcessTempVOByName(String codeTemplateOid,String processName) { |
| | | if (StringUtils.isBlank(processName)){ |
| | | return new CodeClassifyProcessTempVO(); |
| | | } |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("classifyTemplateOid",codeTemplateOid); |
| | | conditionMap.put("name",processName); |
| | | return codeClassifyProcessTempDO2VO(codeClassifyProcessTempMapper.selectByCondition(conditionMap,null).get(0)); |
| | | } |
| | | } |
| | | |