diff --git a/docs/表结构SQL/MySQL.sql b/docs/表结构SQL/MySQL.sql index 67473587..ed849c42 100644 --- a/docs/表结构SQL/MySQL.sql +++ b/docs/表结构SQL/MySQL.sql @@ -127,14 +127,14 @@ CREATE TABLE JCL_FIELD_EXTENDINFO ( field_name_desc varchar(100) NULL, field_type varchar(1000) NULL, control_type int null, - extend_group int null, + extend_group_id int null, isenable int null, isrequired int null, list_show int null, search_show int null, edit_show int null, add_show int null, - button_show int null, + browser_show int null, show_order int null, creator int null, delete_type int null, diff --git a/docs/表结构SQL/Oracle.sql b/docs/表结构SQL/Oracle.sql index 4f6f4b75..8d554d2f 100644 --- a/docs/表结构SQL/Oracle.sql +++ b/docs/表结构SQL/Oracle.sql @@ -129,14 +129,14 @@ CREATE TABLE JCL_FIELD_EXTENDINFO ( FIELD_NAME_DESC NVARCHAR2(100) NULL, FIELD_TYPE NVARCHAR2(1000) NULL, CONTROL_TYPE NUMBER NULL, - EXTEND_GROUP NUMBER NULL, + EXTEND_GROUP_ID NUMBER NULL, ISENABLE NUMBER NULL, ISREQUIRED NUMBER NULL, LIST_SHOW NUMBER NULL, SEARCH_SHOW NUMBER NULL, EDIT_SHOW NUMBER NULL, ADD_SHOW NUMBER NULL, - BUTTON_SHOW NUMBER NULL, + BROWSER_SHOW NUMBER NULL, SHOW_ORDER NUMBER NULL, CREATOR NUMBER NULL, DELETE_TYPE NUMBER NULL, diff --git a/docs/表结构SQL/SqlServer.sql b/docs/表结构SQL/SqlServer.sql index a07f5514..930a8b57 100644 --- a/docs/表结构SQL/SqlServer.sql +++ b/docs/表结构SQL/SqlServer.sql @@ -127,14 +127,14 @@ CREATE TABLE JCL_FIELD_EXTENDINFO ( field_name_desc varchar(100) COLLATE Chinese_PRC_CI_AS NULL, field_type varchar(1000) COLLATE Chinese_PRC_CI_AS NULL, control_type int null, - extend_group int null, + extend_group_id int null, isenable int null, isrequired int null, list_show int null, search_show int null, edit_show int null, add_show int null, - button_show int null, + browser_show int null, show_order int null, creator int null, delete_type int null, diff --git a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java new file mode 100644 index 00000000..fac9e9ec --- /dev/null +++ b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java @@ -0,0 +1,120 @@ +package com.engine.organization.entity.extend.bo; + +import com.api.hrm.bean.FieldItem; +import com.api.hrm.util.FieldType; +import com.engine.organization.entity.extend.po.ExtendInfoPO; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/19 + * @version: 1.0 + */ +public class ExtendInfoBO { + + // 封装对象为table组件 + public static List> convertInfoListToTable(List infoPOList, int operateType, boolean showLabel) { + List> lsCol = new ArrayList>(); + Map col = null; + + int width = 100 / infoPOList.size(); + for (int i = 0; infoPOList != null && i < infoPOList.size(); i++) { + ExtendInfoPO extendInfoPO = infoPOList.get(i); + String tmpkey = extendInfoPO.getFieldName(); + col = new HashMap(); + col.put("title", extendInfoPO.getFieldNameDesc()); + + col.put("key", tmpkey); + col.put("dataIndex", tmpkey); + col.put("com", getFieldDetialInfo(extendInfoPO, operateType, showLabel, width)); + + col.put("width", width + "%"); + + lsCol.add(col); + } + return lsCol; + + } + + + /** + * 明细表字段 + * + * @param extendInfoPO + * @param operateType + * @return + */ + private static List getFieldDetialInfo(ExtendInfoPO extendInfoPO, int operateType, boolean showLabel, int width) { + List ls = new ArrayList(); + FieldItem fieldItem = createField(extendInfoPO, operateType, showLabel, width); + ls.add(fieldItem); + return ls; + } + + /** + * 创建列表字段信息 + * + * @param extendInfoPO + * @param operateType + * @param showLabel + * @param width + * @return + */ + private static FieldItem createField(ExtendInfoPO extendInfoPO, int operateType, boolean showLabel, int width) { + FieldItem fieldItem = new FieldItem(); + if (showLabel) { + fieldItem.setLabel(extendInfoPO.getFieldNameDesc()); + } else { + fieldItem.setLabel(""); + } + + fieldItem.setType(getFieldhtmltype(extendInfoPO.getControlType() + "")); + fieldItem.setKey(extendInfoPO.getFieldName()); + // 查看操作 全部设置为只读 + if (0 == operateType) { + fieldItem.setViewAttr(1); + } else { + // 必填 + if (1 == extendInfoPO.getIsrequired()) { + fieldItem.setViewAttr(3); + fieldItem.setRules("required|string"); + } else { + fieldItem.setViewAttr(2); + } + } + + fieldItem.setWidth(width + "%"); + return fieldItem; + } + + /** + * 获取对应的控件类型 + * + * @param fieldhtmltype + * @return + */ + private static FieldType getFieldhtmltype(String fieldhtmltype) { + FieldType fieldtype = null; + if (fieldhtmltype.equals("1")) { + fieldtype = FieldType.INPUT; + } else if (fieldhtmltype.equals("2")) { + fieldtype = FieldType.TEXTAREA; + } else if (fieldhtmltype.equals("3")) { + fieldtype = FieldType.BROWSER; + } else if (fieldhtmltype.equals("4")) { + fieldtype = FieldType.CHECKBOX; + } else if (fieldhtmltype.equals("5")) { + fieldtype = FieldType.SELECT; + } else if (fieldhtmltype.equals("6")) { + fieldtype = FieldType.FILEUPLOAD; + } else if (fieldhtmltype.equals("7")) { + fieldtype = FieldType.TEXT; + } + return fieldtype; + } +} diff --git a/src/com/engine/organization/entity/comp/po/ExtendGroupPO.java b/src/com/engine/organization/entity/extend/po/ExtendGroupPO.java similarity index 92% rename from src/com/engine/organization/entity/comp/po/ExtendGroupPO.java rename to src/com/engine/organization/entity/extend/po/ExtendGroupPO.java index f5eb1a5d..5c840aa2 100644 --- a/src/com/engine/organization/entity/comp/po/ExtendGroupPO.java +++ b/src/com/engine/organization/entity/extend/po/ExtendGroupPO.java @@ -1,4 +1,4 @@ -package com.engine.organization.entity.comp.po; +package com.engine.organization.entity.extend.po; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java b/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java new file mode 100644 index 00000000..acdd7b1a --- /dev/null +++ b/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java @@ -0,0 +1,105 @@ +package com.engine.organization.entity.extend.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/19 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ExtendInfoPO { + /** + * 主键 + */ + private Long id; + + /** + * 类型 + */ + private Integer extendType; + + /** + * 表名 + */ + private String tableName; + + /** + * 字段名 + */ + private String fieldName; + + /** + * 字段中文名 + */ + private String fieldNameDesc; + + /** + * 类型 + */ + private String fieldType; + + /** + * 控件类型 + */ + private Integer controlType; + + /** + * 分组主键 + */ + private Long extendGroupId; + + /** + * 是否启用 + */ + private Integer isenable; + + /** + * 是否必填 + */ + private Integer isrequired; + + /** + * 列表显示 + */ + private Integer listShow; + + /** + * 查询卡片显示 + */ + private Integer searchShow; + + /** + * 修改显示 + */ + private Integer editShow; + + /** + * 增加显示 + */ + private Integer addShow; + + /** + * 浏览按钮显示 + */ + private Integer browserShow; + + /** + * 显示顺序 + */ + private Integer showOrder; + + private Long creator; + private int deleteType; + private Date createTime; + private Date updateTime; +} diff --git a/src/com/engine/organization/mapper/comp/CompMapper.java b/src/com/engine/organization/mapper/comp/CompMapper.java index 38e543a5..d2ef7201 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.java +++ b/src/com/engine/organization/mapper/comp/CompMapper.java @@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Param; import java.util.Collection; import java.util.List; +import java.util.Map; /** * @description: TODO @@ -15,10 +16,34 @@ import java.util.List; public interface CompMapper { /** * 列表查询 - * @param compPO + * + * @return + */ + List list(); + + /** + * 获取顶级数据 + * + * @return + */ + List listParent(); + + /** + * 获取子层级数据 + * + * @param ids * @return */ - List list(CompPO compPO); + List listChild(@Param("ids") Collection ids); + + /** + * 根据ID查询数据 + * + * @param id + * @return + */ + CompPO listById(@Param("id") long id); + /** * 根据No查询数据 @@ -28,6 +53,16 @@ public interface CompMapper { */ List listByNo(@Param("compNo") String compNo); + + /** + * 根据主表id,查询拓展表数据 + * + * @param tableName + * @param id + * @return + */ + List> listCompExtDT(@Param("tableName") String tableName, @Param("id") long id, @Param("fields") String fields); + /** * 更新禁用标记 * @@ -35,6 +70,7 @@ public interface CompMapper { * @return */ int updateForbiddenTagById(CompPO compPO); + /** * 批量删除职务信息方案 * diff --git a/src/com/engine/organization/mapper/comp/CompMapper.xml b/src/com/engine/organization/mapper/comp/CompMapper.xml index f299610f..4fcda970 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.xml +++ b/src/com/engine/organization/mapper/comp/CompMapper.xml @@ -38,13 +38,54 @@ , t.update_time + + and ifnull(parent_company,'0')='0' + + + + and isnull(parent_company,'0')='0' + + + + and NVL(parent_company,'0')='0' + + + + + + + - SELECT FROM jcl_org_comp t WHERE t.delete_type = 0 + and id = #{id} + + + update jcl_org_comp diff --git a/src/com/engine/organization/mapper/comp/ExtendGroupMapper.java b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java similarity index 58% rename from src/com/engine/organization/mapper/comp/ExtendGroupMapper.java rename to src/com/engine/organization/mapper/extend/ExtendGroupMapper.java index c61ddd40..05a32cfc 100644 --- a/src/com/engine/organization/mapper/comp/ExtendGroupMapper.java +++ b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java @@ -1,6 +1,6 @@ -package com.engine.organization.mapper.comp; +package com.engine.organization.mapper.extend; -import com.engine.organization.entity.comp.po.ExtendGroupPO; +import com.engine.organization.entity.extend.po.ExtendGroupPO; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -19,4 +19,12 @@ public interface ExtendGroupMapper { * @return */ List listByType(@Param("groupType") String groupType); + + /** + * 根据ID查询分组名称 + * + * @param id + * @return + */ + String getGroupNameById(@Param("id") String id); } diff --git a/src/com/engine/organization/mapper/comp/ExtendGroupMapper.xml b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml similarity index 79% rename from src/com/engine/organization/mapper/comp/ExtendGroupMapper.xml rename to src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml index fc4bd10e..ba748796 100644 --- a/src/com/engine/organization/mapper/comp/ExtendGroupMapper.xml +++ b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml @@ -1,7 +1,7 @@ - - + + @@ -35,6 +35,11 @@ and extend_type = #{extendType} + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/extend/ExtendInfoMapper.java b/src/com/engine/organization/mapper/extend/ExtendInfoMapper.java new file mode 100644 index 00000000..287411ce --- /dev/null +++ b/src/com/engine/organization/mapper/extend/ExtendInfoMapper.java @@ -0,0 +1,24 @@ +package com.engine.organization.mapper.extend; + +import com.engine.organization.entity.extend.po.ExtendInfoPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/19 + * @version: 1.0 + */ +public interface ExtendInfoMapper { + /** + * 列表查询 + * + * @param extendType + * @param extendGroupId + * @param tableName + * @return + */ + List listFields(@Param("extendType") String extendType, @Param("extendGroupId") String extendGroupId, @Param("tableName") String tableName); +} diff --git a/src/com/engine/organization/mapper/extend/ExtendInfoMapper.xml b/src/com/engine/organization/mapper/extend/ExtendInfoMapper.xml new file mode 100644 index 00000000..c06dec91 --- /dev/null +++ b/src/com/engine/organization/mapper/extend/ExtendInfoMapper.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.extend_type + , t.table_name + , t.field_name + , t.field_name_desc + , t.field_type + , t.control_type + , t.extend_group_id + , t.isenable + , t.isrequired + , t.list_show + , t.search_show + , t.edit_show + , t.add_show + , t.browser_show + , t.show_order + , t.creator + , t.delete_type + , t.create_time + , t.update_time + + + + + + + \ No newline at end of file diff --git a/src/com/engine/organization/service/CompService.java b/src/com/engine/organization/service/CompService.java index df182b1f..50c533f7 100644 --- a/src/com/engine/organization/service/CompService.java +++ b/src/com/engine/organization/service/CompService.java @@ -65,6 +65,14 @@ public interface CompService { * @param params * @return */ - Map getCompForm(Map params); + Map getCompBaseForm(Map params); + + + /** + * 获取新增表单 + * + * @return + */ + Map getCompSaveForm(); } diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index 77425353..4408f5f3 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -1,6 +1,7 @@ package com.engine.organization.service.impl; +import com.api.browser.bean.BrowserBean; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; @@ -13,9 +14,11 @@ import com.engine.organization.entity.comp.bo.CompBO; import com.engine.organization.entity.comp.dto.CompListDTO; import com.engine.organization.entity.comp.param.CompSearchParam; import com.engine.organization.entity.comp.po.CompPO; -import com.engine.organization.entity.comp.po.ExtendGroupPO; +import com.engine.organization.entity.extend.bo.ExtendInfoBO; +import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.mapper.comp.CompMapper; -import com.engine.organization.mapper.comp.ExtendGroupMapper; +import com.engine.organization.mapper.extend.ExtendGroupMapper; +import com.engine.organization.mapper.extend.ExtendInfoMapper; import com.engine.organization.service.CompService; import com.engine.organization.util.MenuBtn; import com.engine.organization.util.OrganizationAssert; @@ -25,7 +28,9 @@ import com.engine.organization.util.page.Column; import com.engine.organization.util.page.PageInfo; import com.engine.organization.util.page.PageUtil; import org.apache.commons.collections4.CollectionUtils; +import weaver.crm.Maint.SectorInfoComInfo; import weaver.general.StringUtil; +import weaver.hrm.resource.ResourceComInfo; import java.util.*; import java.util.stream.Collectors; @@ -45,18 +50,25 @@ public class CompServiceImpl extends Service implements CompService { return MapperProxyFactory.getProxy(ExtendGroupMapper.class); } + private ExtendInfoMapper getExtendInfoMapper() { + return MapperProxyFactory.getProxy(ExtendInfoMapper.class); + } + @Override public Map listPage(CompSearchParam params) { Map datas = new HashMap<>(); PageUtil.start(params.getCurrent(), params.getPageSize()); - CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID()); - List list = getCompMapper().list(compPO); - PageInfo pageInfo = new PageInfo<>(list, CompPO.class); - Collection compPOS = pageInfo.getList(); + List parentList = getCompMapper().listParent(); + List list = new ArrayList<>(); + list.addAll(parentList); + // 递归查询子数据 + getChildPOs(parentList, list); + + CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID()); // 搜索条件过滤数据 - List filterList = filterListByParams(compPOS, compPO); + List filterList = filterListByParams(list, compPO); List compListDTOS = CompBO.buildCompDTOList(list, filterList); PageInfo pageInfos = new PageInfo<>(compListDTOS, CompListDTO.class); @@ -159,11 +171,13 @@ public class CompServiceImpl extends Service implements CompService { List topTabs = new ArrayList<>(); // 基本信息 topTabs.add(TopTab.builder().color("#000000").groupId("0").showcount(false).title("基本信息").viewCondition("0").build()); + + List infoPOList = getExtendInfoMapper().listFields("1", "", "JCL_ORG_COMPEXT"); + List extendGroups = infoPOList.stream().map(ExtendInfoPO::getExtendGroupId).collect(Collectors.toList()); // 拓展信息 - List groupPOList = getExtendGroupMapper().listByType(""); - if (CollectionUtils.isNotEmpty(groupPOList)) { - for (ExtendGroupPO groupPO : groupPOList) { - topTabs.add(TopTab.builder().color("#000000").groupId(groupPO.getId() + "").showcount(false).title(groupPO.getGroupName()).viewCondition(groupPO.getId() + "").build()); + if (CollectionUtils.isNotEmpty(extendGroups)) { + for (Long groupId : extendGroups) { + topTabs.add(TopTab.builder().color("#000000").groupId(groupId + "").showcount(false).title(getExtendGroupMapper().getGroupNameById(groupId + "")).viewCondition(groupId + "").build()); } } apiDatas.put("topTabs", topTabs); @@ -171,17 +185,18 @@ public class CompServiceImpl extends Service implements CompService { } @Override - public Map getCompForm(Map params) { - // operateType 0 查看 1新增 2编辑 - String operateType = (String) params.get("operateType"); - long id = Long.parseLong((String) params.get("id")); + public Map getCompBaseForm(Map params) { + OrganizationAssert.notNull(params.get("operateType"), "请标识操作类型"); List conditionItems = new ArrayList<>(); // 编号 - SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "compNo"); + SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "编号", "compNo"); + compNoItem.setRules("required|string"); // 名称 - SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "compName"); + SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "compName"); + compNameItem.setRules("required|string"); // 简称 - SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "compNameShort"); + SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "简称", "compNameShort"); + compNameShortItem.setRules("required|string"); // TODO 自定义按钮 // 上级公司 SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级公司", "161", "parentCompany", "compBrowser"); @@ -191,13 +206,9 @@ public class CompServiceImpl extends Service implements CompService { SearchConditionItem industryItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "行业", "63", "industry", ""); // 负责人 SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "负责人", "1", "compPrincipal", ""); - // 禁用标记 - List selectOptions = new ArrayList<>(); - SearchConditionOption enableOption = new SearchConditionOption("true", "启用"); - SearchConditionOption disableOption = new SearchConditionOption("false", "禁用"); - selectOptions.add(enableOption); - selectOptions.add(disableOption); - SearchConditionItem forbiddenTagItem = OrganizationFormItemUtil.selectItem(user, selectOptions, 2, 16, 6, false, "禁用标记", "forbiddenTag"); + // 说明 + SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 17, true, 2, 60, "说明", "description"); + conditionItems.add(compNoItem); conditionItems.add(compNameItem); @@ -206,8 +217,53 @@ public class CompServiceImpl extends Service implements CompService { conditionItems.add(orgCodeItem); conditionItems.add(industryItem); conditionItems.add(compPrincipalItem); - conditionItems.add(forbiddenTagItem); + conditionItems.add(descriptionItem); + // 0 查看 1新增 2编辑 + int operateType = Integer.parseInt((String) params.get("operateType")); + long id = Long.parseLong((String) params.get("id")); + // 编辑、查看状态赋值,设置只读状态 + if (1 != operateType) { + // 赋值 + CompPO compPO = getCompMapper().listById(id); + OrganizationAssert.notNull(compPO, "数据不存在或数据已删除"); + compNoItem.setValue(compPO.getCompNo()); + compNameItem.setValue(compPO.getCompName()); + compNameShortItem.setValue(compPO.getCompNameShort()); + + // compBrowserItem + if (null != compPO.getParentCompany()) { + BrowserBean compBrowserBean = compBrowserItem.getBrowserConditionParam(); + compBrowserBean.setReplaceDatas(creatReplaceDatas(compPO.getParentCompany(), getCompMapper().listById(compPO.getParentCompany()).getCompName())); + compBrowserItem.setBrowserConditionParam(compBrowserBean); + } + orgCodeItem.setValue(compPO.getOrgCode()); + // industryItem + BrowserBean industryBean = industryItem.getBrowserConditionParam(); + industryBean.setReplaceDatas(creatReplaceDatas(compPO.getIndustry(), new SectorInfoComInfo().getSectorInfoname(compPO.getIndustry() + ""))); + industryItem.setBrowserConditionParam(industryBean); + try { + // compPrincipalItem + BrowserBean PrincipalBean = compPrincipalItem.getBrowserConditionParam(); + PrincipalBean.setReplaceDatas(creatReplaceDatas(compPO.getCompPrincipal(), new ResourceComInfo().getLastname(compPO.getCompPrincipal() + ""))); + compPrincipalItem.setBrowserConditionParam(PrincipalBean); + } catch (Exception e) { + throw new RuntimeException(e); + } + descriptionItem.setValue(compPO.getDescription()); + + // 查看,全部置位只读 + if (0 == operateType) { + for (SearchConditionItem item : conditionItems) { + item.setViewAttr(1); + } + } + } + + + HashMap buttonsMap = new HashMap<>(); + buttonsMap.put("hasEdit", true); + buttonsMap.put("hasSave", true); HashMap conditionsMap = new HashMap<>(); conditionsMap.put("items", conditionItems); @@ -216,15 +272,11 @@ public class CompServiceImpl extends Service implements CompService { conditionsMap.put("defaultshow", true); - HashMap buttonsMap = new HashMap<>(); - buttonsMap.put("hasEdit", true); - buttonsMap.put("hasSave", true); - HashMap resultMap = new HashMap<>(); resultMap.put("buttons", buttonsMap); resultMap.put("conditions", conditionsMap); resultMap.put("id", id); - resultMap.put("tables", null); + resultMap.put("tables", getExtendTables(id, operateType, false)); Map apiDatas = new HashMap<>(); apiDatas.put("result", resultMap); @@ -232,6 +284,65 @@ public class CompServiceImpl extends Service implements CompService { return apiDatas; } + @Override + public Map getCompSaveForm() { + Map apiDatas = new HashMap<>(); + List addGroups = new ArrayList<>(); + List conditionItems = new ArrayList<>(); + // 编号 + SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "编号", "compNo"); + compNoItem.setRules("required|string"); + // 名称 + SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "compName"); + compNameItem.setRules("required|string"); + // 简称 + SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "简称", "compNameShort"); + compNameShortItem.setRules("required|string"); + // TODO 自定义按钮 + // 上级公司 + SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级公司", "161", "parentCompany", "compBrowser"); + // 组织机构代码 + SearchConditionItem orgCodeItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "组织机构代码", "orgCode"); + // 行业 + SearchConditionItem industryItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "行业", "63", "industry", ""); + // 负责人 + SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "负责人", "1", "compPrincipal", ""); + // 说明 + SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 17, true, 2, 60, "说明", "description"); + + conditionItems.add(compNoItem); + conditionItems.add(compNameItem); + conditionItems.add(compNameShortItem); + conditionItems.add(compBrowserItem); + conditionItems.add(orgCodeItem); + conditionItems.add(industryItem); + conditionItems.add(compPrincipalItem); + conditionItems.add(descriptionItem); + + + addGroups.add(new SearchConditionGroup("基本信息", true, conditionItems)); + apiDatas.put("condition", addGroups); + + return apiDatas; + + } + + /** + * 递归获取子级数据 + * + * @param parentList + * @param list + */ + private void getChildPOs(List parentList, List list) { + List ids = parentList.stream().map(CompPO::getId).collect(Collectors.toList()); + List listchild = getCompMapper().listChild(ids); + if (CollectionUtils.isNotEmpty(listchild)) { + list.addAll(listchild); + getChildPOs(listchild, list); + } + } + + /** * 通过搜索条件过滤list数据 * @@ -260,4 +371,51 @@ public class CompServiceImpl extends Service implements CompService { } return filterList; } + + + /** + * 处理明细表 + * + * @return + */ + private List> getExtendTables(long id, int operateType, boolean showLabel) { + List> tables = new ArrayList<>(); + String tableName = "JCL_ORG_COMPEXT_DT1"; + // 查询所有分布模块,拓展明细表信息 + List infoPOList = getExtendInfoMapper().listFields("1", "", tableName); + Map> groupMap = infoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId)); + // 遍历Map,组装数据 + for (Map.Entry> entry : groupMap.entrySet()) { + Map tableMap = new HashMap<>(); + tableMap.put("hide", false); + tableMap.put("tabname", getExtendGroupMapper().getGroupNameById(entry.getKey() + "")); + Map tabinfoMap = new HashMap<>(); + tabinfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(entry.getValue(), operateType, showLabel)); + tabinfoMap.put("rownum", "rownum"); + + String fields = entry.getValue().stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); + tabinfoMap.put("datas", getCompMapper().listCompExtDT(tableName, id, fields)); + tableMap.put("tabinfo", tabinfoMap); + tables.add(tableMap); + } + return tables; + } + + + /** + * 浏览按钮类型赋值转换 + * + * @param id + * @param name + * @return + */ + private List> creatReplaceDatas(Object id, Object name) { + List> datas = new ArrayList<>(); + Map map = new HashMap<>(); + map.put("id", id); + map.put("name", name); + datas.add(map); + return datas; + + } } diff --git a/src/com/engine/organization/web/CompController.java b/src/com/engine/organization/web/CompController.java index c16954d3..d4a7dcf5 100644 --- a/src/com/engine/organization/web/CompController.java +++ b/src/com/engine/organization/web/CompController.java @@ -131,18 +131,55 @@ public class CompController { } } + /** + * 获取基础表单 + * + * @param request + * @param response + * @return + */ @GET - @Path("/getCompForm") + @Path("/getCompBaseForm") @Produces(MediaType.APPLICATION_JSON) - public ReturnResult getCompForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + public ReturnResult getCompBaseForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { try { User user = HrmUserVarify.getUser(request, response); Map map = ParamUtil.request2Map(request); - return ReturnResult.successed(getCompWrapper(user).getCompForm(map)); + return ReturnResult.successed(getCompWrapper(user).getCompBaseForm(map)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + + @GET + @Path("/getCompSaveForm") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getCompSaveForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + return ReturnResult.successed(getCompWrapper(user).getCompSaveForm()); } catch (Exception e) { return ReturnResult.exceptionHandle(e.getMessage()); } } + /** + * 获取基本信息、拓展信息Tab + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getTabInfo") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getTabInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + return ReturnResult.successed(getCompWrapper(user).getTabInfo()); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } } diff --git a/src/com/engine/organization/wrapper/CompWrapper.java b/src/com/engine/organization/wrapper/CompWrapper.java index d82142c4..699a6821 100644 --- a/src/com/engine/organization/wrapper/CompWrapper.java +++ b/src/com/engine/organization/wrapper/CompWrapper.java @@ -74,7 +74,25 @@ public class CompWrapper extends Service { * @param params * @return */ - public Map getCompForm(Map params) { - return getCompService(user).getCompForm(params); + public Map getCompBaseForm(Map params) { + return getCompService(user).getCompBaseForm(params); + } + + /** + * 新增表单 + * + * @return + */ + public Map getCompSaveForm() { + return getCompService(user).getCompSaveForm(); + } + + /** + * 获取基本信息、拓展信息Tab + * + * @return + */ + public Map getTabInfo() { + return getCompService(user).getTabInfo(); } }