From 04b4676f4f8f2674a0fdd52624c417d600f6f06b Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期二, 05 十二月 2023 16:19:30 +0800
Subject: [PATCH] 整合代码
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/algorithm/CustomRomanSerialAlgorithmExample.java | 159 ++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 140 insertions(+), 19 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/algorithm/CustomRomanSerialAlgorithmExample.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/algorithm/CustomRomanSerialAlgorithmExample.java
index 96da8d6..ab65d16 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/algorithm/CustomRomanSerialAlgorithmExample.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/algorithm/CustomRomanSerialAlgorithmExample.java
@@ -1,45 +1,166 @@
package com.vci.ubcs.code.algorithm;
-import com.alibaba.nacos.common.utils.StringUtils;
+import com.alibaba.nacos.common.utils.CollectionUtils;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.vci.ubcs.code.annotation.MdmSerialAlgorithm;
import com.vci.ubcs.code.annotation.MdmSerialAlgorithmMethod;
import com.vci.ubcs.code.dto.CodeCustomSerialDTO;
+import com.vci.ubcs.code.entity.CodeAllCode;
+import com.vci.ubcs.code.enumpack.CodeBZOperationTypeEnum;
+import com.vci.ubcs.code.service.ICodeAllCodeService;
import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO;
import com.vci.ubcs.starter.exception.VciBaseException;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
+import io.reactivex.internal.util.LinkedArrayList;
+import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.management.StringValueExp;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static com.vci.ubcs.code.constant.MdmEngineConstant.*;
/****
* 鑷畾涔夌綏椹祦姘寸畻娉曡嚜瀹氫箟绫�
*/
@MdmSerialAlgorithm(text = "鑷畾涔夌綏椹祦姘�",serialType="custom_serial_roman",description = "鑷畾涔夌綏椹祦姘寸畻娉�")
+@Component
public class CustomRomanSerialAlgorithmExample {
+ /**
+ * 缂栫爜瑙勫垯鐨勬湇鍔�
+ */
+ @Autowired
+ private ICodeAllCodeService codeAllCodeService;
+ /***
+ * 鎿嶄綔绫诲瀷
+ */
+ @Value("${bzApply.operationType:operationType}")
+ private String operationType;
+ /***
+ * 鏄惁绯诲垪
+ */
+ @Value("${bzApply.isSeries:isSeries}")
+ private String isSeries;
+
+ /***
+ * 鏄惁鍙樻洿绯诲垪
+ */
+ @Value("${bzApply.isEditSeries:isEditSeries}")
+ private String isEditSeries;
+ /***
+ * 婧愭爣鍑嗗彿
+ */
+ @Value("${bzApply.oldCode:oldCode}")
+ private String oldCode;
+ /***
+ *鍙戝竷鏃堕棿
+ */
+ @Value("${bzApply.releaseTime:releaseTime}")
+ private String releaseTime;
+ /***
+ * 鎺у埗鏄惁鍐欏叆鍊肩殑鐮佹鍚嶇О
+ */
+ @Value("${bzApply.yearSecName:骞翠唬鍙穧")
+ private String yearSecName;
/**
* 鐢熸垚缃楅┈娴佹按鍙风殑鏂规硶
* @return 娴佹按鍙风殑淇℃伅
*/
@MdmSerialAlgorithmMethod
public String serialGenerate(CodeCustomSerialDTO codeCustomSerialDTO){
- //
- codeCustomSerialDTO.getSerialUnitString();
- CodeBasicSecVO secVO= codeCustomSerialDTO.getSerialCodeCodeBasicSec();
- String currentFlowValue=codeCustomSerialDTO.getCurrentFlowValue();
+// boolean isSeriesValue=false;
+ boolean isCrete=false;//鏄惁鎴愪骇缃楅┈椤哄簭鍙�
+ String romanValue="";
+ List<CodeBasicSecVO> codeBasicSecVOList= codeCustomSerialDTO.getCodeBasicSecVOList();
+ int yearSecValue=0;//骞翠唬鍙�
+ List<String> secValueList=codeCustomSerialDTO.getSecValueList();
+ String serialUnitString=codeCustomSerialDTO.getSerialUnitString();
+ //婧愭爣鍑嗙被鍨�
+ boolean isSeriesValue=codeCustomSerialDTO.getBaseModel().getData().containsKey(isSeries)&&StringUtils.isNotBlank(codeCustomSerialDTO.getBaseModel().getData().get(isSeries))&&codeCustomSerialDTO.getBaseModel().getData().get(isEditSeries).equals("true")?true:false;
+ //鏄惁鍙樻洿绯诲垪
+ boolean isEditSeriesValue=codeCustomSerialDTO.getBaseModel().getData().containsKey(isEditSeries)&&StringUtils.isNotBlank(codeCustomSerialDTO.getBaseModel().getData().get(isEditSeries))&&codeCustomSerialDTO.getBaseModel().getData().get(isEditSeries).equals("true")?true:false;
+ //濡傛灉鏍囦慨璁负鏍囧噯锛屽師鏈夎〃鍑嗙郴鍒楀彿涓嶅彉锛屽垯姣旇緝骞翠唬鍙凤紝濡傛灉骞翠唬鍙疯法骞达紙娆″勾1鏈堝悗鍒欎负璺ㄥ勾锛�
+ String operationTypeValue=codeCustomSerialDTO.getBaseModel().getData().containsKey(operationType)&&StringUtils.isNotBlank(codeCustomSerialDTO.getBaseModel().getData().get(operationType))?codeCustomSerialDTO.getBaseModel().getData().get(operationType):"";
+ //鍙戝竷鏃堕棿
+ String releaseTimeValue=codeCustomSerialDTO.getBaseModel().getData().containsKey(releaseTime)&&StringUtils.isNotBlank(codeCustomSerialDTO.getBaseModel().getData().get(releaseTime))?codeCustomSerialDTO.getBaseModel().getData().get(releaseTime):"";
+ if(operationTypeValue.equals(CodeBZOperationTypeEnum.CODE_BZ_AMENDMENT.getValue())){//濡傛灉鏄慨璁�
+ //婧愭爣鍑嗗彿
+ String oldCodeValue=codeCustomSerialDTO.getBaseModel().getData().containsKey(oldCode)&&StringUtils.isNotBlank(codeCustomSerialDTO.getBaseModel().getData().get(oldCode))?codeCustomSerialDTO.getBaseModel().getData().get(oldCode):"";
+ if(StringUtils.isNotBlank(oldCodeValue)){
+ //杩橀渶瑕佷慨鏀筧llCode鐨勭敓鍛藉懆鏈�
+ QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>();
+ allCodeWrapper.in("id", VciBaseUtil.str2List(oldCodeValue));
+ List<CodeAllCode>codeAllcodeList=codeAllCodeService.selectByWrapper(allCodeWrapper);
+ if(!CollectionUtils.isEmpty(codeAllcodeList)){
+ String codeDelimit=codeAllcodeList.get(0).getCodeDelimit();
+ String[] secValues= StringUtils.splitByWholeSeparatorPreserveAllTokens(codeDelimit,SERIAL_VALUE_SPACE);
+ int yearIndex=0;
+ if((!isSeriesValue&&!isEditSeriesValue)||(isSeriesValue&&isSeriesValue)){//濡傛灉鏄爣鍑嗕慨璁负鏍囧噯锛屾垨鑰呯郴鍒椾慨璁负绯诲垪鏃跺�欙紝鍒欏垽鏂勾浠e彿
+ for (int i=0;i<codeBasicSecVOList.size();i++){
+ CodeBasicSecVO codeBasicSecVO=codeBasicSecVOList.get(i);
+ if(codeBasicSecVO.getName().equals(yearSecName)){
+ yearSecValue=Integer.parseInt((secValues[i]));
+ yearIndex=i;
+ }
+ }
+ //鍒欒幏鍙栧勾浠e彿姣旇緝锛屽鏋滃勾浠e彿璺ㄥ勾鍒欓渶瑕佷笉闇�瑕佸鍔犵綏椹祦姘达紝鐩存帴鏀瑰勾浠e彿锛屽鏋滀笉璺ㄥ勾鍒欏鍔犳祦姘�
+ if(StringUtils.isNotBlank(releaseTimeValue)){//鍙戝竷鏃堕棿
+ String[] yearMoths= StringUtils.splitByWholeSeparatorPreserveAllTokens(releaseTimeValue,"-");
+ String[] serialUnitStrings=StringUtils.splitByWholeSeparatorPreserveAllTokens(serialUnitString,SERIAL_UNIT_SPACE);
+ List<String>serialUnitStringList=new ArrayList<>();
+ serialUnitStringList= Arrays.asList(serialUnitStrings);
+ int newYear=0;
+ int month=0;
+ if(yearMoths.length>2){
+ String year=yearMoths[0];
+ if(year.length()>String.valueOf(yearSecValue).length()){//鏈夋椂鍊欏彂甯冩椂闂寸殑骞撮暱搴﹀ぇ浜庣爜娈电殑闀垮害锛屽垯闇�瑕佹埅鍙栧悗2浣�
+ newYear= Integer.parseInt(year.substring(2));
+ }else {
+ newYear=Integer.parseInt(year);
+ }
+ month=Integer.parseInt(yearMoths[1]);
+ }
+ if(newYear>yearSecValue&&month>1){
+ secValueList.set(yearIndex,String.valueOf(newYear));
+ serialUnitStringList.set(yearIndex, String.valueOf(newYear));
+ codeCustomSerialDTO.setSecValueList(secValueList);
+ String newSerialUnitString = serialUnitStringList.size() == 0 ? EMPTY_SERIAL_UNIT : serialUnitStringList.stream().collect(Collectors.joining(SERIAL_UNIT_SPACE));
+ codeCustomSerialDTO.setSerialUnitString(newSerialUnitString);
+ }else{
+ isCrete=true;
+ }
+ }
+ }
+ }
+ }
- Double newThisSerialValue = 0d;
- if(StringUtils.isBlank(currentFlowValue)){
- //绗竴涓紪鐮�
- newThisSerialValue = VciBaseUtil.getDouble(secVO.getSerialStart());
- }else {
- //娴佹按鍙疯偗瀹氭槸鏁板瓧
- //灏嗙綏椹祦姘磋浆涓烘暟瀛楁祦姘�
- int arabicValue=VciBaseUtil.convertRomanToArabic(currentFlowValue);
- newThisSerialValue = (double)(arabicValue + secVO.getSerialStep()) ;
}
- //瑕佺湅鏄惁瓒呰繃鏈�澶х殑娴佹按鍊�
- if (newThisSerialValue >= secVO.getCodeFillLimit()) {
- throw new VciBaseException("娴佹按鍙峰凡缁忚秴杩囧厑璁哥殑鏈�澶ф祦姘村�納0}", new String[]{secVO.getCodeFillLimit().toString()});
+
+ if(isCrete){
+ CodeBasicSecVO secVO= codeCustomSerialDTO.getSerialCodeCodeBasicSec();
+ String currentFlowValue=codeCustomSerialDTO.getCurrentFlowValue();
+ Double newThisSerialValue = 0d;
+ if(StringUtils.isBlank(currentFlowValue)){
+ //绗竴涓紪鐮�
+ newThisSerialValue = VciBaseUtil.getDouble(secVO.getSerialStart());
+ }else {
+ //娴佹按鍙疯偗瀹氭槸鏁板瓧
+ //灏嗙綏椹祦姘磋浆涓烘暟瀛楁祦姘�
+ int arabicValue=VciBaseUtil.convertRomanToArabic(currentFlowValue);
+ newThisSerialValue = (double)(arabicValue + secVO.getSerialStep()) ;
+ }
+ //瑕佺湅鏄惁瓒呰繃鏈�澶х殑娴佹按鍊�
+ if (newThisSerialValue >= secVO.getCodeFillLimit()) {
+ throw new VciBaseException("娴佹按鍙峰凡缁忚秴杩囧厑璁哥殑鏈�澶ф祦姘村�納0}", new String[]{secVO.getCodeFillLimit().toString()});
+ }
+ //灏嗘暟瀛楁祦姘磋浆涓虹綏椹祦姘�
+ romanValue=VciBaseUtil.convertArabicToRoman(newThisSerialValue.intValue());
}
- //灏嗘暟瀛楁祦姘磋浆涓虹綏椹祦姘�
- String romanValue=VciBaseUtil.convertArabicToRoman(newThisSerialValue.intValue());
+
return romanValue;
}
--
Gitblit v1.9.3