Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IRevisionRuleClient.java
@@ -47,6 +47,10 @@ */ String GET_BY_IDS = API_PREFIX + "/revision-rule/get-by-ids"; /** * 英文名称查询 */ String GET_BY_ID = API_PREFIX + "/revision-rule/get-by-id"; /** * 主键批量查询 */ String GET_BY_OIDS = API_PREFIX + "/revision-rule/get-by-oids"; @@ -91,4 +95,13 @@ */ @GetMapping(GET_BY_OIDS) R<List<RevisionRuleVO>> listBtmTypeByOidCollection(Collection<String> pkBtmTypeCollection); /** * 根据id获取版本规则 * @param id * @return */ @GetMapping(GET_BY_ID) R<RevisionRuleVO> selectById(@RequestParam("id") String id); } Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IRevisionRuleFallback.java
@@ -73,4 +73,9 @@ public R<List<RevisionRuleVO>> listBtmTypeByOidCollection(Collection<String> pkBtmTypeCollection) { return R.fail("获取数据失败"); } @Override public R<RevisionRuleVO> selectById(String id) { return R.fail("获取数据失败"); } } Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/revision/model/BaseModel.java
@@ -96,7 +96,7 @@ private Date ts; /** * 所有着 * 所有者 */ private String owner; Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/mapper/CommonsMapper.java
@@ -62,6 +62,8 @@ */ Map<String,Object> getNextRevision(@Param("tableName")String tableName,@Param("nameoid") String nameoid); Map<String,Object> getCurrentRevision(@Param("tableName")String tableName,@Param("nameoid") String nameoid); // Integer updateByTaleAndOid(@Param("tableName")String tableName, @Param("nameoid") String nameoid, @Param("lcStatus") String lcStatus); } Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -135,6 +135,11 @@ */ @Resource IEnumClient enumClient; /** * 版本规则服务 */ @Resource private IRevisionRuleClient revisionRuleClient; /** * 公式的服务 @@ -172,12 +177,7 @@ */ @Autowired private IBtmTypeClient btmTypeClient; /** * 版本规则的服务 */ @Resource private IRevisionRuleClient revisionRuleClient; // /** * 通用查询 */ @@ -433,9 +433,9 @@ checkEnumOnOrder(templateVO, orderDTO); //8.处理时间格式,在数据库里面不论是字符串还是日期格式,都使用相同的格式存储 switchDateAttrOnOrder(templateVO, orderDTO); //9.生成编码的信息 // ClientBusinessObject cbo = boService.createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()); BaseModel cbo = createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmTypeId()); //9.生成编码的信息 ,初始化业务类型:缓存先取消,因为版本规则会出现变动的情况所以无法使用缓存 // BaseModel cbo = createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmTypeId()); BaseModel cbo = createBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId().trim().toLowerCase()); //默认的属性都不用从前端拷贝 //设置编码需要的默认属性的内容 copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, false); @@ -1563,7 +1563,6 @@ conditionMap.put(queryKey, QueryOptionConstant.OR + queryValue); } } /** * 查询编码数据的列表 @@ -2964,7 +2963,7 @@ wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), true); R<List<Map<String, String>>> result = R.data(Collections.singletonList(cbo)); //我们要看是否不是升版的,升版的话,需要对比不相等的属性 String copy = cbo.get("copyfromversion"); /* String copy = cbo.get("copyfromversion"); // if (StringUtils.isBlank(copy)) { // copy = cbo.getAttributeValue("copyfromversion"); // } @@ -2983,11 +2982,12 @@ Map<String, String> difFieldMap = new HashMap<>(); Map<String, String> finalOldData = oldData; cbo.forEach((key, value) -> { String oldValue = finalOldData.getOrDefault(key, ""); if (value == null) { // 这儿oldmap中的全是大写,而cbo中的全是小写所以会拿不到只,这儿直接处理成小写拿不到就用大写拿 String oldValue = String.valueOf(finalOldData.getOrDefault(key.toUpperCase(Locale.ROOT), finalOldData.getOrDefault(key, ""))); if (value == null || value == "null") { value = ""; } if (oldValue == null) { if (oldValue == null || oldValue == "null") { oldValue = ""; } if (!value.equalsIgnoreCase(oldValue)) { @@ -2998,7 +2998,7 @@ difFieldList.add(difFieldMap); result.setData(difFieldList); } } }*/ return result; } @@ -4102,6 +4102,7 @@ toBo.setNameOid(fromBo.getNameOid()); toBo.setBtmname(fromBo.getBtmname()); toBo.setLastR(String.valueOf(1)); // 升版将FirstR修改为0 toBo.setFirstR(String.valueOf(0)); toBo.setFirstV(String.valueOf(1)); toBo.setLastV(String.valueOf(1)); @@ -4112,13 +4113,28 @@ toBo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount())); toBo.setLastModifyTime(new Date()); toBo.setRevisionRule(fromBo.getRevisionRule()); toBo.setVersionRule(fromBo.getVersionRule());R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(fromBo.getBtmname())); toBo.setVersionRule(fromBo.getVersionRule()); //查询业务类型信息,可以获取到版本规则信息(revisionRuleId) R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(fromBo.getBtmname())); if (!listR.isSuccess() || listR.getData().size() == 0) { throw new VciBaseException("传入业务类型未查询到相应表单,请检查!"); } Map<String, Object> nextRevision = commonsMapper.getNextRevision(listR.getData().get(0).getTableName(), fromBo.getNameOid()); toBo.setRevisionSeq(Integer.parseInt(nextRevision.get("REVISIONSEQ").toString())); toBo.setRevisionValue(nextRevision.get("REVISIONVAL").toString()); //Map<String, Object> nextRevision = commonsMapper.getNextRevision(listR.getData().get(0).getTableName(), fromBo.getNameOid()); /* TODO:这是一个待后期完善的功能,目前实现方式是,先查询出当前数据的大版本规则, 然后再查询业务表使用的规则的步长是多少然后计算出该升版为多少 */ Map<String, Object> nextRevision = commonsMapper.getCurrentRevision(listR.getData().get(0).getTableName(), fromBo.getNameOid()); R<RevisionRuleVO> revisionRuleVOR = revisionRuleClient.selectById(listR.getData().get(0).getRevisionRuleId()); String revisionval = nextRevision.get("REVISIONVAL").toString(); // 未查询到版本规则,默认直接给大版本加一 if(!revisionRuleVOR.isSuccess() || Func.isEmpty(revisionRuleVOR.getData())){ revisionval = String.valueOf((Integer.parseInt(revisionval)+1)); }else { revisionval = String.valueOf(Integer.parseInt(revisionval)+revisionRuleVOR.getData().getSerialStep()); } toBo.setRevisionValue(revisionval); toBo.setRevisionSeq(Integer.parseInt(nextRevision.get("REVISIONSEQ").toString())); toBo.setVersionSeq(Integer.valueOf(nextRevision.get("VERSIONSEQ").toString())); toBo.setVersionValue(nextRevision.get("VERSIONVAL").toString()); toBo.setLctid(fromBo.getLctid()); Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CommonsMapper.xml
@@ -82,4 +82,13 @@ where nameoid = #{nameoid} </select> <select id="getCurrentRevision" resultType="map" > select max(revisionSeq) revisionSeq, max(RevisionValue) revisionVal, max(VersionSeq) VersionSeq, max(VersionValue) VersionVal from ${tableName} where nameoid = #{nameoid} </select> </mapper> Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/RevisionRuleClient.java
@@ -15,10 +15,7 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.BeanUtil; import org.springframework.cglib.beans.BeanMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import java.util.*; @@ -106,4 +103,15 @@ public R<List<RevisionRuleVO>> listBtmTypeByOidCollection(Collection<String> oidCollection) { return R.data(service.listRevisionRuleByOidCollection(oidCollection)); } /** * 根据id获取版本规则 * @param id * @return */ @Override public R<RevisionRuleVO> selectById(@RequestParam("id") String id) { return R.data(service.getReversionRuleById(id)); } } Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/IRevisionRuleService.java
@@ -195,4 +195,12 @@ * @return 执行结果 */ List<BtmTypeVO> getApplyRange(String id); /** * 根据id获取版本规则 * @param id * @return */ RevisionRuleVO getReversionRuleById(String id); } Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/RevisionRuleServiceImpl.java
@@ -1,6 +1,7 @@ package com.vci.ubcs.omd.service.impl; import com.alibaba.cloud.commons.lang.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -34,6 +35,7 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.sql.Wrapper; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -510,7 +512,6 @@ return ""; } /** * 替换前缀和后缀 * @param ruleValue 当前版本的值 @@ -537,7 +538,8 @@ /** * 分页查询 * * @param baseQueryObject 查询对象 * @param condition 查询对象 * @param query 分页对象 * @return 查询结果 * @throws VciBaseException 查询出错时抛出异常 */ @@ -557,4 +559,19 @@ VciBaseUtil.alertNotNull(id,"版本规则英文名称"); return BtmTypeWrapper.build().listEntityVO(btmTypeMapper.selectList(Wrappers.<BtmType>query().lambda().eq(BtmType::getRevisionRuleId,id))); } /** * 根据id获取版本规则 * @param id * @return */ @Override public RevisionRuleVO getReversionRuleById(String id) { LambdaQueryWrapper<RevisionRule> wrapper = Wrappers.<RevisionRule>query() .lambda().eq(RevisionRule::getId, id) .last("limit 1"); RevisionRule revisionRule = baseMapper.selectOne(wrapper); return RevisionRuleWrapper.build().entityVO(revisionRule); } }