|
@@ -1,6 +1,5 @@
|
|
|
package com.qmth.sop.business.service.impl;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
|
|
|
import com.qmth.sop.business.bean.result.FlowTaskResult;
|
|
@@ -8,10 +7,10 @@ import com.qmth.sop.business.entity.TBSopInfo;
|
|
|
import com.qmth.sop.business.entity.TFCustomFlow;
|
|
|
import com.qmth.sop.business.mapper.TBSopInfoMapper;
|
|
|
import com.qmth.sop.business.service.TBSopInfoService;
|
|
|
-import com.qmth.sop.business.service.TFCustomFlowService;
|
|
|
-import com.qmth.sop.common.enums.ExceptionResultEnum;
|
|
|
-import com.qmth.sop.common.enums.TFCustomTypeEnum;
|
|
|
+import com.qmth.sop.common.enums.WidgetCodeEnum;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
@@ -28,7 +27,7 @@ import java.util.*;
|
|
|
public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo> implements TBSopInfoService {
|
|
|
|
|
|
@Resource
|
|
|
- TFCustomFlowService tfCustomFlowService;
|
|
|
+ TBSopInfoMapper tbSopInfoMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询动态sop表名是否存在
|
|
@@ -45,26 +44,36 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
/**
|
|
|
* 保存动态sop信息
|
|
|
*
|
|
|
- * @param type
|
|
|
+ * @param tfCustomFlow
|
|
|
* @param flowId
|
|
|
* @param flowTaskResult
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public Boolean saveDynamicSop(TFCustomTypeEnum type, Long flowId, FlowTaskResult flowTaskResult) {
|
|
|
- TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getType, type));
|
|
|
- Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
|
|
|
-
|
|
|
- String tableName = type.getTableName() + "_" + tfCustomFlow.getVersion();
|
|
|
+ @Transactional
|
|
|
+ public Boolean saveDynamicSop(TFCustomFlow tfCustomFlow, Long flowId, FlowTaskResult flowTaskResult) {
|
|
|
+ String tableName = tfCustomFlow.getType().getTableName() + "_" + tfCustomFlow.getVersion();
|
|
|
List<FlowFormWidgetResult> flowFormWidgetResultList = flowTaskResult.getFormProperty();
|
|
|
List<Map<String, String>> fieldValue = new ArrayList<>(flowFormWidgetResultList.size());
|
|
|
+ StringJoiner stringJoiner = new StringJoiner(",");
|
|
|
for (FlowFormWidgetResult f : flowFormWidgetResultList) {
|
|
|
- Map<String, String> map = new LinkedHashMap<>();
|
|
|
- map.put(f.getFormId(), f.getValue());
|
|
|
- fieldValue.add(map);
|
|
|
+ if (f.getCode() != WidgetCodeEnum.FORM_GROUP_TITLE && f.getCode() != WidgetCodeEnum.ONLE_TITLE
|
|
|
+ && f.getCode() != WidgetCodeEnum.BUTTON && f.getCode() != WidgetCodeEnum.IMG
|
|
|
+ && f.getCode() != WidgetCodeEnum.LABEL && f.getCode() != WidgetCodeEnum.SIGN
|
|
|
+ && f.getCode() != WidgetCodeEnum.OTHER) {
|
|
|
+ Map<String, String> map = new LinkedHashMap<>();
|
|
|
+ map.put(f.getFormId(), f.getValue());
|
|
|
+ fieldValue.add(map);
|
|
|
+ stringJoiner.add(f.getFormId());
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
//首先查询动态表里是否有当前表单的数据,没有插入,有则更新
|
|
|
+ List<Map> list = this.selectDynamicSop(tableName, tfCustomFlow.getFlowDeploymentId(), flowId, stringJoiner.toString());
|
|
|
+ if (CollectionUtils.isEmpty(list)) {//插入操作
|
|
|
+// tbSopInfoMapper.saveDynamicSop();
|
|
|
+ } else {//否则更新
|
|
|
+// tbSopInfoMapper.updateDynamicSop();
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -78,7 +87,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public int selectDynamicSop(String tableName, String flowDeploymentId, Long flowId, String fieldName) {
|
|
|
- return 0;
|
|
|
+ public List<Map> selectDynamicSop(String tableName, String flowDeploymentId, Long flowId, String fieldName) {
|
|
|
+ return this.baseMapper.selectDynamicSop(tableName, flowDeploymentId, flowId, fieldName);
|
|
|
}
|
|
|
}
|