虚拟组织建模表数据写入map
This commit is contained in:
parent
f2c5d1227b
commit
8d78af3e14
|
|
@ -109,41 +109,70 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
|
|||
if (StringUtils.isBlank(level)) {
|
||||
level = "3";
|
||||
}
|
||||
String whereSql = companyDateWhereSql(request2Map);
|
||||
|
||||
String whereItemSql = " ";
|
||||
if ("0".equals(root)) { // 集团的情况
|
||||
whereItemSql += " and ftype = 0 ";
|
||||
} else {
|
||||
whereItemSql += " and id = '" + root + "' ";
|
||||
}
|
||||
|
||||
// 获取根节点
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select id, fname, ftype, fparentid, fnumber, fobjid from jcl_org_map " + whereSql + whereItemSql);
|
||||
// 虚拟组织切换
|
||||
String fisvitual = (String) request2Map.get("fisvitual"); // 是否虚拟组织 0否1是
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
String id = null;
|
||||
if (rs.next()) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
id = rs.getString("id");
|
||||
item.put("id", rs.getString("id"));
|
||||
item.put("fname", rs.getString("fname"));
|
||||
item.put("ftype", rs.getString("ftype"));
|
||||
item.put("fnumber", rs.getString("fnumber"));
|
||||
item.put("fobjid",rs.getString("fobjid"));
|
||||
item.put("parentId", null);
|
||||
item.put("expand", "1");
|
||||
item.put("hasChildren", hasChildren(rs.getString("id"), true));
|
||||
list.add(item);
|
||||
if (StringUtils.isBlank(fisvitual)) {
|
||||
fisvitual = "0";
|
||||
}
|
||||
if(fisvitual.equals("1")){
|
||||
String whereSql = "where fid='0'";
|
||||
// 获取根节点
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select fid, fname, forder, fparentid, ftype from uf_jcl_vo " + whereSql);
|
||||
|
||||
int currentLevel = 1;
|
||||
if (currentLevel + 1 <= Integer.parseInt(level)) {
|
||||
findCompanyItemByParantId(id, currentLevel + 1, level, rs, list, whereSql, true);
|
||||
} else {
|
||||
findCompanyItemByParantId(id, currentLevel + 1, level, rs, list, whereSql, false);
|
||||
String fid = null;
|
||||
if (rs.next()) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
fid = rs.getString("fid");
|
||||
item.put("id", rs.getString("fid"));
|
||||
item.put("fname", rs.getString("fname"));
|
||||
item.put("forder", rs.getString("forder"));
|
||||
item.put("parentId", null);
|
||||
item.put("ftype", rs.getString("ftype"));
|
||||
item.put("expand", "1");
|
||||
item.put("hasChildren", hasVOChildren(rs.getString("fid")));
|
||||
list.add(item);
|
||||
}
|
||||
if (null != fid) {
|
||||
findVoItemByParantId(fid, rs, list, true);
|
||||
}
|
||||
}else {
|
||||
String whereSql = companyDateWhereSql(request2Map);
|
||||
|
||||
String whereItemSql = " ";
|
||||
if ("0".equals(root)) { // 集团的情况
|
||||
whereItemSql += " and ftype = 0 ";
|
||||
} else {
|
||||
whereItemSql += " and id = '" + root + "' ";
|
||||
}
|
||||
|
||||
// 获取根节点
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select id, fname, ftype, fparentid, fnumber, fobjid from jcl_org_map " + whereSql + whereItemSql);
|
||||
// List<Map<String, Object>> list = new ArrayList<>();
|
||||
String id = null;
|
||||
if (rs.next()) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
id = rs.getString("id");
|
||||
item.put("id", rs.getString("id"));
|
||||
item.put("fname", rs.getString("fname"));
|
||||
item.put("ftype", rs.getString("ftype"));
|
||||
item.put("fnumber", rs.getString("fnumber"));
|
||||
item.put("fobjid",rs.getString("fobjid"));
|
||||
item.put("parentId", null);
|
||||
item.put("expand", "1");
|
||||
item.put("hasChildren", hasChildren(rs.getString("id"), true));
|
||||
list.add(item);
|
||||
}
|
||||
|
||||
int currentLevel = 1;
|
||||
if (currentLevel + 1 <= Integer.parseInt(level)) {
|
||||
findCompanyItemByParantId(id, currentLevel + 1, level, rs, list, whereSql, true);
|
||||
} else {
|
||||
findCompanyItemByParantId(id, currentLevel + 1, level, rs, list, whereSql, false);
|
||||
}
|
||||
}
|
||||
|
||||
result.put("api_status", true);
|
||||
result.put("data", list);
|
||||
return result;
|
||||
|
|
@ -178,6 +207,29 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
|
|||
|
||||
}
|
||||
|
||||
private void findVoItemByParantId(String id, RecordSet rs, List<Map<String, Object>> list, boolean expand) {
|
||||
rs.executeQuery("select fid, fname, forder, fparentid, ftype from uf_jcl_vo where fparentid = '" + id + "'");
|
||||
List<Map<String, Object>> currentList = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("id", rs.getString("fid"));
|
||||
item.put("fname", rs.getString("fname"));
|
||||
item.put("forder", rs.getString("forder"));
|
||||
item.put("parentId", rs.getString("fparentid"));
|
||||
item.put("ftype", rs.getString("ftype"));
|
||||
item.put("expand", expand ? "1" : "0");
|
||||
item.put("hasChildren", hasVOChildren(rs.getString("fid")));
|
||||
currentList.add(item);
|
||||
}
|
||||
|
||||
list.addAll(currentList);
|
||||
|
||||
for (Map<String, Object> stringObjectMap : currentList) {
|
||||
findVoItemByParantId((String) stringObjectMap.get("id"), rs, list, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String userWhereSql(Map<String, Object> request2Map) {
|
||||
String date = (String) request2Map.get("date"); // 数据日期
|
||||
if (StringUtils.isBlank(date)) {
|
||||
|
|
@ -217,53 +269,71 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
|
|||
}
|
||||
String root = (String) request2Map.get("root"); // 根节点
|
||||
String level = (String) request2Map.get("level"); // 显示层级
|
||||
String fisvitual = (String) request2Map.get("fisvitual"); // 虚拟组织
|
||||
if (StringUtils.isBlank(level)) {
|
||||
level = "3";
|
||||
}
|
||||
|
||||
String whereSql = userWhereSql(request2Map);
|
||||
|
||||
String whereItemSql = " ";
|
||||
if ("0".equals(root)) { // 集团的情况
|
||||
whereItemSql += " and t.ftype = 0 ";
|
||||
} else {
|
||||
whereItemSql += " and t.id = '" + root + "' ";
|
||||
if (StringUtils.isBlank(fisvitual)) {
|
||||
fisvitual = "0";
|
||||
}
|
||||
|
||||
// 获取根节点
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select t.id, t.fname, t.ftype, t.fparentid, t.fleadername,t.fobjid,t.fecid, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fleader, t.fleaderlv, t.fleaderst,t.fecid from jcl_org_map t " + whereSql + whereItemSql);
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
String id = null;
|
||||
if (rs.next()) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
id = rs.getString("id");
|
||||
item.put("id", rs.getString("id"));
|
||||
item.put("fname", rs.getString("fname"));
|
||||
item.put("ftype", rs.getString("ftype"));
|
||||
item.put("parentId", null);
|
||||
item.put("fleadername", rs.getString("fleadername"));
|
||||
item.put("fleaderimg", rs.getString("fleaderimg"));
|
||||
item.put("fleaderjob", rs.getString("fleaderjob"));
|
||||
item.put("fplan", rs.getString("fplan"));
|
||||
item.put("fonjob", rs.getString("fonjob"));
|
||||
item.put("hasChildren", hasChildren(rs.getString("id"), false));
|
||||
item.put("expand", "1");
|
||||
item.put("fnumber", rs.getString("fnumber"));
|
||||
item.put("fleader", rs.getString("fleader"));
|
||||
item.put("fobjid",rs.getString("fobjid"));
|
||||
item.put("fleaderlv",convertLevel(rs.getString("fleaderlv")));
|
||||
item.put("fleaderst",convertGrade(rs.getString("fleaderst")));
|
||||
item.put("fecid",rs.getString("fecid"));
|
||||
list.add(item);
|
||||
if (fisvitual.equals("0")) {
|
||||
String whereSql = userWhereSql(request2Map);
|
||||
|
||||
String whereItemSql = " ";
|
||||
if ("0".equals(root)) { // 集团的情况
|
||||
whereItemSql += " and t.ftype = 0 ";
|
||||
} else {
|
||||
whereItemSql += " and t.id = '" + root + "' ";
|
||||
}
|
||||
|
||||
// 获取根节点
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select t.id, t.fname, t.ftype, t.fparentid, t.fleadername,t.fobjid,t.fecid, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fleader, t.fleaderlv, t.fleaderst,t.fecid from jcl_org_map t " + whereSql + whereItemSql);
|
||||
String id = null;
|
||||
if (rs.next()) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
id = rs.getString("id");
|
||||
item.put("id", rs.getString("id"));
|
||||
item.put("fname", rs.getString("fname"));
|
||||
item.put("ftype", rs.getString("ftype"));
|
||||
item.put("parentId", null);
|
||||
item.put("fleadername", rs.getString("fleadername"));
|
||||
item.put("fleaderimg", rs.getString("fleaderimg"));
|
||||
item.put("fleaderjob", rs.getString("fleaderjob"));
|
||||
item.put("fplan", rs.getString("fplan"));
|
||||
item.put("fonjob", rs.getString("fonjob"));
|
||||
item.put("hasChildren", hasChildren(rs.getString("id"), false));
|
||||
item.put("expand", "1");
|
||||
item.put("fnumber", rs.getString("fnumber"));
|
||||
item.put("fleader", rs.getString("fleader"));
|
||||
item.put("fobjid",rs.getString("fobjid"));
|
||||
item.put("fleaderlv",convertLevel(rs.getString("fleaderlv")));
|
||||
item.put("fleaderst",convertGrade(rs.getString("fleaderst")));
|
||||
item.put("fecid",rs.getString("fecid"));
|
||||
list.add(item);
|
||||
}
|
||||
|
||||
int currentLevel = 1;
|
||||
if (currentLevel + 1 <= Integer.parseInt(level)) {
|
||||
findUserItemByParantId(id, currentLevel + 1, level, rs, list, whereSql, true);
|
||||
}else{
|
||||
findUserItemByParantId(id, currentLevel + 1, level, rs, list, whereSql, false);
|
||||
}
|
||||
|
||||
} else {
|
||||
String whereSql = "where fid='0'";
|
||||
// 获取根节点
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select fid, fname, forder, fparentid, ftype from uf_jcl_vo " + whereSql);
|
||||
String fid = null;
|
||||
if (rs.next()) {
|
||||
Map<String,Object> item = new HashMap<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int currentLevel = 1;
|
||||
if (currentLevel + 1 <= Integer.parseInt(level)) {
|
||||
findUserItemByParantId(id, currentLevel + 1, level, rs, list, whereSql, true);
|
||||
}else{
|
||||
findUserItemByParantId(id, currentLevel + 1, level, rs, list, whereSql, false);
|
||||
}
|
||||
|
||||
result.put("api_status", true);
|
||||
result.put("data", list);
|
||||
|
|
@ -327,23 +397,42 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
|
|||
@Override
|
||||
public Map<String, Object> asyncCompanyData(Map<String, Object> request2Map, User user) {
|
||||
String ids = (String) request2Map.get("ids");
|
||||
String whereSql = companyDateWhereSql(request2Map);
|
||||
|
||||
whereSql += " and fparentid in (" + ids + ") ";
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select id, fname, ftype, fparentid, fnumber,fobjid from jcl_org_map " + whereSql);
|
||||
String fisvitual = (String) request2Map.get("fisvitual");
|
||||
List<Map<String, Object>> currentList = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("id", rs.getString("id"));
|
||||
item.put("fname", rs.getString("fname"));
|
||||
item.put("ftype", rs.getString("ftype"));
|
||||
item.put("parentId", rs.getString("fparentid"));
|
||||
item.put("fnumber", rs.getString("fnumber"));
|
||||
item.put("fobjid", rs.getString("fobjid"));
|
||||
item.put("hasChildren", hasChildren(rs.getString("id"), true));
|
||||
currentList.add(item);
|
||||
if (fisvitual.equals("0")) {
|
||||
String whereSql = companyDateWhereSql(request2Map);
|
||||
|
||||
whereSql += " and fparentid in (" + ids + ") ";
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select id, fname, ftype, fparentid, fnumber,fobjid from jcl_org_map " + whereSql);
|
||||
// List<Map<String, Object>> currentList = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("id", rs.getString("id"));
|
||||
item.put("fname", rs.getString("fname"));
|
||||
item.put("ftype", rs.getString("ftype"));
|
||||
item.put("parentId", rs.getString("fparentid"));
|
||||
item.put("fnumber", rs.getString("fnumber"));
|
||||
item.put("fobjid", rs.getString("fobjid"));
|
||||
item.put("hasChildren", hasChildren(rs.getString("id"), true));
|
||||
currentList.add(item);
|
||||
}
|
||||
} else {
|
||||
String whereSql = "where fparentid in (" + ids + ") ";
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select fid, fname, forder, fparentid, ftype from uf_jcl_vo " + whereSql);
|
||||
while (rs.next()) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("id", rs.getString("fid"));
|
||||
item.put("fname", rs.getString("fname"));
|
||||
item.put("ftype", rs.getString("ftype"));
|
||||
item.put("parentId", rs.getString("fparentid"));
|
||||
item.put("forder", rs.getString("forder"));
|
||||
item.put("hasChildren", hasVOChildren(rs.getString("fid")));
|
||||
currentList.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
|
@ -417,6 +506,20 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
|
|||
return !"0".equals(count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 虚拟组织下级部门判断
|
||||
* @return
|
||||
*/
|
||||
private boolean hasVOChildren(String fid) {
|
||||
String whereSql = " where fparentid = " + fid + " ";
|
||||
grs.executeQuery("select count(1) as count from uf_jcl_vo " + whereSql);
|
||||
String count = "0";
|
||||
if (grs.next()) {
|
||||
count = grs.getString("count");
|
||||
}
|
||||
return !"0".equals(count);
|
||||
}
|
||||
|
||||
private String convertLevel(String fLeaderLv) {
|
||||
String jobLevelName = "";
|
||||
if (StringUtils.isBlank(fLeaderLv)) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
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<String, String> doModeExpand(Map<String, Object> param) {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue