wangliang 1 year ago
parent
commit
5d848e1ac7

+ 1 - 2
sop-api/src/main/java/com/qmth/sop/server/api/TBSopInfoController.java

@@ -28,7 +28,6 @@ import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 
 /**
  * <p>
@@ -57,7 +56,7 @@ public class TBSopInfoController {
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = FormWidgetMetadataResult.class)})
     public Result metadataList(@ApiParam(value = "sop流程类型", required = true) @RequestParam TFCustomTypeEnum type,
                                @ApiParam(value = "sop流程版本") @RequestParam(required = false) Integer version) {
-        return ResultUtil.ok(tdFormWidgetMetadataService.selectAll(type, Objects.isNull(version) ? 1 : version));
+        return ResultUtil.ok(tdFormWidgetMetadataService.selectAll(type, version));
     }
 
     @ApiOperation(value = "sop元数据修改")

+ 8 - 0
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -38,6 +38,7 @@ import org.activiti.engine.task.Task;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -234,6 +235,13 @@ public class ActivitiServiceImpl implements ActivitiService {
             Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
             Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.FLOW_PROCESS_VAR_NO_DATA.exception());
 
+            TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, null, tfCustomFlow.getType());
+            if (maxTfCustomFlow.getVersion().intValue() != tfCustomFlow.getVersion().intValue()) {//说明版本发生变化
+                BeanUtils.copyProperties(maxTfCustomFlow, tfCustomFlow);
+            }
+            Optional.ofNullable(maxTfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+            Optional.ofNullable(maxTfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.FLOW_PROCESS_VAR_NO_DATA.exception());
+
             map.put(SystemConstant.DEFAULT_ASSIGNEE_LIST + 1, approveUserIds);
             ProcessInstance processInstance = runtimeService.startProcessInstanceById(tfCustomFlow.getFlowDefinitionId(), map);
             processFlowId = processInstance.getId();

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/bean/params/SopInfoListParam.java

@@ -30,7 +30,7 @@ public class SopInfoListParam extends TBSopInfo implements Serializable {
     private String typeStr;
 
     @ApiModelProperty(value = "版本号")
-    private Integer version = 1;
+    private Integer version;
 
     @ApiModelProperty(value = "元数据显示字段数组")
     private List<FormWidgetMetadataParam> formWidgetMetadataViewList;

+ 10 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -352,8 +352,11 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         if (sopInfoListParam.getType() != TFCustomTypeEnum.OFFICE_SOP_FLOW && sopInfoListParam.getType() != TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
             throw ExceptionResultEnum.ERROR.exception("流程类型只能为教务处或研究生");
         }
-        TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, null, sopInfoListParam.getType());
-        String tableName = sopInfoListParam.getType().getTableName() + "_" + maxTfCustomFlow.getVersion();
+        if (Objects.isNull(sopInfoListParam.getVersion())) {
+            TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, null, sopInfoListParam.getType());
+            sopInfoListParam.setVersion(maxTfCustomFlow.getVersion());
+        }
+        String tableName = sopInfoListParam.getType().getTableName() + "_" + sopInfoListParam.getVersion();
         String fieldName = null, fieldValue = null, fieldOrder = null;
         StringJoiner stringJoinerView = new StringJoiner(",");
         StringJoiner stringJoinerCondition = new StringJoiner("");
@@ -721,6 +724,11 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
 
             tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
             Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+            TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, null, tfCustomFlow.getType());
+            Optional.ofNullable(maxTfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+            if (maxTfCustomFlow.getVersion().intValue() != tfCustomFlow.getVersion().intValue()) {//说明版本发生变化
+                BeanUtils.copyProperties(maxTfCustomFlow, tfCustomFlow);
+            }
 
             if (tfCustomFlow.getType() != TFCustomTypeEnum.OFFICE_SOP_FLOW && tfCustomFlow.getType() != TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
                 throw ExceptionResultEnum.ERROR.exception("sop流程类型错误");

+ 5 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TDFormWidgetMetadataServiceImpl.java

@@ -85,8 +85,11 @@ public class TDFormWidgetMetadataServiceImpl extends ServiceImpl<TDFormWidgetMet
         if (type != TFCustomTypeEnum.OFFICE_SOP_FLOW && type != TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
             throw ExceptionResultEnum.ERROR.exception("流程类型只能为教务处或研究生");
         }
-        TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, null, type);
-        return this.baseMapper.getFormWidgetMetadataResult(type.name(), maxTfCustomFlow.getVersion());
+        if (Objects.isNull(version)) {
+            TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, null, type);
+            version = maxTfCustomFlow.getVersion();
+        }
+        return this.baseMapper.getFormWidgetMetadataResult(type.name(), version);
     }
 
     /**

+ 7 - 22
sop-business/src/main/resources/mapper/TFCustomFlowMapper.xml

@@ -3,36 +3,21 @@
 <mapper namespace="com.qmth.sop.business.mapper.TFCustomFlowMapper">
 
     <select id="findMaxVersion" resultType="com.qmth.sop.business.entity.TFCustomFlow">
-        select * from t_f_custom_flow tfcf
+        select * from t_f_custom_flow t
         <where>
-            1 = 1 and tfcf.version =
-            (select max(t.version) from t_f_custom_flow t
-            <where>
-                <if test="orgId != null and orgId != ''">
-                    and t.org_id = #{orgId}
-                </if>
-                <if test="flowName != null and flowName != ''">
-                    and t.name = #{flowName}
-                </if>
-                <if test="type != null and type != ''">
-                    and t.type = #{type}
-                </if>
-                and t.enable = 1
-                and t.publish = 1
-            </where>
-            )
             <if test="orgId != null and orgId != ''">
-                and tfcf.org_id = #{orgId}
+                and t.org_id = #{orgId}
             </if>
             <if test="flowName != null and flowName != ''">
-                and tfcf.name = #{flowName}
+                and t.name = #{flowName}
             </if>
             <if test="type != null and type != ''">
-                and tfcf.type = #{type}
+                and t.type = #{type}
             </if>
-            and tfcf.enable = 1
-            and tfcf.publish = 1
+            and t.enable = 1
+            and t.publish = 1
         </where>
+        order by t.version desc limit 1
     </select>
 
     <select id="findFlowDeploymentList" resultType="com.qmth.sop.business.entity.TFCustomFlow">