From 4cd535de8ef099afa96238e5458e6866edccfea7 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期五, 05 五月 2023 20:26:36 +0800
Subject: [PATCH] “代码整合”

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java |  103 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 95 insertions(+), 8 deletions(-)

diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java
index 06ef202..08abbfc 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java
@@ -18,14 +18,23 @@
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
-import com.vci.ubcs.code.entity.CodeButtonEntity;
+import com.vci.ubcs.code.entity.CodeButton;
 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.CodeButtonVO;
+import com.vci.ubcs.code.vo.pagemodel.CodeButtonVO;
+import com.vci.ubcs.starter.exception.VciBaseException;
+import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
+import com.vci.ubcs.starter.web.util.VciBaseUtil;
 import org.springblade.core.tool.api.R;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 
 /**
  * 妯℃澘鎵╁睍姹� 鏈嶅姟瀹炵幇绫�
@@ -36,7 +45,7 @@
 @Service
 public class CodeButtonServiceImpl implements ICodeButtonService {
 
-	@Autowired
+	@Resource
 	CodeButtonMapper codeButtonMapper;
 
 	@Override
@@ -44,11 +53,89 @@
 		return page.setRecords(codeButtonMapper.selectcodebuttonPage(page, codebutton));
 	}
 
+	/**
+	 * 涓婚敭鎵归噺鑾峰彇涓绘暟鎹腑鐨勬寜閽墿灞�
+	 * @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);
+			//濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
+			vo.setLcStatusText(FrameworkDataLCStatus.getTextByValue(vo.getLcStatus()));
+
+		}
+		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) {
-		CodeButtonEntity codebutton = codeButtonMapper.selectById(id);
+		CodeButton codebutton = codeButtonMapper.selectById(id);
 		return changeLcStatus(codebutton,true);
     }
+
 	/**
 	 * 鍋滅敤
 	 *
@@ -57,11 +144,11 @@
 	 */
 	@Override
 	public R disableOrgDuty(String oid) {
-		CodeButtonEntity codebutton = codeButtonMapper.selectById(oid);
+		CodeButton codebutton = codeButtonMapper.selectById(oid);
 		return changeLcStatus(codebutton,false);
 	}
 
-//	@Override
+	//	@Override
 //	public R deleteCodeButton(String ids) {
 ////		VciBaseUtil.alertNotNull(codeButtonDTO,"涓绘暟鎹腑鐨勬寜閽墿灞曟暟鎹璞�",codeButtonDTO.getOid(),"涓绘暟鎹腑鐨勬寜閽墿灞曠殑涓婚敭");
 //		if(StringUtils.isEmpty(ids)){
@@ -86,7 +173,7 @@
 	 * @param disable 鏄惁涓哄仠鐢�
 	 * @return 鎵ц鐨勭粨鏋�
 	 */
-	private R changeLcStatus(CodeButtonEntity buttonDTO, boolean disable){
+	private R changeLcStatus(CodeButton buttonDTO, boolean disable){
 //		VciBaseUtil.alertNotNull(buttonDTO,"鏁版嵁瀵硅薄",buttonDTO.getOid(),"涓婚敭");
 		if(disable){
 			buttonDTO.setLcstatus(FrameworkDataLCStatus.ENABLED.getValue());
@@ -97,7 +184,7 @@
 			R.success(FrameworkDataLCStatus.ENABLED.getValue()):R.fail(FrameworkDataLCStatus.DISABLED.getValue());
 	}
 
-//	/**
+	//	/**
 //	 * 鏍¢獙鏄惁鍙互鍒犻櫎锛屽鏋滃瓨鍦ㄤ笅绾э紝骞朵笖涓嬬骇鏈夋暟鎹紩鐢ㄥ垯涓嶈兘鍒犻櫎
 //	 * @param codeButtonDTO 鏁版嵁浼犺緭瀵硅薄
 //	 * @param codeButtonDO 鏁版嵁搴撲腑鐨勬暟鎹璞�

--
Gitblit v1.9.3