diff --git a/src/com/engine/organization/entity/extend/po/ExtendGroupPO.java b/src/com/engine/organization/entity/extend/po/ExtendGroupPO.java index 5c840aa2..5786466e 100644 --- a/src/com/engine/organization/entity/extend/po/ExtendGroupPO.java +++ b/src/com/engine/organization/entity/extend/po/ExtendGroupPO.java @@ -33,6 +33,11 @@ public class ExtendGroupPO { */ private String groupName; + /** + * 所属分组 + */ + private Long pid; + private Long creator; private int deleteType; private Date createTime; diff --git a/src/com/engine/organization/mapper/extend/ExtMapper.java b/src/com/engine/organization/mapper/extend/ExtMapper.java index da7b11d5..a30f3511 100644 --- a/src/com/engine/organization/mapper/extend/ExtMapper.java +++ b/src/com/engine/organization/mapper/extend/ExtMapper.java @@ -19,7 +19,7 @@ public interface ExtMapper { * @param id * @return */ - Map listCompExt(@Param("tableName") String tableName, @Param("fields") String fields, @Param("id") long id); + Map listExt(@Param("tableName") String tableName, @Param("fields") String fields, @Param("id") long id); /** * 判断当前数据是否存在 @@ -28,7 +28,7 @@ public interface ExtMapper { * @param id * @return */ - int countCompExtById(@Param("tableName") String tableName, @Param("id") long id); + int countExtById(@Param("tableName") String tableName, @Param("id") long id); /** * 插入主表拓展表 @@ -36,7 +36,7 @@ public interface ExtMapper { * @param map * @return */ - int insertCompExt(@Param("tableName") String tableName, @Param("map") Map map); + int insertExt(@Param("tableName") String tableName, @Param("map") Map map); /** * 更新主表拓展表 @@ -44,5 +44,5 @@ public interface ExtMapper { * @param map * @return */ - int updateCompExt(@Param("tableName") String tableName, @Param("id") long id, @Param("map") Map map); + int updateExt(@Param("tableName") String tableName, @Param("id") long id, @Param("map") Map map); } diff --git a/src/com/engine/organization/mapper/extend/ExtMapper.xml b/src/com/engine/organization/mapper/extend/ExtMapper.xml index 40b9672f..612c228b 100644 --- a/src/com/engine/organization/mapper/extend/ExtMapper.xml +++ b/src/com/engine/organization/mapper/extend/ExtMapper.xml @@ -3,7 +3,7 @@ - + insert into ${tableName} ( ${key} @@ -16,7 +16,7 @@ ) - + update ${tableName} set ${key} = #{value} @@ -24,14 +24,14 @@ where id = #{id} - select ${fields} from ${tableName} where delete_type = 0 and id = #{id} - select count(1) from ${tableName} where delete_type = 0 diff --git a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java index 05a32cfc..3c1df2e9 100644 --- a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java +++ b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java @@ -3,6 +3,7 @@ package com.engine.organization.mapper.extend; import com.engine.organization.entity.extend.po.ExtendGroupPO; import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; /** @@ -15,10 +16,26 @@ public interface ExtendGroupMapper { /** * 列表查询 * - * @param groupType + * @param extendType * @return */ - List listByType(@Param("groupType") String groupType); + List listByType(@Param("extendType") String extendType); + + /** + * 根据ID 查询数据 + * + * @param ids + * @return + */ + List listGroupByIds(@Param("ids") Collection ids); + + /** + * 根据ID 查询数据 + * + * @param pid + * @return + */ + List listGroupByPid(@Param("pid") Long pid); /** * 根据ID查询分组名称 diff --git a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml index ba748796..25167c29 100644 --- a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml +++ b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml @@ -16,6 +16,7 @@ t . id + , t.pid , t.extend_type , t.group_name , t.creator @@ -38,7 +39,25 @@ + + diff --git a/src/com/engine/organization/service/CompService.java b/src/com/engine/organization/service/CompService.java index e01ec585..302105f5 100644 --- a/src/com/engine/organization/service/CompService.java +++ b/src/com/engine/organization/service/CompService.java @@ -27,7 +27,7 @@ public interface CompService { * @param params * @return */ - int saveBaseComp(CompSearchParam params); + int saveBaseComp(Map params); /** * 更新禁用标记 diff --git a/src/com/engine/organization/service/ExtService.java b/src/com/engine/organization/service/ExtService.java index 4165b5b9..38b8ac4e 100644 --- a/src/com/engine/organization/service/ExtService.java +++ b/src/com/engine/organization/service/ExtService.java @@ -16,7 +16,7 @@ import java.util.Map; public interface ExtService { /** - * 组装主表拓展表表单 + * 组装主表、主表拓展表表单 * * @param user * @param extendType @@ -28,6 +28,18 @@ public interface ExtService { */ List getExtForm(User user, String extendType, String tableName, int viewAttr, long id, String groupId); + /** + * 组装主表新增表单 + * + * @param user + * @param extendType + * @param tableName + * @param viewAttr + * @param groupId + * @return + */ + List getExtSaveForm(User user, String extendType, String tableName, int viewAttr, String groupId, String autoNoField, String serialType); + /** * 组装明细表表单 * diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index e704aaab..d6fab6c1 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -2,7 +2,6 @@ package com.engine.organization.service.impl; import com.alibaba.fastjson.JSONObject; -import com.api.browser.bean.BrowserBean; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; @@ -12,13 +11,13 @@ import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.hrm.entity.RuleCodeType; import com.engine.organization.component.OrganizationWeaTable; -import com.engine.organization.entity.codesetting.po.CodeRulePO; import com.engine.organization.entity.company.bo.CompBO; import com.engine.organization.entity.company.dto.CompListDTO; import com.engine.organization.entity.company.param.CompSearchParam; import com.engine.organization.entity.company.po.CompPO; -import com.engine.organization.mapper.codesetting.CodeRuleMapper; +import com.engine.organization.entity.extend.po.ExtendGroupPO; import com.engine.organization.mapper.comp.CompMapper; +import com.engine.organization.mapper.extend.ExtMapper; import com.engine.organization.mapper.extend.ExtendGroupMapper; import com.engine.organization.service.CompService; import com.engine.organization.service.ExtService; @@ -31,11 +30,10 @@ import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.page.Column; import com.engine.organization.util.page.PageInfo; import com.engine.organization.util.page.PageUtil; -import weaver.crm.Maint.SectorInfoComInfo; +import org.apache.commons.collections.CollectionUtils; import weaver.general.StringUtil; import weaver.general.Util; import weaver.hrm.User; -import weaver.hrm.resource.ResourceComInfo; import java.util.*; import java.util.stream.Collectors; @@ -54,6 +52,10 @@ public class CompServiceImpl extends Service implements CompService { * 3:岗位 */ private static final String EXTEND_TYPE = "1"; + /** + * 主表表名 + */ + private static final String JCL_ORG_COMP = "JCL_ORG_COMP"; /** * 主表拓展表 */ @@ -65,6 +67,11 @@ public class CompServiceImpl extends Service implements CompService { private static final String RIGHT_NAME = "Company:All"; + /** + * 公司/分部主表title指定ID + */ + private static final Long GROUP_ID = -1L; + private CompMapper getCompMapper() { return MapperProxyFactory.getProxy(CompMapper.class); } @@ -126,14 +133,19 @@ public class CompServiceImpl extends Service implements CompService { } @Override - public int saveBaseComp(CompSearchParam params) { + public int saveBaseComp(Map params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); - // 自动编号 - params.setCompNo(CodeRuleUtil.generateCode(RuleCodeType.SUBCOMPANY, params.getCompNo())); - List list = getCompMapper().listByNo(Util.null2String(params.getCompNo())); + String compNo = (String) params.get("comp_no"); + compNo = CodeRuleUtil.generateCode(RuleCodeType.SUBCOMPANY, compNo); + List list = getCompMapper().listByNo(Util.null2String(compNo)); OrganizationAssert.isEmpty(list, "编号不允许重复"); - CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID()); - return getCompMapper().insertIgnoreNull(compPO); + params.put("comp_no", compNo); + params.put("forbidden_tag", 0); + params.put("creator", user.getUID()); + params.put("delete_type", 0); + params.put("create_time", new Date()); + params.put("update_time", new Date()); + return MapperProxyFactory.getProxy(ExtMapper.class).insertExt(JCL_ORG_COMP, params); } @Override @@ -149,9 +161,12 @@ public class CompServiceImpl extends Service implements CompService { CompSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), CompSearchParam.class); String groupId = (String) params.get("viewCondition"); CompPO compPO = CompBO.convertParamToPO(searchParam, (long) user.getUID()); + if ("0".equals(groupId)) { + groupId = GROUP_ID.toString(); + } int updateCount = 0; // 更新主表数据 - updateCount += getCompMapper().updateBaseComp(compPO); + updateCount += getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_COMP, params, groupId, compPO.getId()); // 更新主表拓展表 updateCount += getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_COMPEXT, params, groupId, compPO.getId()); //更新明细表 @@ -228,10 +243,14 @@ public class CompServiceImpl extends Service implements CompService { buttonsMap.put("hasSave", true); List addGroups = new ArrayList<>(); - if (StringUtil.isEmpty(groupId) || "0".equals(groupId)) { - addGroups.add(new SearchConditionGroup("基本信息", true, getBaseForm(viewAttr, id))); - } else { - addGroups.add(new SearchConditionGroup(getExtendGroupMapper().getGroupNameById(groupId), true, getExtService(user).getExtForm(user, EXTEND_TYPE, JCL_ORG_COMPEXT, viewAttr, id, groupId))); + if ("0".equals(groupId)) { + groupId = GROUP_ID.toString(); + } + List extendGroupPOS = getExtendGroupMapper().listGroupByPid(Long.parseLong(groupId)); + if (CollectionUtils.isNotEmpty(extendGroupPOS)) { + for (ExtendGroupPO extendGroupPO : extendGroupPOS) { + addGroups.add(new SearchConditionGroup(extendGroupPO.getGroupName(), true, getExtService(user).getExtForm(user, EXTEND_TYPE + "", Integer.parseInt(groupId) >= 0 ? JCL_ORG_COMPEXT : JCL_ORG_COMP, viewAttr, id, extendGroupPO.getId().toString()))); + } } HashMap resultMap = new HashMap<>(); @@ -255,91 +274,17 @@ public class CompServiceImpl extends Service implements CompService { HasRightUtil.hasRight(user, RIGHT_NAME, false); 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"); - // 判断是否开启自动编号 - CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.SUBCOMPANY.getValue()); - if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) { - compNoItem.setViewAttr(2); - compNoItem.setHelpfulTip("编号为空,则按照指定规则自动生成编号"); - compNoItem.setRules(""); + List extendGroupPOS = getExtendGroupMapper().listGroupByPid(GROUP_ID); + if (CollectionUtils.isNotEmpty(extendGroupPOS)) { + for (ExtendGroupPO extendGroupPO : extendGroupPOS) { + addGroups.add(new SearchConditionGroup(extendGroupPO.getGroupName(), true, getExtService(user).getExtSaveForm(user, EXTEND_TYPE + "", JCL_ORG_COMP, 2, extendGroupPO.getId().toString(), "comp_no", RuleCodeType.SUBCOMPANY.getValue()))); + } } - getSameFormItem(conditionItems, compNoItem, null); - addGroups.add(new SearchConditionGroup("基本信息", true, conditionItems)); apiDatas.put("condition", addGroups); - return apiDatas; } - /** - * 新增、编辑表单,相同属性 - * - * @param conditionItems - * @param compNoItem - */ - private void getSameFormItem(List conditionItems, SearchConditionItem compNoItem, Long id) { - // 名称 - 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"); - // 上级公司 - SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级公司", "161", "parentCompany", "compBrowser"); - // 组织机构代码 - SearchConditionItem orgCodeItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "组织机构代码", "orgCode"); - orgCodeItem.setRules("required|string"); - // 行业 - SearchConditionItem industryItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "行业", "63", "industry", ""); - // 负责人 - SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "负责人", "1", "compPrincipal", ""); - compPrincipalItem.setRules("required|string"); - // 说明 - SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 16, 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); - - if (null == id) { - return; - } - // 赋值 - 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()); - } /** * 是否为搜索查询 @@ -358,45 +303,4 @@ public class CompServiceImpl extends Service implements CompService { && null == compPO.getForbiddenTag()); } - - /** - * 浏览按钮类型赋值转换 - * - * @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; - - } - - - /** - * 基本信息基础表单 - * - * @param viewAttr - * @param id - * @return - */ - private List getBaseForm(int viewAttr, long id) { - List conditionItems = new ArrayList<>(); - // 编号 - SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 1, 50, "编号", "compNo"); - getSameFormItem(conditionItems, compNoItem, id); - // 查看,全部置位只读 - if (1 == viewAttr) { - for (SearchConditionItem item : conditionItems) { - item.setViewAttr(viewAttr); - } - } - return conditionItems; - } - - } diff --git a/src/com/engine/organization/service/impl/ExtServiceImpl.java b/src/com/engine/organization/service/impl/ExtServiceImpl.java index 17841f76..06e1fced 100644 --- a/src/com/engine/organization/service/impl/ExtServiceImpl.java +++ b/src/com/engine/organization/service/impl/ExtServiceImpl.java @@ -3,8 +3,11 @@ package com.engine.organization.service.impl; import com.api.browser.bean.SearchConditionItem; import com.engine.core.impl.Service; import com.engine.organization.entity.TopTab; +import com.engine.organization.entity.codesetting.po.CodeRulePO; import com.engine.organization.entity.extend.bo.ExtendInfoBO; +import com.engine.organization.entity.extend.po.ExtendGroupPO; import com.engine.organization.entity.extend.po.ExtendInfoPO; +import com.engine.organization.mapper.codesetting.CodeRuleMapper; import com.engine.organization.mapper.extend.ExtDTMapper; import com.engine.organization.mapper.extend.ExtMapper; import com.engine.organization.mapper.extend.ExtendGroupMapper; @@ -61,8 +64,7 @@ public class ExtServiceImpl extends Service implements ExtService { OrganizationAssert.notNull(groupId, "请选择对应的拓展页"); List infoPOList = getExtendInfoMapper().listFields(extendType, groupId, tableName); String fields = infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); - infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); - Map compExtMap = getExtMapper().listCompExt(tableName, fields, id); + Map compExtMap = getExtMapper().listExt(tableName, fields, id); // 组装拓展页内容 for (ExtendInfoPO extendInfoPO : infoPOList) { SearchConditionItem item = ExtendInfoBO.getSearchConditionItem(user, viewAttr, extendInfoPO, null == compExtMap ? null : compExtMap.get(extendInfoPO.getFieldName())); @@ -76,6 +78,35 @@ public class ExtServiceImpl extends Service implements ExtService { return conditionItems; } + @Override + public List getExtSaveForm(User user, String extendType, String tableName, int viewAttr, String groupId, String autoNoField, String serialType) { + List conditionItems = new ArrayList<>(); + + // 2编辑 1查看 + OrganizationAssert.notNull(groupId, "请选择对应的拓展页"); + List infoPOList = getExtendInfoMapper().listFields(extendType, groupId, tableName); + // 组装拓展页内容 + for (ExtendInfoPO extendInfoPO : infoPOList) { + SearchConditionItem item = ExtendInfoBO.getSearchConditionItem(user, viewAttr, extendInfoPO, null); + item.setFieldcol(16); + if (1 == extendInfoPO.getIsrequired()) { + item.setViewAttr(3); + item.setRules("required|string"); + } + if (extendInfoPO.getFieldName().equals(autoNoField)) { + // 判断是否开启自动编号 + CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(serialType); + if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) { + item.setViewAttr(2); + item.setHelpfulTip("编号为空,则按照指定规则自动生成编号"); + item.setRules(""); + } + } + conditionItems.add(item); + } + return conditionItems; + } + @Override public List> getExtendTables(User user, String extendType, String tableName, long id, int viewAttr, boolean showLabel) { List> tables = new ArrayList<>(); @@ -116,11 +147,12 @@ public class ExtServiceImpl extends Service implements ExtService { */ public List getTabInfo(String extendType, String tableName) { List topTabs = new ArrayList<>(); - // 基本信息 - topTabs.add(TopTab.builder().color("#000000").groupId("0").showcount(false).title("基本信息").viewCondition("0").build()); - List infoPOList = getExtendInfoMapper().listFields(extendType, "", tableName); - List extendGroups = infoPOList.stream().map(ExtendInfoPO::getExtendGroupId).collect(Collectors.toList()); + List infoPOList1 = getExtendInfoMapper().listFields(extendType, "", tableName.toLowerCase().replace("ext", "")); + infoPOList.addAll(infoPOList1); + List ids = infoPOList.stream().map(ExtendInfoPO::getExtendGroupId).collect(Collectors.toList()); + List extendGroupPOS = getExtendGroupMapper().listGroupByIds(ids); + Set extendGroups = extendGroupPOS.stream().map(ExtendGroupPO::getPid).collect(Collectors.toSet()); // 拓展信息 if (CollectionUtils.isNotEmpty(extendGroups)) { for (Long groupId : extendGroups) { @@ -140,17 +172,17 @@ public class ExtServiceImpl extends Service implements ExtService { map.put(dtField, params.get(dtField)); } // 判断更新还是插入 - int count = getExtMapper().countCompExtById(tableName, id); + int count = getExtMapper().countExtById(tableName, id); if (count > 0) { map.put("update_time", new Date()); - updateBaseComp = getExtMapper().updateCompExt(tableName, id, map); + updateBaseComp = getExtMapper().updateExt(tableName, id, map); } else { map.put("creator", user.getUID()); map.put("delete_type", 0); map.put("create_time", new Date()); map.put("update_time", new Date()); map.put("id", id); - updateBaseComp = getExtMapper().insertCompExt(tableName, map); + updateBaseComp = getExtMapper().insertExt(tableName, map); } return updateBaseComp; } diff --git a/src/com/engine/organization/web/CompController.java b/src/com/engine/organization/web/CompController.java index 365fcc49..c2a9e23d 100644 --- a/src/com/engine/organization/web/CompController.java +++ b/src/com/engine/organization/web/CompController.java @@ -57,13 +57,12 @@ public class CompController { * * @param request * @param response - * @param params * @return */ @POST @Path("/saveBaseComp") @Produces(MediaType.APPLICATION_JSON) - public ReturnResult saveBaseComp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody CompSearchParam params) { + public ReturnResult saveBaseComp(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody Map params) { try { User user = HrmUserVarify.getUser(request, response); return ReturnResult.successed(getCompWrapper(user).saveBaseComp(params)); diff --git a/src/com/engine/organization/wrapper/CompWrapper.java b/src/com/engine/organization/wrapper/CompWrapper.java index 6e63ba43..d6fed552 100644 --- a/src/com/engine/organization/wrapper/CompWrapper.java +++ b/src/com/engine/organization/wrapper/CompWrapper.java @@ -38,7 +38,7 @@ public class CompWrapper extends Service { * @param params * @return */ - public int saveBaseComp(CompSearchParam params) { + public int saveBaseComp(Map params) { return getCompService(user).saveBaseComp(params); }