From 03fc4cfd7abfd125b942417284999a0aea7305d9 Mon Sep 17 00:00:00 2001
From: xiejun <xiejun@vci-tech.com>
Date: 星期三, 15 一月 2025 21:35:07 +0800
Subject: [PATCH] 产品型号集成,类型转换,人员组织加日志,申请接口引用码段值校验

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/algorithm/CustomRomanSerialAlgorithmExample.java |  157 ++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 145 insertions(+), 12 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 abe1dfa..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,34 +1,167 @@
 package com.vci.ubcs.code.algorithm;
 
+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.CodeOrderSecDTO;
-import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO;
-import com.vci.ubcs.starter.revision.model.BaseModel;
+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 java.util.List;
+import javax.management.StringValueExp;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static com.vci.ubcs.code.constant.MdmEngineConstant.*;
 
 /****
  * 鑷畾涔夌綏椹祦姘寸畻娉曡嚜瀹氫箟绫�
  */
-@MdmSerialAlgorithm(text = "鑷畾涔夌綏椹祦姘�",description = "鑷畾涔夌綏椹祦姘寸畻娉�")
+@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(BaseModel data, CodeRuleVO codeRuleVO, List<CodeOrderSecDTO> secDTOList){
+	public String serialGenerate(CodeCustomSerialDTO codeCustomSerialDTO){
+//		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;
+						  }
+						}
+					}
+				}
+			}
 
-		
+		}
 
+		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(5);
-		//灏嗙綏椹祦姘磋浆涓烘暟瀛楁祦姘�
-		int arabicValue=VciBaseUtil.convertRomanToArabic(romanValue);
-		return "";
+		return romanValue;
 	}
 
 }

--
Gitblit v1.9.3