package weaver.formmode.customjavacode.modeexpand; 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; import weaver.general.Util; import weaver.hrm.User; import weaver.soa.workflow.request.RequestInfo; public class VirOrgServiceImpl extends AbstractModeExpandJavaCodeNew { public Map doModeExpand(Map param) { Map result = new HashMap(); try { User user = (User)param.get("user"); int billid = -1;//数据id int modeid = -1;//模块id RequestInfo requestInfo = (RequestInfo)param.get("RequestInfo"); if(requestInfo!=null){ billid = Util.getIntValue(requestInfo.getRequestid()); modeid = Util.getIntValue(requestInfo.getWorkflowid()); if(billid>0&&modeid>0){ //------请在下面编写业务逻辑代码------ // 获取字段field 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='fid'"); String field = "field"; if (rs.next()) { field += rs.getString("id"); } //JSON转换,获取虚拟组织表的fid String JSONStr = (String) param.get("JSONStr"); JSONObject jsonObject = (JSONObject) JSONObject.parse(JSONStr); String fid = jsonObject.getString(field); JclOrgMap jclOrgMap = new JclOrgMap(); //查询虚拟组织表中的新增记录 RecordSet recordSet = new RecordSet(); recordSet.executeQuery("select id, fid, fname, ftype, forder, fparentid, fdate from uf_jcl_org_vir where fid = '" + fid + "'"); if(recordSet.next()){ Integer ftype = Integer.valueOf(recordSet.getString("ftype")); jclOrgMap.setFType(ftype); jclOrgMap.setFIsVitual(1);//虚拟组织标记 jclOrgMap.setFClass(-1);//-1,虚拟组织 jclOrgMap.setFClassName("虚拟组织"); 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")); if ("1".equals(recordSet.getString("ftype"))) { jclOrgMap.setFParentId(0); }else { jclOrgMap.setFParentId(Integer.valueOf(recordSet.getString("fparentid"))); } MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclOrgMap); } } } } catch (Exception e) { result.put("errmsg","自定义出错信息"); result.put("flag", "false"); } return result; } }