| | |
| | | import com.vci.ubcs.code.constant.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.code.dto.CodeBasicSecDTO; |
| | | import com.vci.ubcs.code.entity.CodeBasicSec; |
| | | import com.vci.ubcs.code.entity.CodeClassify; |
| | | import com.vci.ubcs.code.entity.CodeClassifyValue; |
| | | import com.vci.ubcs.code.entity.CodeFixedValue; |
| | | import com.vci.ubcs.code.enumpack.CodeSecTypeEnum; |
| | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST; |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*; |
| | | |
| | | /** |
| | | * 码段基础信息服务接口 |
| | |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | public boolean deleteCodeBasicSec(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException { |
| | | public R deleteCodeBasicSec(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(codeBasicSecDTO, "码段基础信息数据对象", codeBasicSecDTO.getOid(), "码段基础信息的主键"); |
| | | return this.codeBasicSecMapper.deleteById(codeBasicSecDTO.getOid())>0; |
| | | return this.deleteCodeBasicSecByPrimaryKey(codeBasicSecDTO.getOid()); |
| | | } |
| | | |
| | | /** |
| | | * 主键删除码段基础信息 |
| | | * |
| | | * @param oid 码段基础信息主键 |
| | | * @return 删除结果反馈::success:成功,fail:失败 |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R deleteCodeBasicSecByPrimaryKey(String oid) throws VciBaseException { |
| | | CodeBasicSec codeBasicSecDO = selectByOid(oid); |
| | | boolean isLinked = checkIsLinked(codeBasicSecDO.getPkCodeRule(), oid); |
| | | if (isLinked) { |
| | | return R.fail("编码规则已被引用,不允许编辑或删除"); |
| | | } |
| | | //执行删除操作 |
| | | boolean eftDeleteBasic = codeBasicSecMapper.deleteById(oid) > 0; |
| | | if (CodeSecTypeEnum.CODE_FIXED_SEC.getValue().equals(codeBasicSecDO.getSecType())){ |
| | | List<CodeFixedValue> fixedValueDOS = fixedValueMapper.selectList(Wrappers.<CodeFixedValue>query() |
| | | .lambda().eq(CodeFixedValue::getCodeFixedSecOid,codeBasicSecDO.getOid()) |
| | | ); |
| | | if(!CollectionUtils.isEmpty(fixedValueDOS)){ |
| | | fixedValueMapper.deleteBatchIds(fixedValueDOS.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet())); |
| | | } |
| | | } |
| | | if (CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue().equals(codeBasicSecDO.getSecType())){ |
| | | List<CodeClassifyValue> classifyValueDOS = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query() |
| | | .lambda().eq(CodeClassifyValue::getCodeClassifySecOid,codeBasicSecDO.getOid()) |
| | | ); |
| | | if(!CollectionUtils.isEmpty(classifyValueDOS)) { |
| | | codeClassifyValueMapper.deleteBatchIds(classifyValueDOS.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet())); |
| | | } |
| | | } |
| | | |
| | | return eftDeleteBasic ? R.success(DELETE_SUCCESS) : R.fail(DELETE_FAIL); |
| | | } |
| | | |
| | | /** |
| | |
| | | if(Func.isEmpty(codeBasicSecVO.getPkCodeRule()) || Func.isBlank(codeBasicSecVO.getPkCodeRule())){ |
| | | return null; |
| | | } |
| | | codeBasicSecVO.setSectype(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue()); |
| | | codeBasicSecVO.setSecType(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue()); |
| | | return refDataGridCodeBasicSec(page,codeBasicSecVO); |
| | | } |
| | | |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean upOrderNum(String oid) { |
| | | CodeBasicSec secDO = selectByOid(oid); |
| | | boolean resUpBoolean = false; |
| | | boolean resDownBoolean = false; |
| | | if(secDO.getOrderNum() >1){ |
| | | if(secDO.getOrderNum() > 1){ |
| | | //等于1的时候不能上移了 |
| | | //找比自己小的 |
| | | List<CodeBasicSec> lastSecDOs = codeBasicSecMapper.selectList(Wrappers.<CodeBasicSec>query() |
| | |
| | | ); |
| | | if(!CollectionUtils.isEmpty(lastSecDOs)){ |
| | | CodeBasicSec lastSec = lastSecDOs.get(0); |
| | | resDownBoolean = codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() |
| | | codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() |
| | | .lambda().set(CodeBasicSec::getOrderNum, lastSec.getOrderNum() + 1) |
| | | .eq(CodeBasicSec::getOid, lastSec.getOid()) |
| | | ) > 0; |
| | | ); |
| | | } |
| | | secDO.setOrderNum(secDO.getOrderNum()-1); |
| | | resUpBoolean = codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() |
| | | codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() |
| | | .lambda().set(CodeBasicSec::getOrderNum, secDO.getOrderNum() - 1) |
| | | .eq(CodeBasicSec::getOid, secDO.getOid()) |
| | | ) > 0; |
| | | ); |
| | | } |
| | | return resDownBoolean && resUpBoolean; |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean downOrderNum(String oid) { |
| | | CodeBasicSec secDO = selectByOid(oid); |
| | | boolean resUpBoolean = false; |
| | | boolean resDownBoolean = false; |
| | | Long total = codeBasicSecMapper.selectCount(Wrappers.<CodeBasicSec>query() |
| | | .lambda().eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule()) |
| | | ); |
| | | if(secDO.getOrderNum() < total){ |
| | | if(secDO.getOrderNum() < total){ |
| | | //小于总数的时候才下移 |
| | | List<CodeBasicSec> lastSecDOs = codeBasicSecMapper.selectList(Wrappers.<CodeBasicSec>query() |
| | | .lambda().eq(CodeBasicSec::getOrderNum,String.valueOf(secDO.getOrderNum()+1)) |
| | | .lambda().eq(CodeBasicSec::getOrderNum,secDO.getOrderNum()+1) |
| | | .eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule()) |
| | | ); |
| | | if(!CollectionUtils.isEmpty(lastSecDOs)){ |
| | | CodeBasicSec lastSec = lastSecDOs.get(0); |
| | | resUpBoolean = codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() |
| | | codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() |
| | | .lambda().set(CodeBasicSec::getOrderNum, lastSec.getOrderNum() - 1) |
| | | .eq(CodeBasicSec::getOid, lastSec.getOid()) |
| | | ) > 0; |
| | | ); |
| | | } |
| | | resDownBoolean = codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() |
| | | codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() |
| | | .lambda().set(CodeBasicSec::getOrderNum, secDO.getOrderNum() + 1) |
| | | .eq(CodeBasicSec::getOid, secDO.getOid()) |
| | | ) > 0; |
| | | ); |
| | | } |
| | | return resDownBoolean && resUpBoolean; |
| | | return true; |
| | | } |
| | | |
| | | /** |