¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; |
| | | |
| | | import com.vci.ubcs.code.dto.CodeButtonDTO; |
| | | import com.vci.ubcs.code.dto.CodeFixedValueDTO; |
| | | import com.vci.ubcs.code.entity.CodeButton; |
| | | import com.vci.ubcs.code.entity.CodeFixedValue; |
| | | import com.vci.ubcs.code.enumpack.CodeUseButtonPositionTypeEnum; |
| | | import com.vci.ubcs.code.enumpack.FrameworkDataLCStatus; |
| | | import com.vci.ubcs.code.mapper.CodeButtonMapper; |
| | | import com.vci.ubcs.code.service.ICodeButtonService; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeButtonVO; |
| | | import com.vci.ubcs.common.utils.PageDO2PageVO; |
| | | 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.pagemodel.DataGrid; |
| | | 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.cglib.beans.BeanMap; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*; |
| | | |
| | | /** |
| | | * æ¨¡æ¿æ©å±æ± æå¡å®ç°ç±» |
| | | * |
| | | * @author yuxc |
| | | * @since 2023-03-29 |
| | | */ |
| | | @Service |
| | | public class CodeButtonServiceImpl implements ICodeButtonService { |
| | | |
| | | @Resource |
| | | private CodeButtonMapper codeButtonMapper; |
| | | |
| | | /** |
| | | * 对象çæä½ |
| | | */ |
| | | @Autowired |
| | | private RevisionModelUtil revisionModelUtil; |
| | | |
| | | @Override |
| | | public IPage<CodeButtonVO> selectcodebuttonPage(IPage<CodeButtonVO> page, CodeButtonVO codebutton) { |
| | | return page.setRecords(codeButtonMapper.selectcodebuttonPage(page, codebutton)); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ææçä¸»æ°æ®ä¸çæé®æ©å± |
| | | * @param conditionMap æ¥è¯¢æ¡ä»¶ |
| | | * @param pageHelper å页åæåº |
| | | * @return æ§è¡ç»æ |
| | | * @throws VciBaseException æ¥è¯¢æ¡ä»¶åå页åºéçæ¶å伿åºå¼å¸¸ |
| | | */ |
| | | @Override |
| | | public IPage<CodeButtonVO> gridCodeButton(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"); |
| | | CodeButton codeButton = new CodeButton(); |
| | | BeanMap beanMap = BeanMap.create(codeButton); |
| | | beanMap.putAll(conditionMap); |
| | | IPage<CodeButton> doList = codeButtonMapper.selectPage(Condition.getPage(query),Condition.getQueryWrapper(codeButton)); |
| | | IPage<CodeButtonVO> voList = new Page<>(); |
| | | if (!CollectionUtils.isEmpty(doList.getRecords())) { |
| | | voList.setRecords(codeButtonDO2VOs(doList.getRecords())); |
| | | PageDO2PageVO.pageDO2PageVO(doList,voList); |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | /** |
| | | * å¢å ä¸»æ°æ®ä¸çæé®æ©å± |
| | | * @param codeButtonDTO ä¸»æ°æ®ä¸çæé®æ©å±æ°æ®ä¼ è¾å¯¹è±¡ |
| | | * @return æ§è¡ç»æ |
| | | * @throws VciBaseException åæ°ä¸ºç©ºï¼å¯ä¸é¡¹ï¼å¿
è¾é¡¹ä¸éè¿æ¶ä¼æåºå¼å¸¸ |
| | | */ |
| | | @Override |
| | | public CodeButtonVO addSave(CodeButtonDTO codeButtonDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeButtonDTO,"éè¦æ·»å çæ°æ®å¯¹è±¡"); |
| | | //å°DTO转æ¢ä¸ºDO |
| | | CodeButton codeButtonDO = new CodeButton(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeButtonDTO,codeButtonDO); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeButtonDO, MdmBtmTypeConstant.CODE_BUTTON); |
| | | boolean resInsertCodeButton = codeButtonMapper.insert(codeButtonDO) > 0; |
| | | return resInsertCodeButton ? codeButtonDO2VO(codeButtonDO):null; |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¸»æ°æ®ä¸çæé®æ©å± |
| | | * @param codeButtonDTO ä¸»æ°æ®ä¸çæé®æ©å±æ°æ®ä¼ è¾å¯¹è±¡ |
| | | * @return æ§è¡ç»æ |
| | | * @throws VciBaseException åæ°ä¸ºç©ºï¼å¯ä¸é¡¹ï¼å¿
è¾é¡¹ä¸éè¿æ¶ä¼æåºå¼å¸¸ |
| | | */ |
| | | @Override |
| | | public CodeButtonVO editSave(CodeButtonDTO codeButtonDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeButtonDTO,"æ°æ®å¯¹è±¡",codeButtonDTO.getOid(),"ä¸»æ°æ®ä¸çæé®æ©å±ä¸»é®"); |
| | | //å°DTO转æ¢ä¸ºDO |
| | | CodeButton codeButtonDO = selectByOid(codeButtonDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeButtonDTO,codeButtonDO); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeButtonDO); |
| | | boolean resUpdateCodeButton = codeButtonMapper.updateById(codeButtonDO) > 0; |
| | | return resUpdateCodeButton ? codeButtonDO2VO(codeButtonDO):null; |
| | | } |
| | | |
| | | /** |
| | | * å é¤ä¸»æ°æ®ä¸çæé®æ©å± |
| | | * @param codeButtonDTO ä¸»æ°æ®ä¸çæé®æ©å±æ°æ®ä¼ è¾å¯¹è±¡ï¼oidåtséè¦ä¼ è¾ |
| | | * @return å é¤ç»æåé¦ï¼ï¼successï¼æåï¼failï¼å¤±è´¥ |
| | | * @throws VciBaseException åæ°ä¸ºç©ºï¼è¢«å¼ç¨æ¶æåºå¼å¸¸ |
| | | */ |
| | | @Override |
| | | public R deleteCodeButton(CodeButtonDTO codeButtonDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeButtonDTO,"ä¸»æ°æ®ä¸çæé®æ©å±æ°æ®å¯¹è±¡",codeButtonDTO.getOid(),"ä¸»æ°æ®ä¸çæé®æ©å±ç主é®"); |
| | | CodeButton codeButtonDO = selectByOid(codeButtonDTO.getOid()); |
| | | R baseResult = checkIsCanDeleteForDO(codeButtonDTO,codeButtonDO); |
| | | if(baseResult.isSuccess()) { |
| | | }else{ |
| | | return baseResult; |
| | | } |
| | | //æ§è¡å é¤æä½ |
| | | boolean resDeleteCodeButton = codeButtonMapper.deleteById(codeButtonDO.getOid()) > 0; |
| | | return resDeleteCodeButton ? R.success(DELETE_SUCCESS):R.fail(DELETE_FAIL); |
| | | } |
| | | |
| | | /** |
| | | * 主é®è·åä¸»æ°æ®ä¸çæé®æ©å± |
| | | * @param oid ä¸»é® |
| | | * @return ä¸»æ°æ®ä¸çæé®æ©å±æ¾ç¤ºå¯¹è±¡ |
| | | * @throws VciBaseException åæ°ä¸ºç©ºï¼æ°æ®ä¸å卿¶ä¼æåºå¼å¸¸ |
| | | */ |
| | | @Override |
| | | public CodeButtonVO getObjectByOid(String oid) throws VciBaseException{ |
| | | return codeButtonDO2VO(selectByOid(oid)); |
| | | } |
| | | |
| | | /** |
| | | * åç
§ä¸»æ°æ®ä¸çæé®æ©å±å表 |
| | | * @param conditionMap æ¥è¯¢æ¡ä»¶ |
| | | * @param pageHelper å页åæåº |
| | | * @return ä¸»æ°æ®ä¸çæé®æ©å±æ¾ç¤ºå¯¹è±¡å表ï¼çæçå
容 |
| | | * @throws VciBaseException æ¥è¯¢æ¡ä»¶åå页åºéçæ¶å伿åºå¼å¸¸ |
| | | */ |
| | | @Override |
| | | public IPage<CodeButtonVO> refDataGridCodeButton(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if(conditionMap == null){ |
| | | conditionMap = new HashMap<String, String>(); |
| | | } |
| | | return gridCodeButton(conditionMap,pageHelper); |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªæ¯å¦å¯ä»¥å é¤ï¼å¦æåå¨ä¸çº§ï¼å¹¶ä¸ä¸çº§ææ°æ®å¼ç¨åä¸è½å é¤ |
| | | * @param codeButtonDTO æ°æ®ä¼ è¾å¯¹è±¡ |
| | | * @param codeButtonDO æ°æ®åºä¸çæ°æ®å¯¹è±¡ |
| | | * @return success为true为å¯ä»¥å é¤ï¼falseè¡¨ç¤ºææ°æ®å¼ç¨ï¼obj为true表示æä¸çº§ |
| | | */ |
| | | private R checkIsCanDeleteForDO(CodeButtonDTO codeButtonDTO, CodeButton codeButtonDO) { |
| | | CodeButton buttonDO = new CodeButton(); |
| | | BeanUtil.convert(codeButtonDTO,buttonDO); |
| | | if (!checkTs(codeButtonDTO,buttonDO)) { |
| | | return R.fail(TS_NOT_PROCESS); |
| | | } |
| | | if(!checkIsLinked(codeButtonDO.getOid())) { |
| | | return R.success("success"); |
| | | }else{ |
| | | return R.fail(DATA_LINKED_NOT_DELETE); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥ts |
| | | * @param tempDO |
| | | * @return |
| | | */ |
| | | private boolean checkTs(CodeButtonDTO tempDO, CodeButton codeButton){ |
| | | Date dbTs = codeButton.getTs(); |
| | | Date currentTs = tempDO.getTs(); |
| | | if(currentTs == null ? dbTs == null:currentTs.compareTo(dbTs)==0){ |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªæ¯å¦è¢«å¼ç¨ |
| | | * @param oid ä¸»é® |
| | | * @throws VciBaseException 被å¼ç¨çæ¶å伿åºå¼å¸¸ |
| | | */ |
| | | private boolean checkIsLinked(String oid) throws VciBaseException{ |
| | | //TODO æ·»å éè¦æ ¡éªå¼ç¨çå°æ¹ |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 䏻鮿¥è¯¢æ°æ®å¯¹è±¡ |
| | | * @param oid ä¸»é® |
| | | * @return æ°æ®å¯¹è±¡ |
| | | * @throws VciBaseException åæ°ä¸ºç©ºï¼å¹¶ä¸æ°æ®ä¸åå¨çæ¶å伿åºå¼å¸¸ |
| | | */ |
| | | private CodeButton selectByOid(String oid) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oid,"主é®"); |
| | | CodeButton codeButtonDO = codeButtonMapper.selectById(oid.trim()); |
| | | if(codeButtonDO == null || StringUtils.isBlank(codeButtonDO.getOid())){ |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | return codeButtonDO; |
| | | } |
| | | |
| | | /** |
| | | * 䏻鮿¹éè·åä¸»æ°æ®ä¸çæé®æ©å± |
| | | * @param oidCollections 主é®éåï¼ä½æ¯åæ§è½å½±åï¼å»ºè®®ä¸æ¬¡æ¥è¯¢ä¸è¶
è¿10000个 |
| | | * @return ä¸»æ°æ®ä¸çæé®æ©å±æ¾ç¤ºå¯¹è±¡ |
| | | * @throws VciBaseException æ¥è¯¢åºç°å¼å¸¸æ¶ä¼æåº |
| | | */ |
| | | @Override |
| | | public Collection<CodeButtonVO> listCodeButtonByOids(Collection<String> oidCollections) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(oidCollections,"æ°æ®å¯¹è±¡ä¸»é®éå"); |
| | | List<CodeButton> codeButtonDOList = listCodeButtonDOByOidCollections(oidCollections); |
| | | return codeButtonDO2VOs(codeButtonDOList); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éæ°æ®å¯¹è±¡è½¬æ¢ä¸ºæ¾ç¤ºå¯¹è±¡ |
| | | * @param codeButtonDOs æ°æ®å¯¹è±¡å表 |
| | | * @return æ¾ç¤ºå¯¹è±¡ |
| | | * @throws VciBaseException åæ°ä¸ºç©ºæè
ä¸åå¨çæ¶å伿åºå¼å¸¸ |
| | | */ |
| | | @Override |
| | | public List<CodeButtonVO> codeButtonDO2VOs(Collection<CodeButton> codeButtonDOs) throws VciBaseException{ |
| | | List<CodeButtonVO> voList = new ArrayList<CodeButtonVO>(); |
| | | if(!CollectionUtils.isEmpty(codeButtonDOs)){ |
| | | for(CodeButton s: codeButtonDOs){ |
| | | CodeButtonVO vo = codeButtonDO2VO(s); |
| | | if(vo != null){ |
| | | voList.add(vo); |
| | | } |
| | | } |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | /** |
| | | * æ°æ®å¯¹è±¡è½¬æ¢ä¸ºæ¾ç¤ºå¯¹è±¡ |
| | | * @param codeButtonDO æ°æ®å¯¹è±¡ |
| | | * @return æ¾ç¤ºå¯¹è±¡ |
| | | * @throws VciBaseException æ·è´å±æ§åºéçæ¶å伿åºå¼å¸¸ |
| | | */ |
| | | @Override |
| | | public CodeButtonVO codeButtonDO2VO(CodeButton codeButtonDO) throws VciBaseException{ |
| | | CodeButtonVO vo = new CodeButtonVO(); |
| | | if(codeButtonDO != null){ |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeButtonDO,vo); |
| | | //妿ælcstatusçç±»çè¯ |
| | | vo.setLcStatusText(FrameworkDataLCStatus.getTextByValue(vo.getLcStatus())); |
| | | vo.setUsedpositiontypeText(CodeUseButtonPositionTypeEnum.getTextByValue(codeButtonDO.getUsedPositionType())); |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | @Override |
| | | public List<CodeButton> selectByPrimaryKeyCollection(Collection<String> oids) { |
| | | VciBaseUtil.alertNotNull(oids,"主é®éå"); |
| | | return codeButtonMapper.selectBatchIds(oids); |
| | | } |
| | | |
| | | /** |
| | | * 使ç¨ä¸»é®éåæ¥è¯¢æ°æ®å¯¹è±¡ |
| | | * @param oidCollections 主é®çéå |
| | | * @return æ°æ®å¯¹è±¡å表 |
| | | */ |
| | | private List<CodeButton> listCodeButtonDOByOidCollections(Collection<String> oidCollections){ |
| | | List<CodeButton> codeButtonDOList = new ArrayList<CodeButton>(); |
| | | if(!CollectionUtils.isEmpty(oidCollections)){ |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for(Collection<String> oids: oidCollectionsList){ |
| | | List<CodeButton> tempDOList = codeButtonMapper.selectBatchIds(oids); |
| | | if(!CollectionUtils.isEmpty(tempDOList)){ |
| | | codeButtonDOList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeButtonDOList; |
| | | } |
| | | |
| | | @Override |
| | | public R enableCodeButton(String id) { |
| | | CodeButton codebutton = codeButtonMapper.selectById(id); |
| | | return changeLcStatus(codebutton,true); |
| | | } |
| | | |
| | | /** |
| | | * åç¨ |
| | | * |
| | | * @param oid æ°æ®ä¼ è¾å¯¹è±¡ |
| | | * @return æ§è¡ç»æ |
| | | */ |
| | | @Override |
| | | public R disableOrgDuty(String oid) { |
| | | CodeButton codebutton = codeButtonMapper.selectById(oid); |
| | | return changeLcStatus(codebutton,false); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹çå½å¨æçç¶æï¼å¦åç¨åå¯ç¨ |
| | | * @param buttonDTO æ°æ®ä¼ è¾å¯¹è±¡ï¼å¿
é¡»è¦æoidåts |
| | | * @param disable æ¯å¦ä¸ºåç¨ |
| | | * @return æ§è¡çç»æ |
| | | */ |
| | | private R changeLcStatus(CodeButton buttonDTO, boolean disable){ |
| | | // VciBaseUtil.alertNotNull(buttonDTO,"æ°æ®å¯¹è±¡",buttonDTO.getOid(),"主é®"); |
| | | if(disable){ |
| | | buttonDTO.setLcStatus(FrameworkDataLCStatus.ENABLED.getValue()); |
| | | }else{ |
| | | buttonDTO.setLcStatus(FrameworkDataLCStatus.DISABLED.getValue()); |
| | | } |
| | | return SqlHelper.retBool(codeButtonMapper.updateById(buttonDTO))? |
| | | R.success(FrameworkDataLCStatus.ENABLED.getValue()):R.fail(FrameworkDataLCStatus.DISABLED.getValue()); |
| | | } |
| | | |
| | | // /** |
| | | // * æ ¡éªæ¯å¦å¯ä»¥å é¤ï¼å¦æåå¨ä¸çº§ï¼å¹¶ä¸ä¸çº§ææ°æ®å¼ç¨åä¸è½å é¤ |
| | | // * @param codeButtonDTO æ°æ®ä¼ è¾å¯¹è±¡ |
| | | // * @param codeButtonDO æ°æ®åºä¸çæ°æ®å¯¹è±¡ |
| | | // * @return success为true为å¯ä»¥å é¤ï¼falseè¡¨ç¤ºææ°æ®å¼ç¨ï¼obj为true表示æä¸çº§ |
| | | // */ |
| | | // private R checkIsCanDeleteForDO(CodeButtonEntity codeButtonDTO, CodeButtonVO codeButtonDO) { |
| | | // CodeButtonVO buttonDO = new CodeButtonVO(); |
| | | // BeanUtil.convert(codeButtonDTO,buttonDO); |
| | | // boService.checkTs(buttonDO); |
| | | // if(!checkIsLinked(codeButtonDO.getOid())) { |
| | | // return BaseResult.success(); |
| | | // }else{ |
| | | // return BaseResult.fail(DATA_LINKED_NOT_DELETE,new String[]{""}); |
| | | // } |
| | | // } |
| | | |
| | | } |