¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant; |
| | | import com.vci.ubcs.code.entity.CodeClassifyTemplate; |
| | | import com.vci.ubcs.code.entity.CodeClassifyTemplateAttr; |
| | | import com.vci.ubcs.code.entity.CodeSynonym; |
| | | import com.vci.ubcs.code.mapper.CodeSynonymMapper; |
| | | import com.vci.ubcs.code.service.ICodeClassifyTemplateAttrService; |
| | | import com.vci.ubcs.code.service.ICodeSynonymService; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO; |
| | | import com.vci.ubcs.code.wrapper.CodeClassifyTemplateAttrWrapper; |
| | | import com.vci.ubcs.starter.enumpack.CodeTableNameEnum; |
| | | import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; |
| | | import com.vci.ubcs.starter.util.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.starter.util.UBCSCondition; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * è¿ä¹è¯ç»´æ¤ æå¡å®ç°ç±» |
| | | * |
| | | * @author yuxc |
| | | * @since 2023-04-04 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class CodeSynonymServiceImpl extends ServiceImpl<CodeSynonymMapper, CodeSynonym> implements ICodeSynonymService { |
| | | |
| | | private final CodeSynonymMapper codeSynonymMapper; |
| | | |
| | | private final ICodeClassifyTemplateAttrService codeClassifyTemplateAttrService; |
| | | |
| | | /** |
| | | * è¿ä¹è¯ç»´æ¤ æ°å¢ |
| | | * @param codeSynonym |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean addSave(CodeSynonym codeSynonym) { |
| | | if(codeSynonym.getSynonymValue().isEmpty() || codeSynonym.getSourceValue().isEmpty()){ |
| | | throw new ServiceException("æºå¼åè¿ä¹è¯ä¸è½ä¸ºç©º"); |
| | | } |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeSynonym, MdmBtmTypeConstant.CODE_SYNONYM); |
| | | // æ·»å æ¶é»è®¤ä¸ºç¼è¾ä¸ |
| | | codeSynonym.setLcStatus(FrameWorkDefaultValueConstant.FRAMEWORK_RELEASE_RELEASED); |
| | | return SqlHelper.retBool(codeSynonymMapper.insert(codeSynonym)); |
| | | } |
| | | |
| | | /** |
| | | * è¿ä¹è¯ç»´æ¤ ä¿®æ¹ |
| | | * @param codeSynonym |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean editSave(CodeSynonym codeSynonym) { |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeSynonym); |
| | | return SqlHelper.retBool(codeSynonymMapper.updateById(codeSynonym)); |
| | | } |
| | | |
| | | /** |
| | | * è¿ä¹è¯ç¶æåç¨å¯ç¨ |
| | | * @param map |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateStatus(Map<String, String> map) { |
| | | if(Func.isEmpty(map.getOrDefault("oid",""))){ |
| | | throw new ServiceException("å¿
ä¼ åæ°oidä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | if(Func.isEmpty(map.getOrDefault("lcStatus",""))){ |
| | | throw new ServiceException("çå½å¨æç¶æä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | LambdaUpdateWrapper<CodeSynonym> updateWrapper = Wrappers.<CodeSynonym>update() |
| | | .lambda().eq(CodeSynonym::getOid, map.get("oid")) |
| | | .set(CodeSynonym::getLcStatus, map.get("lcStatus")); |
| | | return SqlHelper.retBool(this.codeSynonymMapper.update(null,updateWrapper)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ |
| | | * @param oids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R deleteDataByIds(String oids) { |
| | | if(Func.isBlank(oids)){ |
| | | return R.fail("æªè·åçåæ°oid"); |
| | | } |
| | | List<Long> oidList = Func.toLongList(oids); |
| | | LambdaQueryWrapper<CodeClassifyTemplateAttr> wrapper = Wrappers.<CodeClassifyTemplateAttr>query().lambda(); |
| | | oidList.stream().forEach(item->{ |
| | | wrapper.or().like(CodeClassifyTemplateAttr::getSysonymRuleOids, item); |
| | | }); |
| | | List<CodeClassifyTemplateAttr> voList = codeClassifyTemplateAttrService.selectByWrapper(wrapper); |
| | | if(!voList.isEmpty()){ |
| | | return R.fail("å é¤çè§åä¸åå¨è¢«å¼ç¨çè¿ä¹è¯æ¥è¯¢è§åï¼"); |
| | | } |
| | | return R.status(SqlHelper.retBool(codeSynonymMapper.deleteBatchIds(oidList))); |
| | | } |
| | | |
| | | /** |
| | | * æ¥çè¿ä¹è¯æ¥è¯¢è§å使ç¨èå´ |
| | | * @param oid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateAttrVO> listUseRangeInClsTempAttr(String oid) { |
| | | MPJLambdaWrapper<CodeClassifyTemplateAttr> mpjLambdaWrapper = new MPJLambdaWrapper<>(CodeClassifyTemplateAttr.class, CodeTableNameEnum.PL_CODE_CLSTEMPATTR.getText()) |
| | | .selectAll(CodeClassifyTemplateAttr.class) |
| | | .selectAs(CodeClassifyTemplate::getName,CodeClassifyTemplateAttr::getClassifyTemplateOidName) |
| | | .leftJoin(CodeClassifyTemplate.class,CodeTableNameEnum.PL_CODE_CLSTEMPLATE.getText(),CodeClassifyTemplate::getOid,CodeClassifyTemplateAttr::getClassifyTemplateOid) |
| | | .like(CodeClassifyTemplateAttr::getSysonymRuleOids, oid); |
| | | List<CodeClassifyTemplateAttr> voList = codeClassifyTemplateAttrService.selectByWrapper(mpjLambdaWrapper); |
| | | return CodeClassifyTemplateAttrWrapper.build().listVO(voList); |
| | | } |
| | | |
| | | @Override |
| | | public String selectNameByWrapper(LambdaQueryWrapper<CodeSynonym> wrappers) { |
| | | List<CodeSynonym> codeSynonymsList = codeSynonymMapper.selectList(wrappers); |
| | | if(codeSynonymsList.isEmpty()){ |
| | | return ""; |
| | | } |
| | | StringBuilder res = new StringBuilder(); |
| | | codeSynonymsList.stream().forEach(item->{ |
| | | res.append(item.getName()).append("(").append(item.getId()).append(")").append(","); |
| | | }); |
| | | return res.toString().replaceAll(",$", ""); |
| | | } |
| | | |
| | | /** |
| | | * è·åè¿ä¹è¯æ¥è¯¢è§å |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Map<String, List<CodeSynonym>> getCodeSynonymByOids(Map<String, CodeClassifyTemplateAttrVO> sysonymAttrMap) { |
| | | if(sysonymAttrMap.isEmpty()){ |
| | | return new HashMap<>(); |
| | | } |
| | | Map<String, List<CodeSynonym>> resMap = new HashMap<>(); |
| | | for (String key : sysonymAttrMap.keySet()) { |
| | | List<String> oids = Func.toStrList(sysonymAttrMap.get(key).getSysonymRuleOids()); |
| | | List<CodeSynonym> codeSynonyms = codeSynonymMapper.selectBatchIds(oids); |
| | | resMap.put(key,codeSynonyms); |
| | | } |
| | | return resMap; |
| | | } |
| | | |
| | | } |