From ba90ddf7618567877f1211f671ae1b34c378faad Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期五, 17 十一月 2023 16:14:21 +0800
Subject: [PATCH] 整合代码
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyValueServiceImpl.java | 207 ++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 169 insertions(+), 38 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyValueServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyValueServiceImpl.java
index 4db19dd..be7cad1 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyValueServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyValueServiceImpl.java
@@ -1,12 +1,15 @@
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.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
import com.vci.ubcs.code.dto.CodeClassifyValueDTO;
+import com.vci.ubcs.code.entity.CodeBasicSec;
import com.vci.ubcs.code.entity.CodeClassifyValue;
-import com.vci.ubcs.code.enumpack.FrameworkDataLCStatus;
+import com.vci.ubcs.code.enumpack.*;
import com.vci.ubcs.code.mapper.CodeClassifyValueMapper;
import com.vci.ubcs.code.service.ICodeBasicSecService;
import com.vci.ubcs.code.service.ICodeClassifyValueService;
@@ -16,24 +19,32 @@
import com.vci.ubcs.starter.revision.model.TreeQueryObject;
import com.vci.ubcs.starter.revision.model.TreeWrapperOptions;
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.Tree;
import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
+import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
+import java.rmi.ServerException;
import java.util.*;
import java.util.stream.Collectors;
import static com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant.LC_STATUS;
-import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*;
+import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_CASCADE_LINKED_NOT_DELETE;
+import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST;
@Service
-public class CodeClassifyValueServiceImpl extends ServiceImpl<CodeClassifyValueMapper, CodeClassifyValue> implements ICodeClassifyValueService {
+public class CodeClassifyValueServiceImpl extends ServiceImpl<CodeClassifyValueMapper, CodeClassifyValue> implements ICodeClassifyValueService {
@Resource
private RevisionModelUtil revisionModelUtil;
@@ -48,7 +59,34 @@
/**
* 涓婄骇鑺傜偣鐨勫睘鎬у悕绉�
*/
- private static final String PARENT_FIELD_NAME = "parentClassifyValueOid";
+ private static final String PARENT_FIELD_NAME = "parentClassifyValueOid";
+
+ /**
+ * 鍏嬮殕鍒嗙被鐮佸��
+ * @param codeClassifyValues
+ * @return
+ */
+ @Override
+ public boolean cloneCodeClassifyVaue(List<CodeClassifyValue> codeClassifyValues) {
+ // 鍒涘缓Map瀵硅薄锛岀敤浜庡瓨鍌ㄥ師濮媜id鍜屾柊oid鐨勬槧灏勫叧绯�
+ Map<String, String> oidMap = new HashMap<>();
+ // 閬嶅巻瀵硅薄鏁扮粍锛屼负姣忎釜瀵硅薄鐢熸垚鏂扮殑oid锛屽苟灏嗗師濮媜id鍜屾柊oid鐨勬槧灏勫叧绯诲瓨鍌ㄥ埌Map涓�
+ for (CodeClassifyValue obj : codeClassifyValues) {
+ String originalOid = obj.getOid();
+ String newOid = VciBaseUtil.getPk();
+ oidMap.put(originalOid, newOid);
+ }
+ // 閬嶅巻瀵硅薄鏁扮粍锛屾洿鏂版瘡涓璞$殑oid鍜宑odeClassifySecOid灞炴�у��
+ for (CodeClassifyValue obj : codeClassifyValues) {
+ String originalOid = obj.getOid();
+ String newOid = oidMap.get(originalOid);
+ obj.setOid(newOid);
+ String originalParentClassifyValueOid = obj.getParentClassifyValueOid();
+ String newParentClassifyValueOid = oidMap.get(originalParentClassifyValueOid);
+ obj.setParentClassifyValueOid(newParentClassifyValueOid);
+ }
+ return this.saveBatch(codeClassifyValues);
+ }
/**
* 鏌ヨ鍒嗙被鐮佹鐨勭爜鍊� 鏍�
@@ -58,14 +96,13 @@
*/
@Override
public List<Tree> treeCodeClassifyValue(TreeQueryObject treeQueryObject) throws VciBaseException {
- // List<CodeClassifyValueDO> doList =selectCodeClassifyValueDOByTree(treeQueryObject);
- List<CodeClassifyValue> doList =selectCodeClassifyValueDO4Tree(treeQueryObject);
+ List<CodeClassifyValue> doList = selectCodeClassifyValueDO4Tree(treeQueryObject);
List<CodeClassifyValueVO> voList = CodeClassifyValueWrapper.build().listVO(doList);
TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(PARENT_FIELD_NAME);
treeWrapperOptions.copyFromTreeQuery(treeQueryObject);
return revisionModelUtil.doList2Trees(voList,treeWrapperOptions,(CodeClassifyValueVO s) ->{
//鍙互鍦ㄨ繖閲屽鐞嗘爲鑺傜偣鐨勬樉绀�
- return s.getId() + " " + s.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s
+ return s.getId() + " " + (Func.isNotEmpty(s.getName()) ? s.getName():"") + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s
.getLcStatus()) ? (" 銆愬仠鐢ㄣ�� ") : "");
});
}
@@ -77,12 +114,13 @@
* @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public boolean addSave(CodeClassifyValueDTO codeClassifyValueDTO) throws VciBaseException{
VciBaseUtil.alertNotNull(codeClassifyValueDTO,"闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄");
//娣诲姞瀵圭爜鍊煎瓙鐖剁骇鐨勫垽鏂�
- if(StringUtils.isNotBlank(codeClassifyValueDTO.getParentclassifyvalueoid())){
- String parentclassifyvalueoid = codeClassifyValueDTO.getParentclassifyvalueoid();
- String codeclassifysecoid = codeClassifyValueDTO.getCodeclassifysecoid();
+ if(StringUtils.isNotBlank(codeClassifyValueDTO.getParentClassifyValueOid())){
+ String parentclassifyvalueoid = codeClassifyValueDTO.getParentClassifyValueOid();
+ String codeclassifysecoid = codeClassifyValueDTO.getCodeClassifySecOid();
CodeClassifyValue parentDO = codeClassifyValueMapper.selectById(parentclassifyvalueoid);
if (parentDO.getCodeClassifySecOid().equalsIgnoreCase(codeclassifysecoid)){
throw new VciBaseException("涓嶅厑璁稿湪鐖剁爜鍊间腑鐩存帴娣诲姞瀛愮爜鍊�");
@@ -91,11 +129,17 @@
//灏咲TO杞崲涓篋O
CodeClassifyValue codeClassifyValueDO = new CodeClassifyValue();
BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyValueDTO,codeClassifyValueDO);
+ //濉厖涓�浜涢粯璁ゅ��
+ DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeClassifyValueDO, MdmBtmTypeConstant.CODE_CLASSIFY_VALUE);
+ LambdaQueryWrapper<CodeClassifyValue> wrapper = Wrappers.<CodeClassifyValue>query()
+ .lambda().eq(CodeClassifyValue::getCodeClassifySecOid, codeClassifyValueDO.getCodeClassifySecOid());
+ if(Func.isEmpty(codeClassifyValueDO.getParentClassifyValueOid())){
+ wrapper.isNull(CodeClassifyValue::getParentClassifyValueOid);
+ }else{
+ wrapper.eq(CodeClassifyValue::getParentClassifyValueOid, codeClassifyValueDO.getParentClassifyValueOid());
+ }
//鏌ヨ
- List<CodeClassifyValue> existList = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query()
- .lambda().eq(CodeClassifyValue::getCodeClassifySecOid, codeClassifyValueDO.getCodeClassifySecOid())
- .eq(CodeClassifyValue::getParentClassifyValueOid, codeClassifyValueDO.getParentClassifyValueOid())
- );
+ List<CodeClassifyValue> existList = codeClassifyValueMapper.selectList(wrapper);
codeClassifyValueDO.setOrderNum(existList.size() + 1);
boolean resBoolean = codeClassifyValueMapper.insert(codeClassifyValueDO) > 0;
return resBoolean;
@@ -108,11 +152,14 @@
* @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public boolean editSave(CodeClassifyValueDTO codeClassifyValueDTO) throws VciBaseException{
VciBaseUtil.alertNotNull(codeClassifyValueDTO,"鏁版嵁瀵硅薄",codeClassifyValueDTO.getOid(),"鍒嗙被鐮佹鐨勭爜鍊间富閿�");
//灏咲TO杞崲涓篋O
CodeClassifyValue codeClassifyValueDO = selectByOid(codeClassifyValueDTO.getOid());
revisionModelUtil.copyFromDTOIgnore(codeClassifyValueDTO,codeClassifyValueDO);
+ //濉厖涓�浜涢粯璁ゅ��
+ DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeClassifyValueDO);
boolean resBoolean = codeClassifyValueMapper.updateById(codeClassifyValueDO) > 0;
return resBoolean;
}
@@ -137,9 +184,7 @@
* @return success涓簍rue涓哄彲浠ュ垹闄わ紝false琛ㄧず鏈夋暟鎹紩鐢紝obj涓簍rue琛ㄧず鏈変笅绾�
*/
private R checkIsCanDeleteForDO(CodeClassifyValueDTO codeClassifyValueDTO, CodeClassifyValue codeClassifyValueDO) {
- if (!checkTs(codeClassifyValueDTO)) {
- return R.fail(TS_NOT_PROCESS);
- }
+ //boService.checkTs(codeClassifyValueDTO);
//鏍¢獙涓嬬骇鏄惁鏈夊紩鐢�
if(checkChildIsLinked(codeClassifyValueDO.getOid())){
return R.fail(DATA_CASCADE_LINKED_NOT_DELETE);
@@ -205,18 +250,16 @@
CodeClassifyValue codeClassifyValueDO = selectByOid(codeClassifyValueDTO.getOid());
R baseResult = checkIsCanDeleteForDO(codeClassifyValueDTO,codeClassifyValueDO);
if(baseResult.isSuccess()) {
- //鎵句笅绾х殑锛岃繖涓槸鍙互鍒犻櫎鐨勬椂鍊橰
- List<String> childrenOids = codeClassifyValueMapper.selectAllLevelChildOid(codeClassifyValueDO.getOid().trim());
+ //鍏堝垹闄や笅绾х爜鍊硷紝鎵句笅绾х殑锛岃繖涓槸鍙互鍒犻櫎鐨勬椂鍊�
+ List<String> childrenOids = codeClassifyValueMapper.selectChildOid(codeClassifyValueDO.getOid().trim());
if (!CollectionUtils.isEmpty(childrenOids)) {
Collection<Collection<String>> childrenCollections = VciBaseUtil.switchCollectionForOracleIn(childrenOids);
for(Collection<String> s : childrenCollections){
- codeClassifyValueMapper.delete(Wrappers.<CodeClassifyValue>query().lambda().eq(CodeClassifyValue::getOid,s));
+ codeClassifyValueMapper.deleteBatchIds(s);
}
}
- }else{
- return baseResult;
}
- //鎵ц鍒犻櫎鎿嶄綔
+ //鎵ц鍒犻櫎鎿嶄綔锛屽啀鍒犻櫎鐖剁殑鐮佸��
boolean resBoolean = codeClassifyValueMapper.deleteById(codeClassifyValueDO.getOid()) > 0;
return R.status(resBoolean);
}
@@ -273,7 +316,7 @@
*/
@Override
@Transactional(rollbackFor = Exception.class)
- public R batchSave4Order(List<CodeClassifyValueDTO> dtoList, String codeclassifysecoid) {
+ public R batchSave4Order(List<CodeClassifyValueDTO> dtoList, String codeclassifysecoid) throws VciBaseException{
VciBaseUtil.alertNotNull(codeclassifysecoid,"鍒嗙被鐮佹涓婚敭");
List<CodeClassifyValue> valueDOList = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query()
.lambda().eq(CodeClassifyValue::getCodeClassifySecOid,codeclassifysecoid)
@@ -281,18 +324,21 @@
List<CodeClassifyValue> updateList = new ArrayList<>();
dtoList.forEach(dto -> {
- if( StringUtils.isNotBlank( dto.getOid() )){
+ if(StringUtils.isNotBlank(dto.getOid())){
List<CodeClassifyValue> collect = valueDOList.stream().filter(value -> {
return dto.getOid().equals(value.getOid());
}).collect(Collectors.toList());
collect.forEach(ccv -> {
- ccv.setOrderNum(dto.getOrdernum());
+ ccv.setOrderNum(dto.getOrderNum());
ccv.setId(dto.getId());
ccv.setName(dto.getName());
updateList.add(ccv);
});
}
});
+ if(updateList.isEmpty()){
+ return R.fail("璇ユ搷浣滄湁璇�愬緟鎿嶄綔闆嗗悎涓虹┖銆戙��");
+ }
boolean resBoolean = this.updateBatchById(updateList);
return R.status(resBoolean);
}
@@ -336,24 +382,109 @@
List<String> oids = codeBasicSecService.getOidByCodeclassifysecOid(conditionMap.get("codeclassifysecoid"));
LambdaQueryWrapper<CodeClassifyValue> wrapper = Wrappers.<CodeClassifyValue>query()
.lambda().in(CodeClassifyValue::getCodeClassifySecOid,oids)
- .orderByDesc(CodeClassifyValue::getOrderNum);
+ .orderByAsc(CodeClassifyValue::getOrderNum);
return codeClassifyValueMapper.selectList(wrapper);
}
/**
- * 妫�鏌s
- * @param tempDO
- * @return
+ * 浣跨敤鐮佹鐨勪富閿幏鍙栧垎绫荤殑鐮佸�煎唴瀹�
+ *
+ * @param classifySecOid 鐮佹鐨勪富閿�
+ * @param parentClassifyValueOid 涓婄骇鍒嗙被鐨勪富閿�
+ * @return 鍒嗙被鐮佸�肩殑鍐呭
*/
- private boolean checkTs(CodeClassifyValueDTO tempDO){
- LambdaQueryWrapper<CodeClassifyValue> wrapper = Wrappers.<CodeClassifyValue>query()
- .lambda().eq(CodeClassifyValue::getOid,tempDO.getOid()).select(CodeClassifyValue::getTs);
- long dbTs = codeClassifyValueMapper.selectById(wrapper).getTs().getTime();
- long currentTs = tempDO.getTs().getTime();
- if(dbTs == currentTs){
- return true;
+ @Override
+ public List<CodeClassifyValueVO> listCodeClassifyValueBySecOid(String classifySecOid, String parentClassifyValueOid) {
+ if(StringUtils.isBlank(classifySecOid)){
+ return new ArrayList<>();
}
- return false;
+ CodeBasicSec secDO = codeBasicSecService.getById(classifySecOid);
+ if(secDO == null || StringUtils.isBlank(secDO.getOid())){
+ throw new VciBaseException("鐮佹鐨勫唴瀹瑰湪绯荤粺涓笉瀛樺湪");
+ }
+ if(StringUtils.isNotBlank(secDO.getParentClassifySecOid()) && StringUtils.isBlank(parentClassifyValueOid)){
+ return new ArrayList<>();
+ //鍥犱负鏈変笂绾у垎绫荤殑鏃跺�欙紝蹇呴』鍏堥�夋嫨涓婄骇鍒嗙被鐨勫唴瀹�
+ }
+// Map<String,String> conditionMap = new HashMap<>();
+// conditionMap.put("codeClassifySecOid",classifySecOid);
+// if(StringUtils.isNotBlank(parentClassifyValueOid)){
+// conditionMap.put("parentClassifyValueOid",parentClassifyValueOid);
+// }
+// PageHelper pageHelper = new PageHelper(-1);
+// pageHelper.addDefaultAsc("ordernum");
+ QueryWrapper<CodeClassifyValue> wrapper = new QueryWrapper<>();
+ wrapper.eq("codeClassifySecOid",classifySecOid);
+ if(StringUtils.isNotBlank(parentClassifyValueOid)){
+ wrapper.in("parentClassifyValueOid",VciBaseUtil.str2List(parentClassifyValueOid));
+ }
+ wrapper.orderByAsc("ordernum");
+
+ List<CodeClassifyValue> valueDOList = codeClassifyValueMapper.selectList(wrapper);
+ return codeClassifyValueDO2VOs(valueDOList);
}
+ /**
+ * 鏍规嵁涓婚敭鑾峰彇鐮佸�煎瓧绗︿覆
+ * @param oid
+ * @return
+ */
+ @Override
+ public String getClassifyValueStr(String oid){
+ if(Func.isEmpty(oid)){
+ return "";
+ }
+ String classifyValueStr = this.codeClassifyValueMapper.getClassifyValueStr(oid);
+ return Func.isEmpty(classifyValueStr) ? "":classifyValueStr;
+ }
+
+ /**
+ * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
+ * @param codeClassifyValueDOs 鏁版嵁瀵硅薄鍒楄〃
+ * @return 鏄剧ず瀵硅薄
+ * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呬笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
+ */
+ @Override
+ public List<CodeClassifyValueVO> codeClassifyValueDO2VOs(Collection<CodeClassifyValue> codeClassifyValueDOs) throws VciBaseException{
+ List<CodeClassifyValueVO> voList = new ArrayList<CodeClassifyValueVO>();
+ if(!CollectionUtils.isEmpty(codeClassifyValueDOs)){
+ for(CodeClassifyValue s: codeClassifyValueDOs){
+ CodeClassifyValueVO vo = codeClassifyValueDO2VO(s);
+ if(vo != null){
+ voList.add(vo);
+ }
+ }
+ }
+ return voList;
+ }
+
+ /**
+ * 鏍规嵁codeClassifySecOid鍒犻櫎鐮佸��
+ * @param codeClassifySecOid
+ * @return
+ * @throws ServerException
+ */
+ @Override
+ public Boolean deleteClassifyValueBySecOid(String codeClassifySecOid) throws ServerException {
+ LambdaQueryWrapper<CodeClassifyValue> wrapper = Wrappers.<CodeClassifyValue>query()
+ .lambda().eq(CodeClassifyValue::getCodeClassifySecOid, codeClassifySecOid);
+ return codeClassifyValueMapper.delete(wrapper) > 0;
+ }
+
+ /**
+ * 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
+ * @param codeClassifyValueDO 鏁版嵁瀵硅薄
+ * @return 鏄剧ず瀵硅薄
+ * @throws VciBaseException 鎷疯礉灞炴�у嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
+ */
+ @Override
+ public CodeClassifyValueVO codeClassifyValueDO2VO(CodeClassifyValue codeClassifyValueDO) throws VciBaseException{
+ CodeClassifyValueVO vo = new CodeClassifyValueVO();
+ if(codeClassifyValueDO != null){
+ BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyValueDO,vo);
+ //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
+
+ }
+ return vo;
+ }
}
--
Gitblit v1.9.3