From 238121be19655f63a45fc9c9c3d864801eb4471b Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期三, 24 四月 2024 12:44:07 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodePhaseAttrServiceImpl.java | 336 ++++++++-----------------------------------------------
1 files changed, 53 insertions(+), 283 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodePhaseAttrServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodePhaseAttrServiceImpl.java
index ce27060..c83a441 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodePhaseAttrServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodePhaseAttrServiceImpl.java
@@ -1,301 +1,71 @@
+/*
+ * 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.vci.ubcs.code.constant.MdmBtmTypeConstant;
+import com.alibaba.nacos.common.utils.StringUtils;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import com.vci.ubcs.code.entity.CodePhaseAttr;
import com.vci.ubcs.code.mapper.CodePhaseAttrMapper;
-import com.vci.ubcs.code.entity.CodePhaseAttrDO;
-import com.vci.ubcs.code.service.CodePhaseAttrServiceI;
-import com.vci.starter.revision.service.RevisionModelUtil;
-import com.vci.starter.web.constant.QueryOptionConstant;
-import com.vci.starter.web.exception.VciBaseException;
-import com.vci.starter.web.pagemodel.BaseResult;
-import com.vci.starter.web.pagemodel.DataGrid;
-import com.vci.starter.web.pagemodel.PageHelper;
-import com.vci.starter.web.util.BeanUtil;
-import com.vci.starter.web.util.BeanUtilForVCI;
-import com.vci.starter.web.util.VciBaseUtil;
-import com.vci.web.pageModel.BatchCBO;
-import com.vci.web.service.WebBoServiceI;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import com.vci.ubcs.code.dto.CodePhaseAttrDTO;
+import com.vci.ubcs.code.service.ICodePhaseAttrService;
import com.vci.ubcs.code.vo.pagemodel.CodePhaseAttrVO;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Lazy;
+import com.vci.ubcs.starter.web.util.VciBaseUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
-import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
-import static com.vci.frameworkcore.constant.FrameWorkLangCodeConstant.*;
-
/**
- * 闃舵鐨勫睘鎬ф湇鍔�
- * @author weidy
- * @date 2022-01-24
+ * 缂栫爜搴撳畾涔�-妯℃澘闃舵-灞炴�� 鏈嶅姟瀹炵幇绫�
+ *
+ * @author yuxc
+ * @since 2023-04-20
*/
@Service
-public class CodePhaseAttrServiceImpl implements CodePhaseAttrServiceI {
+public class CodePhaseAttrServiceImpl extends ServiceImpl<CodePhaseAttrMapper, CodePhaseAttr> implements ICodePhaseAttrService {
- /**
- * 鏃ュ織
- */
- private Logger logger = LoggerFactory.getLogger(getClass());
+ @Override
+ public IPage<CodePhaseAttrVO> selectCodePhaseattrPage(IPage<CodePhaseAttrVO> page, CodePhaseAttrVO codePhaseAttr) {
+ return page.setRecords(baseMapper.selectCodePhaseattrPage(page, codePhaseAttr));
+ }
- /**
- * 鏁版嵁鎿嶄綔灞�
- */
- @Resource
- private CodePhaseAttrMapper codePhaseAttrMapper;
-
- /**
- * 涓氬姟绫诲瀷鎿嶄綔鐨勬湇鍔�
- */
- @Autowired
- @Lazy
- private WebBoServiceI boService;
-
- /**
- * 瀵硅薄鐨勬搷浣�
- */
- @Autowired
- private RevisionModelUtil revisionModelUtil;
+ /**
+ * 浣跨敤妯℃澘涓婚敭鍜岄樁娈电紪鍙疯幏鍙栧寘鍚殑灞炴��
+ *
+ * @param templateOid 妯℃澘鐨勭紪鍙�
+ * @param phaseId 闃舵鐨勭紪鍙�
+ * @return 灞炴�х殑鑻辨枃鍚嶇О
+ */
+ @Override
+ public List<String> listAttrByTemplateOidAndPhaseId(String templateOid, String phaseId) {
+ if(StringUtils.isBlank(templateOid)|| StringUtils.isBlank(phaseId)){
+ return new ArrayList<>();
+ }
+ QueryWrapper<CodePhaseAttr> wrapper = new QueryWrapper();
+ wrapper.inSql("codephaseoid","select oid from pl_code_tempphase where codeClassifyTemplateOid ='" + templateOid + "' and lower(name) ='" + phaseId.trim().toLowerCase(Locale.ROOT) + "'");
+// Map<String,String> conditionMap = new HashMap<>();
+// conditionMap.put("codephaseoid", QueryOptionConstant.IN + "(select oid from pl_code_tempphase where codeClassifyTemplateOid ='" + templateOid + "' and lower(name) ='" + phaseId.trim().toLowerCase(Locale.ROOT) + "')");
+// PageHelper pageHelper = new PageHelper(-1);
+ List<CodePhaseAttr> attrDOS = baseMapper.selectList(wrapper);
+ return CollectionUtils.isEmpty(attrDOS)?new ArrayList<>():attrDOS.stream().map(CodePhaseAttr::getId).collect(Collectors.toList());
+ }
- /**
- * 鏌ヨ鎵�鏈夌殑闃舵鐨勫睘鎬�
- * @param conditionMap 鏌ヨ鏉′欢
- * @param pageHelper 鍒嗛〉鍜屾帓搴�
- * @return 鎵ц缁撴灉
- * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
- */
- @Override
- public DataGrid<CodePhaseAttrVO> gridCodePhaseAttr(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{
- if (pageHelper == null) {
- pageHelper = new PageHelper(-1);
- }
- pageHelper.addDefaultDesc("createTime");
- List<CodePhaseAttrDO> doList = codePhaseAttrMapper.selectByCondition(conditionMap,pageHelper);
- DataGrid<CodePhaseAttrVO> dataGrid=new DataGrid<CodePhaseAttrVO>();
- if (!CollectionUtils.isEmpty(doList)) {
- dataGrid.setData(codePhaseAttrDO2VOs(doList));
- dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(codePhaseAttrMapper.countByCondition(conditionMap))));
- }
- return dataGrid;
- }
-
- /**
- * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
- * @param codePhaseAttrDOs 鏁版嵁瀵硅薄鍒楄〃
- * @return 鏄剧ず瀵硅薄
- * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呬笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
- */
- @Override
- public List<CodePhaseAttrVO> codePhaseAttrDO2VOs(Collection<CodePhaseAttrDO> codePhaseAttrDOs) throws VciBaseException{
- List<CodePhaseAttrVO> voList = new ArrayList<CodePhaseAttrVO>();
- if(!CollectionUtils.isEmpty(codePhaseAttrDOs)){
- for(CodePhaseAttrDO s: codePhaseAttrDOs){
- CodePhaseAttrVO vo = codePhaseAttrDO2VO(s);
- if(vo != null){
- voList.add(vo);
- }
- }
- }
- return voList;
- }
-
- /**
- * 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
- * @param codePhaseAttrDO 鏁版嵁瀵硅薄
- * @return 鏄剧ず瀵硅薄
- * @throws VciBaseException 鎷疯礉灞炴�у嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
- */
- @Override
- public CodePhaseAttrVO codePhaseAttrDO2VO(CodePhaseAttrDO codePhaseAttrDO) throws VciBaseException{
- CodePhaseAttrVO vo = new CodePhaseAttrVO();
- if(codePhaseAttrDO != null){
- BeanUtilForVCI.copyPropertiesIgnoreCase(codePhaseAttrDO,vo);
- //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
- }
- return vo;
- }
-
- /**
- * 澧炲姞闃舵鐨勫睘鎬�
- * @param codePhaseAttrDTO 闃舵鐨勫睘鎬ф暟鎹紶杈撳璞�
- * @return 鎵ц缁撴灉
- * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
- */
- @Override
- public CodePhaseAttrVO addSave(CodePhaseAttrDTO codePhaseAttrDTO) throws VciBaseException{
- VciBaseUtil.alertNotNull(codePhaseAttrDTO,"闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄");
- //灏咲TO杞崲涓篋O
- CodePhaseAttrDO codePhaseAttrDO = new CodePhaseAttrDO();
- BeanUtilForVCI.copyPropertiesIgnoreCase(codePhaseAttrDTO,codePhaseAttrDO);
- codePhaseAttrMapper.insert(codePhaseAttrDO);
- return codePhaseAttrDO2VO(codePhaseAttrDO);
- }
-
- /**
- * 淇敼闃舵鐨勫睘鎬�
- * @param codePhaseAttrDTO 闃舵鐨勫睘鎬ф暟鎹紶杈撳璞�
- * @return 鎵ц缁撴灉
- * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
- */
- @Override
- public CodePhaseAttrVO editSave(CodePhaseAttrDTO codePhaseAttrDTO) throws VciBaseException{
- VciBaseUtil.alertNotNull(codePhaseAttrDTO,"鏁版嵁瀵硅薄",codePhaseAttrDTO.getOid(),"闃舵鐨勫睘鎬т富閿�");
- //灏咲TO杞崲涓篋O
- CodePhaseAttrDO codePhaseAttrDO = selectByOid(codePhaseAttrDTO.getOid());
- revisionModelUtil.copyFromDTOIgnore(codePhaseAttrDTO,codePhaseAttrDO);
- codePhaseAttrMapper.updateByPrimaryKey(codePhaseAttrDO);
- return codePhaseAttrDO2VO(codePhaseAttrDO);
- }
-
-
- /**
- * 鏍¢獙鏄惁鍙互鍒犻櫎锛屽鏋滃瓨鍦ㄤ笅绾э紝骞朵笖涓嬬骇鏈夋暟鎹紩鐢ㄥ垯涓嶈兘鍒犻櫎
- * @param codePhaseAttrDTO 鏁版嵁浼犺緭瀵硅薄
- * @param codePhaseAttrDO 鏁版嵁搴撲腑鐨勬暟鎹璞�
- * @return success涓簍rue涓哄彲浠ュ垹闄わ紝false琛ㄧず鏈夋暟鎹紩鐢紝obj涓簍rue琛ㄧず鏈変笅绾�
- */
- private BaseResult checkIsCanDeleteForDO(CodePhaseAttrDTO codePhaseAttrDTO, CodePhaseAttrDO codePhaseAttrDO) {
- CodePhaseAttrDO tsDO = new CodePhaseAttrDO();
- BeanUtil.convert(codePhaseAttrDTO,tsDO);
- boService.checkTs(tsDO);
- if(!checkIsLinked(codePhaseAttrDO.getOid())) {
- return BaseResult.success();
- }else{
- return BaseResult.fail(DATA_LINKED_NOT_DELETE,new String[]{""});
- }
- }
-
- /**
- * 鏍¢獙鏄惁琚紩鐢�
- * @param oid 涓婚敭
- * @throws VciBaseException 琚紩鐢ㄧ殑鏃跺�欎細鎶涘嚭寮傚父
- */
- private boolean checkIsLinked(String oid) throws VciBaseException{
- //TODO 娣诲姞闇�瑕佹牎楠屽紩鐢ㄧ殑鍦版柟
- return false;
- }
-
- /**
- * 鍒犻櫎闃舵鐨勫睘鎬�
- * @param codePhaseAttrDTO 闃舵鐨勫睘鎬ф暟鎹紶杈撳璞★紝oid鍜宼s闇�瑕佷紶杈�
- * @return 鍒犻櫎缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐�
- * @throws VciBaseException 鍙傛暟涓虹┖锛岃寮曠敤鏃舵姏鍑哄紓甯�
- */
- @Override
- public BaseResult deleteCodePhaseAttr(CodePhaseAttrDTO codePhaseAttrDTO) throws VciBaseException{
- VciBaseUtil.alertNotNull(codePhaseAttrDTO,"闃舵鐨勫睘鎬ф暟鎹璞�",codePhaseAttrDTO.getOid(),"闃舵鐨勫睘鎬х殑涓婚敭");
- CodePhaseAttrDO codePhaseAttrDO = selectByOid(codePhaseAttrDTO.getOid());
- BaseResult baseResult = checkIsCanDeleteForDO(codePhaseAttrDTO,codePhaseAttrDO);
- if(baseResult.isSuccess()) {
- }else{
- return baseResult;
- }
- //鎵ц鍒犻櫎鎿嶄綔
- BatchCBO batchCBO = codePhaseAttrMapper.deleteByPrimaryKey(codePhaseAttrDO.getOid());
- return (batchCBO!=null && batchCBO.getDeleteCbos() !=null &&batchCBO.getDeleteCbos().size() > 0)?BaseResult.successMsg(DELETE_SUCCESS):BaseResult.fail(DELETE_FAIL);
- }
-
- /**
- * 涓婚敭鑾峰彇闃舵鐨勫睘鎬�
- * @param oid 涓婚敭
- * @return 闃舵鐨勫睘鎬ф樉绀哄璞�
- * @throws VciBaseException 鍙傛暟涓虹┖锛屾暟鎹笉瀛樺湪鏃朵細鎶涘嚭寮傚父
- */
- @Override
- public CodePhaseAttrVO getObjectByOid(String oid) throws VciBaseException{
- return codePhaseAttrDO2VO(selectByOid(oid));
- }
-
- /**
- * 涓婚敭鏌ヨ鏁版嵁瀵硅薄
- * @param oid 涓婚敭
- * @return 鏁版嵁瀵硅薄
- * @throws VciBaseException 鍙傛暟涓虹┖锛屽苟涓旀暟鎹笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
- */
- private CodePhaseAttrDO selectByOid(String oid) throws VciBaseException{
- VciBaseUtil.alertNotNull(oid,"涓婚敭");
- CodePhaseAttrDO codePhaseAttrDO = codePhaseAttrMapper.selectByPrimaryKey(oid.trim());
- if(codePhaseAttrDO == null || StringUtils.isBlank(codePhaseAttrDO.getOid())){
- throw new VciBaseException(DATA_OID_NOT_EXIST);
- }
- return codePhaseAttrDO;
- }
-
- /**
- * 涓婚敭鎵归噺鑾峰彇闃舵鐨勫睘鎬�
- * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓�
- * @return 闃舵鐨勫睘鎬ф樉绀哄璞�
- * @throws VciBaseException 鏌ヨ鍑虹幇寮傚父鏃朵細鎶涘嚭
- */
- @Override
- public Collection<CodePhaseAttrVO> listCodePhaseAttrByOids(Collection<String> oidCollections) throws VciBaseException{
- VciBaseUtil.alertNotNull(oidCollections,"鏁版嵁瀵硅薄涓婚敭闆嗗悎");
- List<CodePhaseAttrDO> codePhaseAttrDOList = listCodePhaseAttrDOByOidCollections(oidCollections);
- return codePhaseAttrDO2VOs(codePhaseAttrDOList);
- }
-
- /**
- * 浣跨敤涓婚敭闆嗗悎鏌ヨ鏁版嵁瀵硅薄
- * @param oidCollections 涓婚敭鐨勯泦鍚�
- * @return 鏁版嵁瀵硅薄鍒楄〃
- */
- private List<CodePhaseAttrDO> listCodePhaseAttrDOByOidCollections(Collection<String> oidCollections){
- List<CodePhaseAttrDO> codePhaseAttrDOList = new ArrayList<CodePhaseAttrDO>();
- if(!CollectionUtils.isEmpty(oidCollections)){
- Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections);
- for(Collection<String> oids: oidCollectionsList){
- List<CodePhaseAttrDO> tempDOList = codePhaseAttrMapper.selectByPrimaryKeyCollection(oids);
- if(!CollectionUtils.isEmpty(tempDOList)){
- codePhaseAttrDOList.addAll(tempDOList);
- }
- }
- }
- return codePhaseAttrDOList;
- }
-
-
-
- /**
- * 鍙傜収闃舵鐨勫睘鎬у垪琛�
- * @param conditionMap 鏌ヨ鏉′欢
- * @param pageHelper 鍒嗛〉鍜屾帓搴�
- * @return 闃舵鐨勫睘鎬ф樉绀哄璞″垪琛紝鐢熸晥鐨勫唴瀹�
- * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
- */
- @Override
- public DataGrid<CodePhaseAttrVO> refDataGridCodePhaseAttr(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{
- if(conditionMap == null){
- conditionMap = new HashMap<String, String>();
- }
- return gridCodePhaseAttr(conditionMap,pageHelper);
- }
-
- /**
- * 浣跨敤妯℃澘涓婚敭鍜岄樁娈电紪鍙疯幏鍙栧寘鍚殑灞炴��
- *
- * @param templateOid 妯℃澘鐨勭紪鍙�
- * @param phaseId 闃舵鐨勭紪鍙�
- * @return 灞炴�х殑鑻辨枃鍚嶇О
- */
- @Override
- public List<String> listAttrByTemplateOidAndPhaseId(String templateOid, String phaseId) {
- if(StringUtils.isBlank(templateOid)|| StringUtils.isBlank(phaseId)){
- return new ArrayList<>();
- }
- Map<String,String> conditionMap = new HashMap<>();
- conditionMap.put("codephaseoid", QueryOptionConstant.IN + "(select oid from "+
- VciBaseUtil.getTableName(MdmBtmTypeConstant.CODE_TEMPLATE_PHASE) +
- " where codeClassifyTemplateOid ='" + templateOid + "' and lower(name) ='" + phaseId.trim().toLowerCase(Locale.ROOT) + "')");
- PageHelper pageHelper = new PageHelper(-1);
- List<CodePhaseAttrDO> attrDOS = codePhaseAttrMapper.selectByCondition(conditionMap, pageHelper);
- return CollectionUtils.isEmpty(attrDOS)?new ArrayList<>():attrDOS.stream().map(CodePhaseAttrDO::getId).collect(Collectors.toList());
- }
}
-
--
Gitblit v1.9.3