2022-11-03 11:19:48 +08:00
package weaver.formmode.organization.modeexpand ;
2022-11-02 13:47:29 +08:00
import com.alibaba.fastjson.JSONObject ;
import com.engine.organization.entity.map.JclOrgMap ;
import com.engine.organization.mapper.jclorgmap.JclOrgMapper ;
import com.engine.organization.util.OrganizationDateUtil ;
import com.engine.organization.util.db.MapperProxyFactory ;
import weaver.conn.RecordSet ;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew ;
import java.sql.Date ;
import java.util.HashMap ;
import java.util.Map ;
2022-11-03 11:19:48 +08:00
2022-11-02 13:47:29 +08:00
import weaver.general.Util ;
import weaver.hrm.User ;
import weaver.soa.workflow.request.RequestInfo ;
2022-11-02 20:18:55 +08:00
/ * *
* 虚拟组织新增修改到map表接口
* /
public class VOModeExpand extends AbstractModeExpandJavaCodeNew {
2022-11-02 13:47:29 +08:00
public Map < String , String > doModeExpand ( Map < String , Object > param ) {
Map < String , String > result = new HashMap < String , String > ( ) ;
try {
2022-11-03 11:19:48 +08:00
User user = ( User ) param . get ( " user " ) ;
2022-11-02 13:47:29 +08:00
int billid = - 1 ; //数据id
int modeid = - 1 ; //模块id
2022-11-03 11:19:48 +08:00
RequestInfo requestInfo = ( RequestInfo ) param . get ( " RequestInfo " ) ;
if ( requestInfo ! = null ) {
2022-11-02 13:47:29 +08:00
billid = Util . getIntValue ( requestInfo . getRequestid ( ) ) ;
modeid = Util . getIntValue ( requestInfo . getWorkflowid ( ) ) ;
2022-11-03 11:19:48 +08:00
if ( billid > 0 & & modeid > 0 ) {
2022-11-02 13:47:29 +08:00
//JSON转换,获取虚拟组织表的fid
String JSONStr = ( String ) param . get ( " JSONStr " ) ;
JSONObject jsonObject = ( JSONObject ) JSONObject . parse ( JSONStr ) ;
2022-11-02 20:18:55 +08:00
String fid = jsonObject . getString ( queryField ( " fid " ) ) ;
2022-11-03 11:19:48 +08:00
String iscreate = ( String ) param . get ( " iscreate " ) ;
2022-11-02 13:47:29 +08:00
//查询虚拟组织表中的新增记录
RecordSet recordSet = new RecordSet ( ) ;
2022-11-02 20:18:55 +08:00
recordSet . executeQuery ( " select id, fid, fecid, fname, ftype, forder, fparentid, fdate from uf_jcl_org_vir where fid = ' " + fid + " ' " ) ;
JclOrgMap jclOrgMap = new JclOrgMap ( ) ;
2022-11-03 11:19:48 +08:00
if ( recordSet . next ( ) ) {
2022-11-02 13:47:29 +08:00
Integer ftype = Integer . valueOf ( recordSet . getString ( " ftype " ) ) ;
jclOrgMap . setFType ( ftype ) ;
jclOrgMap . setFIsVitual ( 1 ) ; //虚拟组织标记
2022-11-02 20:18:55 +08:00
jclOrgMap . setFClass ( 0 ) ; //-1,行政维度
jclOrgMap . setFClassName ( " 行政维度 " ) ;
2022-11-02 13:47:29 +08:00
jclOrgMap . setFDateBegin ( new Date ( OrganizationDateUtil . stringToDate ( recordSet . getString ( " fdate " ) ) . getTime ( ) ) ) ;
jclOrgMap . setFDateEnd ( new Date ( OrganizationDateUtil . stringToDate ( " 2099-12-31 " ) . getTime ( ) ) ) ;
jclOrgMap . setFNumber ( String . valueOf ( modeid ) ) ; //模块的数据编号
jclOrgMap . setId ( Integer . valueOf ( recordSet . getString ( " id " ) ) ) ;
jclOrgMap . setFName ( recordSet . getString ( " fname " ) ) ;
2022-11-03 11:19:48 +08:00
if ( ! " " . equals ( recordSet . getString ( " fparentid " ) ) ) {
jclOrgMap . setFParentId ( Integer . valueOf ( recordSet . getString ( " fparentid " ) ) ) ;
}
2022-11-02 13:47:29 +08:00
if ( " 1 " . equals ( recordSet . getString ( " ftype " ) ) ) {
jclOrgMap . setFParentId ( 0 ) ;
2022-11-03 11:19:48 +08:00
} else if ( " 4 " . equals ( recordSet . getString ( " ftype " ) ) ) {
2022-11-02 20:18:55 +08:00
RecordSet rsHrm = new RecordSet ( ) ;
rsHrm . executeQuery ( " select lastname from HrmResource where id= " + recordSet . getString ( " fecid " ) ) ;
2022-11-03 11:19:48 +08:00
if ( rsHrm . next ( ) ) {
2022-11-02 20:18:55 +08:00
jclOrgMap . setFName ( rsHrm . getString ( " lastname " ) ) ;
}
2022-11-02 13:47:29 +08:00
}
}
2022-11-03 11:19:48 +08:00
if ( iscreate . equals ( " 2 " ) ) {
2022-11-02 20:18:55 +08:00
RecordSet rs = new RecordSet ( ) ;
2022-11-03 11:19:48 +08:00
String delsql = " delete JCL_ORG_MAP where id= " + jclOrgMap . getId ( ) + " and ftype=' " + jclOrgMap . getFType ( ) + " ' and fisvitual='1' and fdatebegin=' " + jclOrgMap . getFDateBegin ( ) + " ' " ;
2022-11-02 20:18:55 +08:00
rs . execute ( delsql ) ;
2022-11-03 11:19:48 +08:00
String updatesql = " update JCL_ORG_MAP set fdateend=' " + jclOrgMap . getFDateBegin ( ) + " ' where id= " + jclOrgMap . getId ( ) + " and ftype=' " + jclOrgMap . getFType ( ) + " ' and fisvitual='1' and fdateend > ' " + jclOrgMap . getFDateBegin ( ) + " ' " ;
2022-11-02 20:18:55 +08:00
rs . execute ( updatesql ) ;
}
MapperProxyFactory . getProxy ( JclOrgMapper . class ) . insertMap ( jclOrgMap ) ;
2022-11-02 13:47:29 +08:00
}
}
} catch ( Exception e ) {
2022-11-03 11:19:48 +08:00
result . put ( " errmsg " , " 自定义出错信息 " ) ;
2022-11-02 13:47:29 +08:00
result . put ( " flag " , " false " ) ;
}
return result ;
}
2022-11-02 20:18:55 +08:00
/ * *
* 查询表单对应字段
* /
private String queryField ( String fieldName ) {
RecordSet rs = new RecordSet ( ) ;
rs . executeQuery ( " select b.id from workflow_bill a \ n " +
" INNER JOIN workflow_billfield b on a.id=b.billid \ n " +
" where a.tablename='uf_jcl_org_vir' and b.fieldname=' " + fieldName + " ' " ) ;
String field = " field " ;
if ( rs . next ( ) ) {
field + = rs . getString ( " id " ) ;
}
return field ;
}
2022-11-02 13:47:29 +08:00
}