From b267ac7499877043675bbd25d1478b1731c12ec9 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期五, 24 十一月 2023 15:14:03 +0800
Subject: [PATCH] 代码提交
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java | 610 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 524 insertions(+), 86 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java
index ed02a92..6592961 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java
@@ -2,53 +2,63 @@
import com.alibaba.cloud.commons.lang.StringUtils;
import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.vci.ubcs.code.constant.MdmBtmTypeConstant;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+
import com.vci.ubcs.code.dto.CodeBasicSecDTO;
-import com.vci.ubcs.code.entity.CodeBasicSec;
-import com.vci.ubcs.code.entity.CodeClassifyValue;
-import com.vci.ubcs.code.entity.CodeFixedValue;
+import com.vci.ubcs.code.dto.CodeOrderDTO;
+import com.vci.ubcs.code.dto.CodeOrderSecDTO;
+import com.vci.ubcs.code.entity.*;
import com.vci.ubcs.code.enumpack.*;
import com.vci.ubcs.code.lifecycle.CodeRuleLC;
import com.vci.ubcs.code.mapper.CodeBasicSecMapper;
import com.vci.ubcs.code.mapper.CodeClassifyValueMapper;
import com.vci.ubcs.code.mapper.CodeFixedValueMapper;
-import com.vci.ubcs.code.service.ICodeBasicSecService;
-import com.vci.ubcs.code.service.ICodeClassifyValueService;
-import com.vci.ubcs.code.service.ICodeFixedValueService;
-import com.vci.ubcs.code.service.ICodeRuleService;
-import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO;
-import com.vci.ubcs.code.vo.pagemodel.CodeFixedValueVO;
-import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO;
+import com.vci.ubcs.code.mapper.CodeSerialValueMapper;
+import com.vci.ubcs.code.service.*;
+import com.vci.ubcs.code.vo.CodeReferConfigVO;
+import com.vci.ubcs.code.vo.pagemodel.*;
import com.vci.ubcs.code.wrapper.CodeBasicSecWrapper;
+import com.vci.ubcs.omd.cache.EnumCache;
+import com.vci.ubcs.omd.enums.EnumEnum;
+import com.vci.ubcs.starter.enumpack.CodeTableNameEnum;
import com.vci.ubcs.starter.exception.VciBaseException;
+import com.vci.ubcs.starter.revision.model.BaseModel;
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.util.UBCSCondition;
+import com.vci.ubcs.starter.util.UBCSSqlKeyword;
import com.vci.ubcs.starter.web.enumpck.OsCodeFillTypeEnum;
-import com.vci.ubcs.starter.web.pagemodel.KeyValue;
-import com.vci.ubcs.starter.web.pagemodel.UIFormReferVO;
+import com.vci.ubcs.starter.web.pagemodel.*;
import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
+import com.vci.ubcs.starter.web.util.VciDateUtil;
import com.vci.ubcs.starter.web.util.WebUtil;
import com.vci.ubcs.system.entity.DictBiz;
import com.vci.ubcs.system.feign.IDictBizClient;
-import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
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.FrameWorkLangCodeConstant.*;
+import static com.vci.ubcs.code.constant.MdmEngineConstant.EMPTY_SERIAL_UNIT;
+import static com.vci.ubcs.code.constant.MdmEngineConstant.SERIAL_UNIT_SPACE;
/**
* 鐮佹鍩虹淇℃伅鏈嶅姟鎺ュ彛
@@ -85,6 +95,9 @@
private ICodeClassifyValueService codeClassifyValueService;
@Resource
+ private ICodeReferConfigService codeReferConfigService;
+
+ @Resource
private IDictBizClient iDictBizClient;
/**
@@ -94,9 +107,15 @@
private ICodeFixedValueService fixedValueService;
/**
+ * 娴佹按鍙风殑鐩稿叧鐨勪俊鎭�
+ */
+ @Resource
+ private CodeSerialValueMapper serialValueMapper;
+
+ /**
* 涓婂眰鍒嗙被鐮佹鐨勫睘鎬у悕绉�
*/
- private static final String PARENT_FIELD_NAME = "parentclassifysecoid";
+ private static final String PARENT_FIELD_NAME = "parentClassifySecOid";
/**
* 涓婄骇鍒嗙被鐮佸�肩殑灞炴�у悕绉�
@@ -105,19 +124,27 @@
/**
* 鏌ヨ鎵�鏈夌殑鐮佹鍩虹淇℃伅
- *
- * @param page 鏌ヨ鏉′欢
- * @param codeBasicSecVO 鍒嗛〉鍜屾帓搴�
+ * @param conditionMap 鏌ヨ鏉′欢
+ * @param query 鍒嗛〉瀵硅薄
* @return 鎵ц缁撴灉
* @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
*/
@Override
- public IPage<CodeBasicSecVO> gridCodeBasicSec(IPage<CodeBasicSecVO> page, CodeBasicSecVO codeBasicSecVO) throws VciBaseException {
- if(Func.isEmpty(codeBasicSecVO.getPkCodeRule()) || Func.isBlank(codeBasicSecVO.getPkCodeRule())){
+ public IPage<CodeBasicSecVO> gridCodeBasicSec(Query query, Map<String,Object> conditionMap) throws ServiceException {
+ if(Func.isEmpty(Func.isEmpty(conditionMap.get(CodeTableNameEnum.PL_CODE_BASICSEC.getText()+".pkCodeRule")))){
return null;
}
- List<CodeBasicSec> codeBasicSecs = codeBasicSecMapper.selectCodeBasicSecPage(page, codeBasicSecVO);
- return page.setRecords(CodeBasicSecWrapper.build().listVO(codeBasicSecs));
+ // 鑱旇〃鏌ヨ ,璁剧疆琛ㄥ埆鍚嶏紝琛ㄥ埆鍚嶉粯璁ゅ氨閲囩敤琛ㄥ悕灏忓啓锛岄厤缃珮绾ф煡璇㈢殑鏃跺�欏氨闇�瑕佹牴鎹繖涓潵瀵箇here鏉′欢杩涜閰嶇疆
+ MPJLambdaWrapper<CodeBasicSec> mpjLambdaWrapper = new MPJLambdaWrapper<>(CodeBasicSec.class, CodeTableNameEnum.PL_CODE_BASICSEC.getText())
+ .selectAll(CodeBasicSec.class)
+ .selectAs(CodeClassify::getName, CodeBasicSec::getReferCodeClassifyOidName)
+ .leftJoin(CodeClassify.class, CodeTableNameEnum.PL_CODE_CLASSIFY.getText(), CodeClassify::getOid, CodeBasicSec::getReferCodeClassifyOid)
+ .leftJoin(CodeBasicSec.class,CodeTableNameEnum.PL_CODE_BASICSEC.getText()+1,CodeBasicSec::getOid,CodeBasicSec::getParentClassifySecOid
+ ,ext->ext.selectAs(CodeBasicSec::getName,CodeBasicSec::getParentClassifySecText));
+ // 娣诲姞where鏉′欢
+ UBCSSqlKeyword.buildConditionByAs(conditionMap,mpjLambdaWrapper,CodeTableNameEnum.PL_CODE_BASICSEC.getText());
+ IPage<CodeBasicSec> codeBasicSecIPage = codeBasicSecMapper.selectPage(UBCSCondition.getPage(query), mpjLambdaWrapper);
+ return CodeBasicSecWrapper.build().pageVO(codeBasicSecIPage);
}
/**
@@ -127,7 +154,7 @@
*/
@Override
@Transactional(rollbackFor = Exception.class)
- public boolean batchDeleteSecByCodeRuleOid(String codeRuleOid) {
+ public boolean batchDeleteSecByCodeRuleOid(String codeRuleOid) throws ServiceException {
VciBaseUtil.alertNotNull(codeRuleOid,"缂栫爜瑙勫垯涓婚敭");
// 1銆侀�氳繃pkcoderule浣滀负鏉′欢锛屽厛鏌ヨ瑕佸垹闄ゅ熀纭�鐮佹
List<CodeBasicSec> deleteList = this.codeBasicSecMapper.selectList(Wrappers.<CodeBasicSec>query().eq("pkcoderule", codeRuleOid));
@@ -144,9 +171,11 @@
// 灏嗚浣滀负鍒犻櫎鏉′欢鐨勫�兼斁鍦ㄤ竴涓泦鍚堥噷闈�
Set<String> fixedSecOidSet = fixedSecList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet());
// 閫氳繃澶栭敭杩涜鏌ヨ
- List<CodeFixedValue> fixedValueS = fixedValueMapper.selectList(Wrappers.<CodeFixedValue>query().lambda().in(CodeFixedValue::getCodeFixedSecOid,fixedSecOidSet));
- // 鏍规嵁鏌ヨ鍑烘潵鐨刬d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎
- deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet()))>0;
+ List<CodeFixedValue> fixedValues = fixedValueMapper.selectList(Wrappers.<CodeFixedValue>query().lambda().in(CodeFixedValue::getCodeFixedSecOid,fixedSecOidSet));
+ if(!fixedValues.isEmpty()){
+ // 鏍规嵁鏌ヨ鍑烘潵鐨刬d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎
+ deletFlag = fixedValueMapper.deleteBatchIds(fixedValues.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet()))>0;
+ }
}
// 4銆佸啀鍒犻櫎鍒嗙被鐮佹
List<CodeBasicSec> classifySecList = deleteList.stream().filter(sec -> {
@@ -156,9 +185,11 @@
// 灏嗚浣滀负鍒犻櫎鏉′欢鐨勫�兼斁鍦ㄤ竴涓泦鍚堥噷闈�
Set<String> classifySecOidSet = classifySecList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet());
// 閫氳繃澶栭敭杩涜鏌ヨ
- List<CodeClassifyValue> fixedValueS = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query().lambda().in(CodeClassifyValue::getCodeClassifySecOid,classifySecOidSet));
- // 鏍规嵁鏌ヨ鍑烘潵鐨勪富閿甶d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎
- deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet()))>0;
+ List<CodeClassifyValue> codeClassifyValues = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query().lambda().in(CodeClassifyValue::getCodeClassifySecOid,classifySecOidSet));
+ if(!codeClassifyValues.isEmpty()){
+ // 鏍规嵁鏌ヨ鍑烘潵鐨勪富閿甶d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎
+ deletFlag = codeClassifyValueMapper.deleteBatchIds(codeClassifyValues.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet()))>0;
+ }
}
return deletFlag;
}
@@ -170,7 +201,7 @@
* @return 鏈夌┖鐨勫垯浼爇ey-灞炴�у悕 value-瀛楁鍚箟锛屾病鏈夌┖鐨勫垯浼� key-success value-true
*/
@Override
- public KeyValue checkAttrNullableBySecType(CodeBasicSecDTO codeBasicSecDTO) {
+ public KeyValue checkAttrNullableBySecType(CodeBasicSecDTO codeBasicSecDTO) throws ServiceException {
VciBaseUtil.alertNotNull(codeBasicSecDTO.getSecType(), "鐮佹鍒嗙被");
String secType = codeBasicSecDTO.getSecType();
HashMap<String, String> attrMap = JSONObject.parseObject(JSONObject.toJSONString(codeBasicSecDTO), HashMap.class);
@@ -215,13 +246,13 @@
CodeBasicSec codeBasicSecDO = new CodeBasicSec();
BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDTO, codeBasicSecDO);
//text杞崲
- codeBasicSecDO.setSecTypeText(CodeSecTypeEnum.getTextByValue(codeBasicSecDTO.getSecType()));
- codeBasicSecDO.setCodeLevelTypeText(CodeLevelTypeEnum.getTextByValue(codeBasicSecDTO.getCodeLevelType()));
- codeBasicSecDO.setCodeSecLengthTypeText(CodeSecLengthTypeEnum.getTextByValue(codeBasicSecDTO.getCodeSecLengthType()));
- codeBasicSecDO.setValueCutTypeText(CodeCutTypeEnum.getValueByText(codeBasicSecDTO.getValueCutType()));
- codeBasicSecDO.setCodeGetValueTypeText(CodeGetValueTypeEnum.getValueByText(codeBasicSecDTO.getCodeGetValueType()));
+ codeBasicSecDO.setSecTypeText(EnumCache.getValue(EnumEnum.CODE_SEC_TYPE,codeBasicSecDTO.getSecType()));
+ codeBasicSecDO.setCodeLevelTypeText(EnumCache.getValue(EnumEnum.CODE_LEVEL_TYPE,codeBasicSecDTO.getCodeLevelType()));
+ codeBasicSecDO.setCodeSecLengthTypeText(EnumCache.getValue(EnumEnum.CODE_SEC_LENGTH,codeBasicSecDTO.getCodeSecLengthType()));
+ codeBasicSecDO.setValueCutTypeText(EnumCache.getValue(EnumEnum.CODE_CUT_TYPE,codeBasicSecDTO.getValueCutType()));
+ codeBasicSecDO.setCodeGetValueTypeText(EnumCache.getValue(EnumEnum.CODE_GET_VALUE_TYPE,codeBasicSecDTO.getCodeGetValueType()));
//濉厖涓�浜涢粯璁ゅ��
- DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeBasicSecDO,MdmBtmTypeConstant.CODE_BASIC_SEC);
+ DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeBasicSecDO, MdmBtmTypeConstant.CODE_BASIC_SEC);
//鎺掑簭鍙凤紝榛樿绛変簬褰撳墠宸叉湁鐨勬暟閲忓姞1
Long total = codeBasicSecMapper.selectCount(Wrappers.<CodeBasicSec>query()
.lambda()
@@ -237,29 +268,88 @@
&& StringUtils.isBlank(codeBasicSecDO.getCodeFillSeparator())){
throw new VciBaseException("褰撹ˉ浣嶆柟寮忎负宸﹁ˉ浣嶆垨鑰呭彸琛ヤ綅鐨勬椂鍊欙紝琛ヤ綅瀛楃涓嶈兘涓虹┖");
}
+ CodeReferConfigVO codeReferConfigVO = null;
//寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸垽鏂弬鐓х殑淇℃伅鏄惁姝g‘
if(CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(codeBasicSecDO.getSecType())){
if(StringUtils.isBlank(codeBasicSecDO.getReferConfig())){
- throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐� 鍙傜収閰嶇疆 鐨勫唴瀹�");
+ throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐� 鍙傜収閰嶇疆鐨勫唴瀹�");
}
try{
- JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class);
+ //JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class);
+ codeReferConfigVO = JSONObject.parseObject(codeBasicSecDO.getReferConfig(), CodeReferConfigVO.class);
+ // 灏嗗弬鐓ч厤缃繘琛屾寔涔呭寲锛岀粰鐢ㄦ埛鎻愪緵鍙彲閫夋嫨鍙傜収閰嶇疆鐨勬柟寮�
}catch (Throwable e){
throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝鍙傜収閰嶇疆鐨勫唴瀹圭殑鏍煎紡涓嶆纭�,",new String[0],e);
+ }
+ // 鍒ゆ柇鏄惁涓哄紩鐢ㄧ爜娈碉紝濡傛灉鏄簲鐢ㄧ爜娈电殑璇濓紝涓轰簡閫傞厤鍓嶇缁勪欢锛岃繖閲岃瀵硅〃杩涜澶勭悊涓�涓嬶紝鎸夌収浠ュ墠鐨勫弬鐓ф牸寮忚繘琛岃浆鎹�
+ codeBasicSecDO.setReferValueInfo(referConfigToUIUiTable(codeReferConfigVO));
+ if(Func.toBoolean(codeReferConfigVO.getIsPersistence())){
+ codeReferConfigService.insert(codeReferConfigVO);
}
}
boolean resBoolean = codeBasicSecMapper.insert(codeBasicSecDO) > 0;
//SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo();
if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){
DictBiz dictBiz = new DictBiz();
- dictBiz.setCode(MdmBtmTypeConstant.CODE_BASIC_SEC);
- dictBiz.setDictKey("codefileseparator");
+ dictBiz.setCode("codeFillSeparator");
+ dictBiz.setDictKey(codeBasicSecDO.getCodeFillSeparator());
dictBiz.setDictValue(codeBasicSecDO.getCodeFillSeparator());
//浠庡師鏉ョ殑charService锛堝彲杈撳彲閫夛級鏇存敼涓鸿皟鐢╫md涓殑鎺ュ彛鏉ュ疄鐜�
iDictBizClient.getCheck(dictBiz);
//charService.save(MdmBtmTypeConstant.CODE_BASIC_SEC,"codefileseparator",codeBasicSecDO.getCodeFillSeparator(),sessionInfo);
}
return resBoolean;
+ }
+
+ /**
+ * 灏唕eferconfig杞崲涓篔SON鏍煎紡鐨刄IFormReferVO
+ * @param codeReferConfig
+ * @return
+ */
+ private String referConfigToUIUiTable(CodeReferConfigVO codeReferConfig){
+ // 鎷疯礉涓轰互鍓嶇殑鑰佸璞�
+ UIReferConfigFormVO uiFormReferVO = new UIReferConfigFormVO();
+ BeanUtil.copy(codeReferConfig,uiFormReferVO);
+
+ // 琛ㄦ牸鐨勮嚜瀹氫箟瀹氫箟
+ UITableConfigVO uiTableConfigVO = new UITableConfigVO();
+ uiTableConfigVO.setPage(new UITablePageVO(codeReferConfig.getLimit(),1));
+ // 鍒楄〃鐨勫垪鐨勪俊鎭浆鎹�
+ List<TableColVO> uiTableFieldVOs = new ArrayList<>();
+ // 蹇�熸煡璇㈠垪
+ List<TableColVO> queryColumns = new ArrayList<>();
+ if(!CollectionUtils.isEmpty(codeReferConfig.getCodeShowFieldConfigVOS())){
+ codeReferConfig.getCodeShowFieldConfigVOS().stream().forEach(showField ->{
+ TableColVO tableColVO = new TableColVO();
+ BeanUtil.copy(showField,tableColVO);
+ tableColVO.setSortField(showField.getAttrSortField());
+ uiTableFieldVOs.add(tableColVO);
+ if(Func.toBoolean(showField.getIsQuery())){
+ TableColVO tableQueryColumns = new TableColVO();
+ BeanUtil.copy(showField,tableQueryColumns);
+ tableColVO.setSortField(showField.getAttrSortField());
+ queryColumns.add(tableQueryColumns);
+ }
+ });
+ }
+ // 鏄剧ず鐨勫垪
+ uiTableConfigVO.setCols(uiTableFieldVOs);
+ // 蹇�熸煡璇㈠垪
+ uiTableConfigVO.setQueryColumns(queryColumns);
+ //set缁欒〃鏍奸厤缃睘鎬�
+ uiFormReferVO.setTableConfig(uiTableConfigVO);
+ //瀛楁鍚嶄笉涓�鑷达紝闇�瑕佹墜鍔╯et
+ uiFormReferVO.setMuti(Func.toBoolean(codeReferConfig.getIsMuti()));
+ uiFormReferVO.setInitSort(new UIFieldSortVO(codeReferConfig.getSortField(),codeReferConfig.getSortType()));
+ // 绛涢�夋潯浠�
+ HashMap<String, String> whereMap = new HashMap<>();
+ if(!codeReferConfig.getCodeSrchCondConfigVOS().isEmpty()){
+ codeReferConfig.getCodeSrchCondConfigVOS().stream().forEach(srch->{
+ whereMap.put(srch.getFilterField()+srch.getFilterType(),srch.getFilterValue());
+ });
+ }
+ uiFormReferVO.setWhere(whereMap);
+ return JSONObject.toJSONString(uiFormReferVO);
}
/**
@@ -271,10 +361,10 @@
*/
@Override
@Transactional(rollbackFor = Exception.class)
- public boolean editSave(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException {
+ public boolean editSave(CodeBasicSecDTO codeBasicSecDTO) throws ServerException {
VciBaseUtil.alertNotNull(codeBasicSecDTO, "闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄");
KeyValue attrKv = checkAttrNullableBySecType(codeBasicSecDTO);
- if (! "success".equals(attrKv.getKey())){
+ if (!"success".equals(attrKv.getKey())){
throw new VciBaseException(attrKv.getValue() + "涓嶈兘涓虹┖");
}
//灏咲TO杞崲涓篋O
@@ -282,6 +372,7 @@
DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeBasicSecDO);
boolean status = codeRuleService.checkEditDelStatus(codeRuleService.getObjectByOid(codeBasicSecDO.getPkCodeRule()).getLcStatus());
boolean resBoolean;
+ CodeReferConfigVO codeReferConfigVO = null;
if (!status){
//杩斿洖閿欒淇℃伅
throw new VciBaseException("缂栫爜瑙勫垯涓嶅厑璁哥紪杈戞垨鍒犻櫎锛�");
@@ -294,23 +385,46 @@
}
//寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸垽鏂弬鐓х殑淇℃伅鏄惁姝g‘
if(CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(codeBasicSecDO.getSecType())){
- if(StringUtils.isBlank(codeBasicSecDO.getReferConfig())){
- throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐� 鍙傜収閰嶇疆 鐨勫唴瀹�");
+ if(StringUtils.isBlank(codeBasicSecDTO.getReferConfig())){
+ throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐欏弬鐓ч厤缃殑鍐呭");
}
try{
- JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class);
+ // JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class);
+ codeReferConfigVO = JSONObject.parseObject(codeBasicSecDTO.getReferConfig(), CodeReferConfigVO.class);
}catch (Throwable e){
throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝鍙傜収閰嶇疆鐨勫唴瀹圭殑鏍煎紡涓嶆纭�,",new String[0],e);
}
+ // 鍒ゆ柇鏄惁涓哄紩鐢ㄧ爜娈碉紝濡傛灉鏄紩鐢ㄧ爜娈电殑璇濓紝涓轰簡閫傞厤鍓嶇缁勪欢锛岃繖閲岃瀵硅〃杩涜澶勭悊涓�涓嬶紝鎸夌収浠ュ墠鐨勫弬鐓ф牸寮忚繘琛岃浆鎹�
+ codeBasicSecDO.setReferValueInfo(referConfigToUIUiTable(codeReferConfigVO));
+ if(codeReferConfigVO.getIsPersistence()=="true"){
+ codeReferConfigService.insert(codeReferConfigVO);
+ }
}
- revisionModelUtil.copyFromDTOIgnore(codeBasicSecDTO, codeBasicSecDO);
+ // revisionModelUtil.copyFromDTOIgnore(codeBasicSecDTO, codeBasicSecDO);//姝ゅ鐨勬嫹璐濅細鎶妑eferValueInfo鐨勫�肩粰瑕嗙洊鎺夛紝闇�瑕侀噸鏂拌祴鍊�
+ BaseModel tempModel = new BaseModel();
+ BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDO, tempModel);
+ BeanUtil.copyProperties(codeBasicSecDTO, codeBasicSecDO,"referValueInfo");
+ BeanUtilForVCI.copyPropertiesIgnoreCase(tempModel, codeBasicSecDO);
+ codeBasicSecDO.setId(VciBaseUtil.getStringValueFromObject(VciBaseUtil.getValueFromField("id", codeBasicSecDTO)));
+ codeBasicSecDO.setName(VciBaseUtil.getStringValueFromObject(VciBaseUtil.getValueFromField("name", codeBasicSecDTO)));
+ codeBasicSecDO.setDescription(VciBaseUtil.getStringValueFromObject(VciBaseUtil.getValueFromField("description", codeBasicSecDTO)));
+
resBoolean = codeBasicSecMapper.updateById(codeBasicSecDO)>0;
+ // 浠庡垎绫荤爜娈垫垨鍥哄畾鐮佹鏀逛负鍏朵粬鐮佹鏃讹紝鍒ゆ柇鐢ㄦ埛鏄惁閫夋嫨浜嗘竻绌虹爜鍊�
+ if(codeBasicSecDTO.getIsClearValue()){
+ // 鍒嗙被鐮佸�兼竻绌�
+ if(codeBasicSecDTO.getSecType().equals(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue())){
+ codeClassifyValueService.deleteClassifyValueBySecOid(codeBasicSecDTO.getOid());
+ }else {
+ //鍥哄畾鐮佸�兼竻绌�
+ fixedValueService.deleteFixedValueBySecOid(codeBasicSecDTO.getOid());
+ }
+ }
//SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo();
if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){
- //杩欏効鐩墠闇�瑕佹敼 2023/4/24
DictBiz dictBiz = new DictBiz();
- dictBiz.setCode(MdmBtmTypeConstant.CODE_BASIC_SEC);
- dictBiz.setDictKey("codefileseparator");
+ dictBiz.setCode("codeFillSeparator");
+ dictBiz.setDictKey(codeBasicSecDO.getCodeFillSeparator());
dictBiz.setDictValue(codeBasicSecDO.getCodeFillSeparator());
//浠庡師鏉ョ殑charService锛堝彲杈撳彲閫夛級鏇存敼涓鸿皟鐢╫md涓殑鎺ュ彛鏉ュ疄鐜�
iDictBizClient.getCheck(dictBiz);
@@ -326,7 +440,7 @@
* @param secType 鐮佹绫诲瀷
* @return 涓嶅彲涓虹┖鐨勫瓧娈甸泦鍚�
*/
- private Map<String, String> getNotNullableAttr(String secType) {
+ private Map<String, String> getNotNullableAttr(String secType) throws ServiceException {
Map<String, String> attrMap = new HashMap<>();
if (CodeSecTypeEnum.CODE_ATTR_SEC.getValue().equalsIgnoreCase(secType)) {
attrMap.put("name", "灞炴�х爜娈靛悕绉�");
@@ -442,29 +556,29 @@
/**
* 鍙傜収鐮佹鍩虹淇℃伅鍒楄〃
*
- * @param codeBasicSecVO 鏌ヨ鏉′欢
- * @param page 鍒嗛〉鍜屾帓搴�
+ * @param conditionMap 鏌ヨ鏉′欢
+ * @param query 鍒嗛〉鍜屾帓搴�
* @return 鐮佹鍩虹淇℃伅鏄剧ず瀵硅薄鍒楄〃锛岀敓鏁堢殑鍐呭
* @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
*/
@Override
- public IPage<CodeBasicSecVO> refDataGridCodeBasicSec(IPage<CodeBasicSecVO> page, CodeBasicSecVO codeBasicSecVO) throws VciBaseException {
- return gridCodeBasicSec(page,codeBasicSecVO);
+ public IPage<CodeBasicSecVO> refDataGridCodeBasicSec(Query query ,Map<String,Object> conditionMap) throws VciBaseException {
+ return gridCodeBasicSec(query,conditionMap);
}
/**
* 鍙傜収鍒嗙被鐨勭爜娈�
- * @param codeBasicSecVO 鏌ヨ鏉′欢
- * @param page 鍒嗛〉鐨勫璞�
+ * @param conditionMap 鏌ヨ鏉′欢
+ * @param query 鍒嗛〉鍜屾帓搴�
* @return 鐮佹鐨勫唴瀹�
*/
@Override
- public IPage<CodeBasicSecVO> refDataGridClassifySec(IPage<CodeBasicSecVO> page, CodeBasicSecVO codeBasicSecVO) throws VciBaseException {
- if(Func.isEmpty(codeBasicSecVO.getPkCodeRule()) || Func.isBlank(codeBasicSecVO.getPkCodeRule())){
+ public IPage<CodeBasicSecVO> refDataGridClassifySec(Query query ,Map<String,Object> conditionMap) throws VciBaseException {
+ if(Func.isEmpty(conditionMap.get("pkCodeRule"))){
return null;
}
- codeBasicSecVO.setSecType(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue());
- return refDataGridCodeBasicSec(page,codeBasicSecVO);
+ conditionMap.put("secType",(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue()));
+ return refDataGridCodeBasicSec(query.setAscs("orderNum"),conditionMap);
}
/**
@@ -476,27 +590,123 @@
*/
@Override
@Transactional(rollbackFor = Exception.class)
- public R cloneCodeBasicSec(List<String> oidList, String pkCodeRule) {
+ public R cloneCodeBasicSec(List<String> oidList, String pkCodeRule) throws ServiceException, ServerException {
boolean isLinked = checkIsLinked(pkCodeRule,null);
if (isLinked) {
return R.fail("缂栫爜瑙勫垯宸茶寮曠敤锛屼笉鍏佽缂栬緫鎴栧垹闄�");
}
List<CodeBasicSec> createList = new ArrayList<>();
List<CodeBasicSec> basicSecDOS = codeBasicSecMapper.selectBatchIds(oidList);
- basicSecDOS.forEach(sec -> {
+ /* 闇�瑕佹敞鎰忕殑鏄厠闅嗚繃鏉ョ殑鐮佹闇�瑕佸orderNum杩涜鎺掑簭锛屽惁鍒欎細鍑虹幇鎺掑簭涔辫烦鐨勬儏鍐�
+ 瀹炵幇鏂瑰紡鏄煡璇㈠嚭璇ヨ鍒欎笅鏍规嵁orderNum鎺掑簭鍚庣殑鏈�鍚庝竴涓爜娈� */
+ LambdaQueryWrapper<CodeBasicSec> lastBasicWrapper = Wrappers.<CodeBasicSec>query()
+ .lambda().orderByDesc(CodeBasicSec::getOrderNum)
+ .eq(CodeBasicSec::getPkCodeRule,pkCodeRule)
+ .last("limit 1");
+ CodeBasicSec lastCodeBasicSec = codeBasicSecMapper.selectOne(lastBasicWrapper);
+ // 鎺掑簭鍙蜂粠杩欏効寮�濮嬫帓
+ int orderNum = Func.isEmpty(lastCodeBasicSec) || Func.isEmpty(lastCodeBasicSec.getOrderNum()) ? -1 : lastCodeBasicSec.getOrderNum();
+ if(basicSecDOS.isEmpty()){
+ return R.fail("鍏嬮殕鐨勭爜娈典俊鎭笉瀛樺湪锛�");
+ }
+ List<CodeBasicSec> codeClassifySec = new ArrayList<>();
+ Map<String,List<CodeFixedValue>> codeFixedValueMaps = new HashMap<>();
+ for (CodeBasicSec sec : basicSecDOS) {
CodeBasicSec newSecDO = new CodeBasicSec();
BeanUtilForVCI.copyPropertiesIgnoreCase(sec,newSecDO);
- newSecDO.setOid("");
- newSecDO.setNameOid("");
- newSecDO.setRevisionOid("");
- newSecDO.setId(newSecDO.getId() + "_copy");
- newSecDO.setName(newSecDO.getName() + "_copy");
+ String oldBasicOid = newSecDO.getOid();
+ newSecDO.setId(newSecDO.getId());
+ newSecDO.setName(newSecDO.getName());
+ orderNum++;
+ newSecDO.setOrderNum(orderNum);
newSecDO.setPkCodeRule(pkCodeRule);
+ // 鍒ゆ柇鏄惁鏄垎绫荤爜娈�,涓氬姟閫昏緫绋嶅井澶嶆潅涓�鐐规墍浠ラ渶瑕佸厛鎻愬嚭鏉ュ崟鐙鐞�
+ if(newSecDO.getSecType().equals(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue())){
+ // 瀛樺偍鏃х殑鐮佹oid鍜屾柊鐨勭爜娈电殑oid鐨勫叧鑱斿叧绯�
+ codeClassifySec.add(newSecDO);
+ continue;
+ }
+ // 鏇存敼鍒涘缓鏃堕棿锛屼慨鏀规椂闂寸瓑榛樿鍊�
+ DefaultAttrAssimtUtil.addDefaultAttrAssimt(newSecDO,MdmBtmTypeConstant.CODE_BASIC_SEC);
+ //鍥哄畾鐮佹
+ if(newSecDO.getSecType().equals(CodeSecTypeEnum.CODE_FIXED_SEC.getValue())){
+ // 鍥哄畾鐮佹瀛樺偍濂給id鍜岀爜鍊肩殑鍏宠仈鍏崇郴
+ codeFixedValueMaps.put(newSecDO.getOid(),fixedValueService.list(Wrappers.<CodeFixedValue>query()
+ .lambda().eq(CodeFixedValue::getCodeFixedSecOid, oldBasicOid)
+ ));
+ }
createList.add(newSecDO);
+ }
+ // 澶勭悊鍒嗙被鐮佹鐨刼id锛屽洜涓簅id鍏宠仈parentClassifyOid锛屼笌鐮佸�糲odeClassifyOid锛岀爜鍊煎張闇�瑕侀�氳繃鏃х殑鐮佹oid鏉ユ煡璇紝鎵�浠ヤ笉鑳界洿鎺ユ敼鍙榦id
+ changeParentOidAssnOid(codeClassifySec);
+ // 灏嗗鐞嗚繃鐨勫垎绫荤爜娈典篃娣诲姞杩涜鍋氭柊澧炲鐞嗙殑鐮佹闆嗗悎涓�
+ createList.addAll(codeClassifySec);
+ boolean resBoolean = true;
+ if(!createList.isEmpty()){
+ resBoolean = saveBatch(createList);
+ }
+ // 鏈�缁堣瀛樺叆鐮佸�艰〃涓殑锛岀爜鍊煎璞�
+ List<CodeFixedValue> codeFixedDOValues = new ArrayList<>();
+ // 鏋勯�犵爜鍊煎璞★紝涓庣爜娈典富閿叧鑱斿叧绯伙紝浠ュ強鏀瑰彉鍥哄畾鐮佸�肩殑oid
+ codeFixedValueMaps.forEach((key, value) -> {
+ value.stream().forEach(item -> {
+ item.setOid("");
+ item.setCodeFixedSecOid(key);
+ DefaultAttrAssimtUtil.updateDefaultAttrAssimt(item);
+ codeFixedDOValues.add(item);
+ });
});
- boolean b = saveBatch(createList);
- //codeBasicSecMapper.insertBatch(createList);
- return R.data(b,"鍏嬮殕鐮佹淇℃伅鎴愬姛");
+ boolean resFixed = true;
+ if(!codeFixedValueMaps.isEmpty()){
+ // 鍏嬮殕鍥哄畾鐮佸��
+ resFixed = fixedValueService.saveBatch(codeFixedDOValues);
+ }
+ return (resBoolean&&resFixed) ? R.data(resBoolean,"鍏嬮殕鐮佹淇℃伅鎴愬姛"):R.fail("鍏嬮殕鐮佹淇℃伅澶辫触锛�");
+ }
+
+ /**
+ * 鏀瑰彉鐮佹涓埗鍒嗙被鐮佹鍜屽瓙鍒嗙被鐮佹涔嬮棿鐨勫叧鑱攐id涓烘柊鐨刼id,骞朵笖涓嶇牬鍧忓垎绫荤爜鍊肩殑鍏宠仈鍏崇郴
+ * @param basicSecs
+ * @return
+ * @throws ServerException
+ */
+ @Override
+ public boolean changeParentOidAssnOid(List<CodeBasicSec> basicSecs) throws ServerException {
+ Map<String, List<CodeClassifyValue>> codeClassValues = new HashMap<>();
+ List<CodeClassifyValue> codeClassifyDOValues = new ArrayList<>();
+ HashMap<String, String> oidMap = new HashMap<>();
+ boolean resClone = false;
+ try {
+ // 閬嶅巻瀵硅薄鏁扮粍锛屼负姣忎釜瀵硅薄鐢熸垚鏂扮殑oid锛屽苟灏嗗師濮媜id鍜屾柊oid鐨勬槧灏勫叧绯诲瓨鍌ㄥ埌Map涓�
+ for (CodeBasicSec obj : basicSecs) {
+ String originalOid = obj.getOid();
+ String newOid = VciBaseUtil.getPk();
+ oidMap.put(originalOid, newOid);
+ }
+ // 閬嶅巻瀵硅薄鏁扮粍锛屾洿鏂版瘡涓璞$殑oid鍜宑odeClassifySecOid灞炴�у��
+ for (CodeBasicSec obj : basicSecs) {
+ String originalOid = obj.getOid();
+ String newOid = oidMap.get(originalOid);
+ // 鏂扮殑oid鍏宠仈瑕佸厠闅嗙爜鍊�
+ codeClassValues.put(newOid,codeClassifyValueService.list(Wrappers.<CodeClassifyValue>query()
+ .lambda().eq(CodeClassifyValue::getCodeClassifySecOid, originalOid)));
+ obj.setOid(newOid);
+ String originalParentClassifyValueOid = obj.getParentClassifySecOid();
+ String newParentClassifyValueOid = oidMap.get(originalParentClassifyValueOid);
+ obj.setParentClassifySecOid(newParentClassifyValueOid);
+ }
+ codeClassValues.forEach((key, value) -> {
+ value.stream().forEach(item -> {
+ DefaultAttrAssimtUtil.updateDefaultAttrAssimt(item);
+ item.setCodeClassifySecOid(key);
+ codeClassifyDOValues.add(item);
+ });
+ });
+ resClone = codeClassifyValueService.cloneCodeClassifyVaue(codeClassifyDOValues);
+ }catch (Exception e){
+ throw new ServerException("鐖跺垎绫荤爜娈靛拰瀛愬垎绫荤爜娈礳lone杞崲oid鏃跺嚭閿欙細"+e.getCause());
+ }
+ return resClone;
}
/**
@@ -540,7 +750,7 @@
*/
@Override
@Transactional(rollbackFor = Exception.class)
- public boolean upOrderNum(String oid) {
+ public boolean upOrderNum(String oid) throws ServiceException{
CodeBasicSec secDO = selectByOid(oid);
if(secDO.getOrderNum() > 1){
//绛変簬1鐨勬椂鍊欎笉鑳戒笂绉讳簡
@@ -571,7 +781,7 @@
*/
@Override
@Transactional(rollbackFor = Exception.class)
- public boolean downOrderNum(String oid) {
+ public boolean downOrderNum(String oid) throws ServiceException {
CodeBasicSec secDO = selectByOid(oid);
Long total = codeBasicSecMapper.selectCount(Wrappers.<CodeBasicSec>query()
.lambda().eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule())
@@ -603,7 +813,7 @@
* @return
*/
@Override
- public List<String> getOidByCodeclassifysecOid(String codeClassifySecOid) {
+ public List<String> getOidByCodeclassifysecOid(String codeClassifySecOid)throws ServiceException {
return codeBasicSecMapper.getOidByCodeclassifysecOid(codeClassifySecOid.trim());
}
@@ -675,7 +885,6 @@
return codeBasicSecDO;
}
-
/**
* 浣跨敤瑙勫垯鐨勪富閿幏鍙栧搴旂殑鐮佹鍐呭
*
@@ -683,17 +892,14 @@
* @return 鐮佹鐨勫唴瀹�
*/
@Override
- public List<CodeBasicSecVO> listCodeBasicSecByRuleOid(String ruleOid) {
+ public List<CodeBasicSecVO> listCodeBasicSecByRuleOid(String ruleOid)throws ServiceException {
if(StringUtils.isBlank(ruleOid)){
return new ArrayList<>();
}
- Map<String,String> conditionMap = new HashMap<>();
- conditionMap.put("pkCodeRule",ruleOid);
-// PageHelper pageHelper = new PageHelper(-1);
-// pageHelper.addDefaultAsc("ordernum");
- QueryWrapper<CodeBasicSec> wrapper = new QueryWrapper<>();
- wrapper.orderByAsc("ordernum");
- List<CodeBasicSec> secDOList = codeBasicSecMapper.selectList(wrapper);//.selectByCondition(conditionMap, pageHelper);
+ LambdaQueryWrapper<CodeBasicSec> wrapper = Wrappers.<CodeBasicSec>query().lambda()
+ .eq(CodeBasicSec::getPkCodeRule, ruleOid)
+ .orderByAsc(CodeBasicSec::getOrderNum);
+ List<CodeBasicSec> secDOList = baseMapper.selectList(wrapper);//
return codeBasicSecDO2VOs(secDOList,true);
}
@@ -730,6 +936,27 @@
}
/**
+ * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
+ *
+ * @param codeBasicSecDOs 鏁版嵁瀵硅薄鍒楄〃
+ * @return 鏄剧ず瀵硅薄
+ * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呬笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
+ */
+ @Override
+ public List<CodeBasicSecVO> codeBasicSecDO2VOs(Collection<CodeBasicSec> codeBasicSecDOs) throws VciBaseException {
+ List<CodeBasicSecVO> voList = new ArrayList<CodeBasicSecVO>();
+ if (!CollectionUtils.isEmpty(codeBasicSecDOs)) {
+ for (CodeBasicSec s : codeBasicSecDOs) {
+ CodeBasicSecVO vo = codeBasicSecDO2VO(s);
+ if (vo != null) {
+ voList.add(vo);
+ }
+ }
+ }
+ return voList;
+ }
+
+ /**
* 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
*
* @param codeBasicSecDO 鏁版嵁瀵硅薄
@@ -738,14 +965,225 @@
*/
@Override
public CodeBasicSecVO codeBasicSecDO2VO(CodeBasicSec codeBasicSecDO) throws VciBaseException {
- CodeBasicSecVO vo = new CodeBasicSecVO();
+ CodeBasicSecVO codeBasicSecVO = new CodeBasicSecVO();
if (codeBasicSecDO != null) {
- BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDO, vo);
+ BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDO, codeBasicSecVO);
+ if(StringUtils.isNotBlank(codeBasicSecDO.getSecType())){
+ codeBasicSecVO.setSecTypeText(EnumCache.getValue(EnumEnum.CODE_SEC_TYPE,codeBasicSecDO.getSecType()));
+ }
+ if(StringUtils.isNotBlank(codeBasicSecDO.getCodeLevelType())){
+ codeBasicSecVO.setCodeLevelTypeText(EnumCache.getValue(EnumEnum.CODE_LEVEL_TYPE,codeBasicSecDO.getCodeLevelType()));
+ }
+ if(StringUtils.isNotBlank(codeBasicSecDO.getCodeSecLengthType())){
+ codeBasicSecVO.setCodeSecLengthTypeText(EnumCache.getValue(EnumEnum.CODE_SEC_LENGTH,codeBasicSecDO.getCodeSecLengthType()));
+ }
+ if(StringUtils.isNotBlank(codeBasicSecDO.getValueCutType())){
+ codeBasicSecVO.setValueCutTypeText(EnumCache.getValue(EnumEnum.CODE_CUT_TYPE,codeBasicSecDO.getValueCutType()));
+ }
+ if(StringUtils.isNotBlank(codeBasicSecDO.getCodeGetValueType())){
+ codeBasicSecVO.setCodeGetValueTypeText(EnumCache.getValue(EnumEnum.CODE_GET_VALUE_TYPE,codeBasicSecDO.getCodeGetValueType()));
+ }
+ // 濡傛灉鏄垎绫荤爜娈甸渶瑕佹煡璇㈡墍灞炲垎绫荤殑涓枃鍚嶇О
+ if(codeBasicSecDO.getSecType().equals("codeclassifysec") && Func.isNotEmpty(codeBasicSecDO.getParentClassifySecOid())){
+ CodeBasicSec codeBasicSec = codeBasicSecMapper.selectOne(Wrappers.<CodeBasicSec>query().lambda()
+ .eq(CodeBasicSec::getOid, codeBasicSecDO.getParentClassifySecOid())
+ .eq(CodeBasicSec::getSecType, codeBasicSecDO.getSecType()));
+ if(Func.isNotEmpty(codeBasicSec)){
+ codeBasicSecVO.setParentClassifySecOid(codeBasicSec.getOid());
+ codeBasicSecVO.setParentClassifySecText(codeBasicSec.getName());
+ }
+ }
//濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
if (true) {
//vo.setLcStatusText({lcStatusFullClassName}.getTextByValue(vo.getLcStatus()));
}
}
- return vo;
+ return codeBasicSecVO;
+ }
+
+ /**
+ * 鏍规嵁缂栫爜瑙勫垯涓婚敭鑾峰彇缂栫爜涓嬬殑娴佹按渚濊禆鐮佹
+ *
+ * @param oid 缂栫爜瑙勫垯涓婚敭
+ * @return
+ * @throws VciBaseException
+ */
+ @Override
+ public CodeRuleVO getSerialNumberDepend(String oid) throws VciBaseException {
+ VciBaseUtil.alertNotNull(oid,"缂栫爜瑙勫垯涓婚敭");
+ CodeRuleVO codeRuleVO = codeRuleService.getObjectByOid(oid);
+ if (codeRuleVO != null) {
+ //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
+ codeRuleVO.setLcStatusText(CodeRuleLC.getTextByValue(codeRuleVO.getLcStatus()));
+
+ LambdaQueryWrapper<CodeBasicSec> wrapper = Wrappers.<CodeBasicSec>query().lambda()
+ .eq(CodeBasicSec::getPkCodeRule, codeRuleVO.getOid())
+ .eq(CodeBasicSec::getSecType,CodeSecTypeEnum.CODE_SERIAL_SEC.getValue());
+ CodeBasicSec codeBasicSec = this.getOne(wrapper);
+ if(codeBasicSec != null && VciBaseUtil.isNotNull(codeBasicSec.getOid())){
+ wrapper = Wrappers.<CodeBasicSec>query().lambda()
+ .eq(CodeBasicSec::getPkCodeRule,codeRuleVO.getOid())
+ .eq(CodeBasicSec::getSerialDependFlag,"true")
+ .orderByAsc(CodeBasicSec::getOrderNum);
+ //.orderByAsc(CodeBasicSec::getSerialDependOrder);
+ List<CodeBasicSec> codeBasicSecList = this.list(wrapper);
+ if(!CollectionUtils.isEmpty(codeBasicSecList)){
+ List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecDO2VOs(codeBasicSecList);
+ //鏌ヨ鍥哄畾鐮佺殑鐮佸��
+ Map<String, List<CodeFixedValueVO>> secValueMap = fixedValueService.listCodeFixedValueBySecOids(codeBasicSecList.stream().map(CodeBasicSec::getOid).collect(Collectors.toList()));
+ codeBasicSecVOS.stream().forEach(vo->{
+ vo.setFixedValueVOList(secValueMap.getOrDefault(vo.getOid(),null));
+ });
+ codeRuleVO.setSecVOList(codeBasicSecVOS);
+ }
+ }else{
+ throw new VciBaseException(codeRuleVO.getName()+"缂栫爜瑙勫垯涓嬫棤娴佹按鐮佹锛屾棤娉曡缃渶澶ф祦姘村彿锛�");
+ }
+ }
+ return codeRuleVO;
+ }
+
+ /**
+ * 璁剧疆鏈�澶ф祦姘村彿
+ *
+ * @param codeOrderDTO 缂栫爜鐢宠浼犺緭瀵硅薄
+ * @return
+ * @throws VciBaseException
+ */
+ @Override
+ public String setMaxSerialNumberForCodeRule(CodeOrderDTO codeOrderDTO) throws VciBaseException {
+ VciBaseUtil.alertNotNull(codeOrderDTO.getCodeRuleOid(),"缂栫爜瑙勫垯涓婚敭",codeOrderDTO.getMaxSecNum(),"鏈�澶ф祦姘村彿");
+ List<CodeOrderSecDTO> codeOrderSecDTOList = codeOrderDTO.getSecDTOList();
+ if(CollectionUtils.isEmpty(codeOrderSecDTOList)){
+ throw new VciBaseException("鏈�澶ф祦姘村彿鐨勬祦姘翠緷璧栦笉鑳戒负绌猴紒");
+ }
+
+ String codeRuleOid = codeOrderDTO.getCodeRuleOid();
+ int maxSecNum = codeOrderDTO.getMaxSecNum();
+
+ Map<String/**鐮佹涓婚敭*/,CodeOrderSecDTO/**鐮佹鐩稿叧淇℃伅*/> codeOrderSecDTOMap = codeOrderSecDTOList.stream().collect(Collectors.toMap(s -> s.getSecOid(), t -> t));
+ List<String> codeBasicSecOidList = codeOrderSecDTOList.stream().map(s->s.getSecOid()).collect(Collectors.toList());//娴佹按渚濊禆鐮佹鐨勪富閿泦鍚�
+
+ //鑾峰彇娴佹按渚濊禆鐮佹
+ LambdaQueryWrapper<CodeBasicSec> wrapper = Wrappers.<CodeBasicSec>query().lambda()
+ .eq(CodeBasicSec::getPkCodeRule,codeRuleOid)
+ .in(CodeBasicSec::getOid,codeBasicSecOidList)
+ .eq(CodeBasicSec::getSerialDependFlag,"true")
+ .orderByAsc(CodeBasicSec::getSerialDependOrder);
+ List<CodeBasicSec> codeBasicSecList = this.list(wrapper);
+
+ //鎸夋祦姘翠緷璧栭『搴忥紝澶勭悊娴佹按渚濊禆鐮佹鐨勫��
+ List<String> serialDependValueList = new ArrayList<>();
+ codeBasicSecList.stream().forEach(s->{
+ CodeOrderSecDTO codeOrderSecDTO = codeOrderSecDTOMap.get(s.getOid());
+ String serialDependValue = codeOrderSecDTO.getSecValue();
+ if(s.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())){
+ try {
+ Date date = VciDateUtil.str2Date(codeOrderSecDTO.getSecValue(),s.getCodeDateFormatStr());
+ serialDependValue = VciDateUtil.date2Str(date,s.getCodeDateFormatStr());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ serialDependValueList.add(serialDependValue);
+ });
+
+ //鑾峰彇娴佹按鐮佹
+ wrapper = Wrappers.<CodeBasicSec>query().lambda()
+ .eq(CodeBasicSec::getPkCodeRule,codeRuleOid)
+ .eq(CodeBasicSec::getSecType,CodeSecTypeEnum.CODE_SERIAL_SEC.getValue())
+ .orderByAsc(CodeBasicSec::getSerialDependOrder);
+ CodeBasicSec codeBasicSec = this.getOne(wrapper);
+
+ //鏍规嵁缂栫爜瑙勫垯鍜屾祦姘翠緷璧栵紝鑾峰彇鏈�澶ф祦姘村彿
+ String serialUnitString = serialDependValueList.size() == 0 ? EMPTY_SERIAL_UNIT : serialDependValueList.stream().collect(Collectors.joining(SERIAL_UNIT_SPACE));
+ LambdaQueryWrapper<CodeSerialValue> codeSerialWrapper = new LambdaQueryWrapper<>();
+ codeSerialWrapper.eq(CodeSerialValue::getCodeRuleOid, codeRuleOid);
+ codeSerialWrapper.eq(CodeSerialValue::getSerialUnit, serialUnitString);
+ codeSerialWrapper.eq(CodeSerialValue::getCodeSecOid,codeBasicSec.getOid());
+ codeSerialWrapper.orderByDesc(CodeSerialValue::getCreateTime);
+ List<CodeSerialValue> codeSerialValueList = serialValueMapper.selectList(codeSerialWrapper);
+
+ //濡傛灉鏈�澶ф祦姘村彿涓嶄负绌猴紝璇存槑宸叉湁鏈�濂芥祦姘村彿锛屾洿鏂版渶澶ф祦姘村彿
+ if(!CollectionUtils.isEmpty(codeSerialValueList)){
+ CodeSerialValue codeSerialValue = codeSerialValueList.get(0);
+ int maxSerial = Double.valueOf(codeSerialValue.getMaxSerial()).intValue();
+ //宸叉湁鐨勬渶澶ф祦姘村彿锛屽皬浜庤缃殑鏈�澶ф祦姘村彿锛屾洿鏂版渶澶ф祦姘村彿
+ if(maxSerial < maxSecNum){
+ codeSerialValue.setMaxSerial(String.valueOf(maxSecNum));
+ serialValueMapper.updateById(codeSerialValue);
+ }else{
+ maxSecNum = maxSerial;
+ }
+ }else{
+ //濡傛灉鏈�澶ф祦姘村彿涓嶄负绌猴紝璇存槑鏃犳渶濂芥祦姘村彿锛屾柊澧炴渶澶ф祦姘村彿
+ CodeSerialValue codeSerialValue = new CodeSerialValue();
+ DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeSerialValue, MdmBtmTypeConstant.CODE_SERIAL_VALUE);
+ codeSerialValue.setCodeRuleOid(codeRuleOid);
+ codeSerialValue.setSerialUnit(serialUnitString);
+ codeSerialValue.setCodeSecOid(codeBasicSec.getOid());
+ codeSerialValue.setMaxSerial(String.valueOf(maxSecNum));
+ serialValueMapper.insert(codeSerialValue);
+ }
+ return String.valueOf(maxSecNum);
+ }
+
+ /***
+ * 鏍规嵁娴佹按渚濊禆鑾峰彇鏈�澶ф祦姘村彿
+ * @param codeOrderDTO 缂栫爜鐢宠浼犺緭瀵硅薄
+ * @return
+ */
+ @Override
+ public Double getMaxSerialNumberForCodeRule(CodeOrderDTO codeOrderDTO) {
+ Double maxSerialNumber=0.0;
+ VciBaseUtil.alertNotNull(codeOrderDTO.getCodeRuleOid(),"缂栫爜瑙勫垯涓婚敭");
+ List<CodeOrderSecDTO> codeOrderSecDTOList=codeOrderDTO.getSecDTOList();
+ if(CollectionUtils.isEmpty(codeOrderSecDTOList)){
+ throw new VciBaseException("鏈�澶ф祦姘村彿鐨勬祦姘翠緷璧栦笉鑳戒负绌猴紒");
+ }
+ String codeRuleOid = codeOrderDTO.getCodeRuleOid();
+ Map<String/**鐮佹涓婚敭*/,CodeOrderSecDTO/**鐮佹鐩稿叧淇℃伅*/> codeOrderSecDTOMap = codeOrderSecDTOList.stream().collect(Collectors.toMap(s -> s.getSecOid(), t -> t));
+ List<String> codeBasicSecOidList = codeOrderSecDTOList.stream().map(s->s.getSecOid()).collect(Collectors.toList());//娴佹按渚濊禆鐮佹鐨勪富閿泦鍚�
+ //鑾峰彇娴佹按渚濊禆鐮佹
+ LambdaQueryWrapper<CodeBasicSec> wrapper = Wrappers.<CodeBasicSec>query().lambda()
+ .eq(CodeBasicSec::getPkCodeRule,codeRuleOid)
+ .in(CodeBasicSec::getOid,codeBasicSecOidList)
+ .eq(CodeBasicSec::getSerialDependFlag,"true")
+ .orderByAsc(CodeBasicSec::getSerialDependOrder);
+ List<CodeBasicSec> codeBasicSecList = this.list(wrapper);
+ //鎸夋祦姘翠緷璧栭『搴忥紝澶勭悊娴佹按渚濊禆鐮佹鐨勫��
+ List<String> serialDependValueList = new ArrayList<>();
+ codeBasicSecList.stream().forEach(s->{
+ CodeOrderSecDTO codeOrderSecDTO = codeOrderSecDTOMap.get(s.getOid());
+ String serialDependValue = codeOrderSecDTO.getSecValue();
+ if(s.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())){
+ try {
+ Date date = VciDateUtil.str2Date(codeOrderSecDTO.getSecValue(),s.getCodeDateFormatStr());
+ serialDependValue = VciDateUtil.date2Str(date,s.getCodeDateFormatStr());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ serialDependValueList.add(serialDependValue);
+ });
+
+ //鑾峰彇娴佹按鐮佹
+ wrapper = Wrappers.<CodeBasicSec>query().lambda()
+ .eq(CodeBasicSec::getPkCodeRule,codeRuleOid)
+ .eq(CodeBasicSec::getSecType,CodeSecTypeEnum.CODE_SERIAL_SEC.getValue())
+ .orderByAsc(CodeBasicSec::getSerialDependOrder);
+ CodeBasicSec codeBasicSec = this.getOne(wrapper);
+ //鏍规嵁缂栫爜瑙勫垯鍜屾祦姘翠緷璧栵紝鑾峰彇鏈�澶ф祦姘村彿
+ String serialUnitString = serialDependValueList.size() == 0 ? EMPTY_SERIAL_UNIT : serialDependValueList.stream().collect(Collectors.joining(SERIAL_UNIT_SPACE));
+ LambdaQueryWrapper<CodeSerialValue> codeSerialWrapper = new LambdaQueryWrapper<>();
+ codeSerialWrapper.eq(CodeSerialValue::getCodeRuleOid, codeRuleOid);
+ codeSerialWrapper.eq(CodeSerialValue::getSerialUnit, serialUnitString);
+ codeSerialWrapper.eq(CodeSerialValue::getCodeSecOid,codeBasicSec.getOid());
+ codeSerialWrapper.orderByDesc(CodeSerialValue::getCreateTime);
+ List<CodeSerialValue> codeSerialValueList = serialValueMapper.selectList(codeSerialWrapper);
+ if(!CollectionUtils.isEmpty(codeSerialValueList)){
+ maxSerialNumber=StringUtils.isBlank(codeSerialValueList.get(0).getMaxSerial())?0:Double.parseDouble(codeSerialValueList.get(0).getMaxSerial());
+ }
+ return maxSerialNumber;
}
}
--
Gitblit v1.9.3