@ -1,6 +1,7 @@
package com.mdp.form.service ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.mdp.core.utils.BaseUtils ;
import com.mdp.form.FormUtil ;
@ -9,6 +10,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory ;
import java.util.* ;
import java.util.stream.Collectors ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
@ -57,12 +59,11 @@ public class FormDataService extends BaseService<FormDataMapper,FormData> {
* @param tagNames
* /
public void updateTagsByDataId ( String dataId , String tagIds , String tagNames ) {
/ / TODO Auto - generated method stub
Map < String , Object > p = new HashMap < > ( ) ;
p . put ( "id" , dataId ) ;
p . put ( "tagIds" , tagIds ) ;
p . put ( "tagNames" , tagNames ) ;
this . update ( "updateTagsById" , p ) ;
UpdateWrapper < FormData > uw = new UpdateWrapper < > ( ) ;
uw . set ( "tag_ids" , tagIds ) ;
uw . set ( "tag_names" , tagNames ) ;
uw . eq ( "id" , dataId ) ;
super . update ( uw ) ;
}
@ -77,7 +78,8 @@ public class FormDataService extends BaseService<FormDataMapper,FormData> {
p . put ( "flowState" , flowState ) ;
p . put ( "formId" , formId ) ;
p . put ( "procInstId" , procInstId ) ;
this . update ( "updateFlowStateByProcInst" , p ) ;
this . baseMapper . updateFlowStateByProcInst ( p ) ;
}
/ * *
* 智能表单直接操作时调用 , 检查流程状态 , 如果是审核通过和审核中 , 不允许更改数据
@ -213,14 +215,18 @@ public class FormDataService extends BaseService<FormDataMapper,FormData> {
}
if ( needInsertList . size ( ) > 0 ) {
this . batchInsert ( needInsertList ) ;
this . saveBatch ( needInsertList . stream ( ) . map ( k - > ( FormData ) k ) . collect ( Collectors . toList ( ) ) ) ;
}
if ( needUpdateList . size ( ) > 0 ) {
if ( updateFlowState ) {
this . batchUpdate ( formDatas ) ;
this . updateBatchById ( formDatas . stream ( ) . map ( k - > ( FormData ) k ) . collect ( Collectors . toList ( ) ) ) ;
} else {
this . update ( "batchUpdateWithoutFlowState" , formDatas ) ;
this . updateBatchById ( formDatas . stream ( ) . map ( k - > {
k . setFlowState ( null ) ;
return ( FormData ) k ;
} ) . collect ( Collectors . toList ( ) ) ) ;
}
}
@ -318,8 +324,9 @@ public class FormDataService extends BaseService<FormDataMapper,FormData> {
}
private int updateSomeFieldsByProcInstId ( Map < String , Object > needUpdateFormDataMap ) {
return this . update ( "updateSomeFieldsByProcInstId" , needUpdateFormDataMap ) ;
UpdateWrapper < FormData > uw = new UpdateWrapper < > ( ) ;
uw . exists ( " SELECT 1 FROM form_data_process_approva a where a.proc_inst_id = {0} AND a.form_data_id = form_data.id" , needUpdateFormDataMap . get ( "procInstId" ) ) ;
return super . update ( BaseUtils . fromMap ( needUpdateFormDataMap , FormData . class ) , uw ) ? 1 : 0 ;
}
/ * *
@ -336,7 +343,7 @@ public class FormDataService extends BaseService<FormDataMapper,FormData> {
if ( StringUtils . isEmpty ( fieldBizKey ) ) {
return tips ;
} else if ( fieldBizKey . length ( ) ! = 3 ) {
tips . setFailure Msg ( "is-biz-key-err-001" , "isBizKey " , "表单字段定义的主键编码错误" ) ;
tips . setErr Msg ( "is-biz-key-err-001" , "表单字段定义的主键编码错误" ) ;
return tips ;
}
boolean hasPrefix = false ;
@ -377,7 +384,14 @@ public class FormDataService extends BaseService<FormDataMapper,FormData> {
public FormData getDbFormDataByBizKey ( String bizKey ) {
return this . selectOne ( "getDbFormDataByBizKey" , bizKey ) ;
QueryWrapper < FormData > qw = new QueryWrapper < > ( ) ;
qw . eq ( "biz_key" , bizKey ) ;
List < FormData > formDatas = super . list ( qw ) ;
if ( formDatas ! = null & & formDatas . size ( ) > 0 ) {
return formDatas . get ( 0 ) ;
} else {
return null ;
}
}
}