| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | 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.CodeFixedValueDTO; |
| | | import com.vci.ubcs.code.entity.CodeClassifyProcessTemp; |
| | | import com.vci.ubcs.code.entity.CodeFixedValue; |
| | | import com.vci.ubcs.code.mapper.CodeFixedValueMapper; |
| | | import com.vci.ubcs.code.service.ICodeFixedValueService; |
| | |
| | | import com.vci.ubcs.code.wrapper.CodeFixedValueWrapper; |
| | | 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.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import org.slf4j.Logger; |
| | |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*; |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_LINKED_NOT_DELETE; |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST; |
| | | |
| | | /** |
| | | * 固定码段的码值服务 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据codeFixedSecOid查询码值 |
| | | * @param codeFixedSecOids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<CodeFixedValue> listFixedValueByCodeFixedSecOid(List<String> codeFixedSecOids){ |
| | | if(codeFixedSecOids.isEmpty()){ |
| | | return new ArrayList<CodeFixedValue>(); |
| | | } |
| | | /*List<CodeFixedValue> codeFixedValues = codeFixedValueMapper.selectList( |
| | | Wrappers.<CodeFixedValue>query().lambda() |
| | | .in(CodeFixedValue::getCodeFixedSecOid, codeFixedSecOids) |
| | | );*/ |
| | | List<CodeFixedValue> codeFixedValues = codeFixedValueMapper.selectByPageByCodeFixedSecOid(codeFixedSecOids, new Page<>(1, -1)); |
| | | return codeFixedValues; |
| | | } |
| | | |
| | | /** |
| | | * 根据关联固定码段主键删除码值 |
| | | * @param codeFixedSecOid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Boolean deleteFixedValueBySecOid(String codeFixedSecOid) { |
| | | LambdaQueryWrapper<CodeFixedValue> wrapper = Wrappers.<CodeFixedValue>query() |
| | | .lambda().eq(CodeFixedValue::getCodeFixedSecOid, codeFixedSecOid); |
| | | return codeFixedValueMapper.delete(wrapper)>0; |
| | | } |
| | | |
| | | /** |
| | | * 增加固定码段的码值 |
| | | * @param codeFixedValueDTO 固定码段的码值数据传输对象 |
| | | * @return 执行结果 |
| | |
| | | CodeFixedValue codeFixedValueDO = new CodeFixedValue(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeFixedValueDTO,codeFixedValueDO); |
| | | //填充一些默认值 |
| | | codeFixedValueDO.setOid(VciBaseUtil.getPk()); |
| | | codeFixedValueDO.setRevisionOid(VciBaseUtil.getPk()); |
| | | codeFixedValueDO.setNameOid(VciBaseUtil.getPk()); |
| | | codeFixedValueDO.setBtmname(MdmBtmTypeConstant.CODE_FIXED_VALUE); |
| | | codeFixedValueDO.setCreateTime(new Date()); |
| | | codeFixedValueDO.setCreator(AuthUtil.getUserId().toString()); |
| | | codeFixedValueDO.setLastModifier(AuthUtil.getUserId().toString()); |
| | | codeFixedValueDO.setLastModifyTime(new Date()); |
| | | codeFixedValueDO.setTs(new Date()); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeFixedValueDO, MdmBtmTypeConstant.CODE_FIXED_VALUE); |
| | | Long count = this.codeFixedValueMapper.selectCount(Wrappers.<CodeFixedValue>query() |
| | | .lambda().eq(CodeFixedValue::getCodeFixedSecOid, codeFixedValueDO.getCodeFixedSecOid()) |
| | | )+1L; |
| | |
| | | CodeFixedValue codeFixedValueDO = selectByOid(codeFixedValueDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeFixedValueDTO,codeFixedValueDO); |
| | | //填充一些默认值 |
| | | codeFixedValueDO.setLastModifier(AuthUtil.getUserId().toString()); |
| | | codeFixedValueDO.setLastModifyTime(new Date()); |
| | | codeFixedValueDO.setTs(new Date()); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeFixedValueDO); |
| | | boolean resBoolean = codeFixedValueMapper.updateById(codeFixedValueDO) > 0; |
| | | return resBoolean; |
| | | } |
| | |
| | | * @return success为true为可以删除,false表示有数据引用,obj为true表示有下级 |
| | | */ |
| | | private R checkIsCanDeleteForDO(CodeFixedValueDTO codeFixedValueDTO, CodeFixedValue codeFixedValueDO) { |
| | | if (checkTs(codeFixedValueDTO)) { |
| | | return R.fail(TS_NOT_PROCESS); |
| | | } |
| | | //boService.checkTs(codeFixedValueDTO); |
| | | if(!checkIsLinked(codeFixedValueDO.getOid())) { |
| | | return R.status(true); |
| | | }else{ |
| | | return R.fail(DATA_LINKED_NOT_DELETE); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 检查ts |
| | | * @param tempDO |
| | | * @return |
| | | */ |
| | | private boolean checkTs(CodeFixedValueDTO tempDO){ |
| | | LambdaQueryWrapper<CodeFixedValue> wrapper = Wrappers.<CodeFixedValue>query() |
| | | .lambda().eq(CodeFixedValue::getOid,tempDO.getOid()).select(CodeFixedValue::getTs); |
| | | long dbTs = codeFixedValueMapper.selectById(wrapper).getTs().getTime(); |
| | | long currentTs = tempDO.getTs().getTime(); |
| | | if(dbTs == currentTs){ |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | List<CodeFixedValue> doList = codeFixedValueMapper.selectList(Wrappers.<CodeFixedValue>query() |
| | | .lambda().eq(CodeFixedValue::getCodeFixedSecOid,codefixedsecoid) |
| | | ); |
| | | if(doList.isEmpty()){ |
| | | return false; |
| | | } |
| | | boolean resBoolean = codeFixedValueMapper.deleteBatchIds(doList.stream().map(CodeFixedValue::getOid).collect(Collectors.toList())) > 0; |
| | | return resBoolean; |
| | | } |
| | | |
| | | |
| | | } |