From b2fd60a9bc37553fe9edc395d8a1417d6ae0b8e2 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Tue, 17 May 2022 16:12:31 +0800 Subject: [PATCH 01/22] =?UTF-8?q?=E9=9B=86=E5=9B=A2=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/mapper/post/PostInfoMapper.xml | 2 +- .../engine/organization/service/GroupService.java | 10 ++++++++++ .../service/impl/GroupServiceImpl.java | 14 +++++++++++++- src/com/engine/organization/util/MenuBtn.java | 8 ++++---- .../engine/organization/web/GroupController.java | 14 ++++++++++++++ .../engine/organization/wrapper/GroupWrapper.java | 10 ++++++++++ 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/com/engine/organization/mapper/post/PostInfoMapper.xml b/src/com/engine/organization/mapper/post/PostInfoMapper.xml index 9d4a6011..be162ff4 100644 --- a/src/com/engine/organization/mapper/post/PostInfoMapper.xml +++ b/src/com/engine/organization/mapper/post/PostInfoMapper.xml @@ -154,7 +154,7 @@ - + update jcl_org_post_info forbidden_tag=#{forbiddenTag}, diff --git a/src/com/engine/organization/service/GroupService.java b/src/com/engine/organization/service/GroupService.java index fb704c21..fc02bf8e 100644 --- a/src/com/engine/organization/service/GroupService.java +++ b/src/com/engine/organization/service/GroupService.java @@ -17,14 +17,24 @@ public interface GroupService { */ Map getGroupFormField(Map params); + /** + * 更新 + * + * @param params + * @return + */ + boolean updateGroup(Map params); + /** * 获取列表页面按钮信息 + * * @return */ Map getHasRight(); /** * 获取列表tabs + * * @return */ Map getTabInfo(); diff --git a/src/com/engine/organization/service/impl/GroupServiceImpl.java b/src/com/engine/organization/service/impl/GroupServiceImpl.java index fb431936..d2f6d85b 100644 --- a/src/com/engine/organization/service/impl/GroupServiceImpl.java +++ b/src/com/engine/organization/service/impl/GroupServiceImpl.java @@ -6,6 +6,7 @@ import com.engine.core.impl.Service; import com.engine.organization.entity.TopTab; import com.engine.organization.service.GroupService; import com.engine.organization.util.MenuBtn; +import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.OrganizationFormItemUtil; import weaver.conn.RecordSet; import weaver.general.StringUtil; @@ -37,7 +38,6 @@ public class GroupServiceImpl extends Service implements GroupService { String id = Util.null2String(params.get("id")); if (!StringUtil.isEmpty(id)) { RecordSet rs = new RecordSet(); - String sql = "select * from HrmCompany where id in(" + id + ")"; rs.executeQuery(sql); rs.executeQuery(sql); @@ -71,6 +71,18 @@ public class GroupServiceImpl extends Service implements GroupService { return apiDatas; } + @Override + public boolean updateGroup(Map params) { + String id = Util.null2String(params.get("id")); + OrganizationAssert.notNull(id, "数据有误"); + String companyname = (String) params.get("companyname"); + String companydesc = (String) params.get("companydesc"); + String companyweb = (String) params.get("companyweb"); + RecordSet rs = new RecordSet(); + return rs.executeUpdate("update HrmCompany set COMPANYNAME = ?,COMPANYDESC=?,COMPANYWEB=? where id = ?", companyname, companydesc, companyweb, id); + + } + @Override public Map getHasRight() { Map btnDatas = new HashMap<>(); diff --git a/src/com/engine/organization/util/MenuBtn.java b/src/com/engine/organization/util/MenuBtn.java index ac273b73..b8870502 100644 --- a/src/com/engine/organization/util/MenuBtn.java +++ b/src/com/engine/organization/util/MenuBtn.java @@ -33,7 +33,7 @@ public class MenuBtn { * @return */ public static MenuBtn topMenu_addNew() { - return MenuBtn.builder().isBatch("1").isTop("1").menuFun("new").menuIcon("icon-coms-New-Flow").menuName("新建").type("BTN_Addnew").build(); + return MenuBtn.builder().isBatch("1").isTop("1").menuFun("new").menuIcon("icon-coms-New-Flow").menuName("新增").type("BTN_Addnew").build(); } /** @@ -51,7 +51,7 @@ public class MenuBtn { * @return */ public static MenuBtn rightMenu_addNew() { - return MenuBtn.builder().isBatch("0").isTop("1").menuFun("new").menuIcon("icon-coms-New-Flow").menuName("新建").type("BTN_Addnew").build(); + return MenuBtn.builder().isBatch("0").isTop("1").menuFun("new").menuIcon("icon-coms-New-Flow").menuName("新增").type("BTN_Addnew").build(); } /** @@ -80,12 +80,12 @@ public class MenuBtn { Map btnDatas = new HashMap<>(); ArrayList topMenuList = new ArrayList<>(); ArrayList rightMenuList = new ArrayList<>(); - // 新建 + // 新增 topMenuList.add(MenuBtn.topMenu_addNew()); // 批量删除 topMenuList.add(MenuBtn.topMenu_batchDelete()); btnDatas.put("topMenu", topMenuList); - // 新建 + // 新增 rightMenuList.add(MenuBtn.rightMenu_addNew()); // 日志 rightMenuList.add(MenuBtn.rightMenu_btnLog()); diff --git a/src/com/engine/organization/web/GroupController.java b/src/com/engine/organization/web/GroupController.java index 8a4abdf4..be6a5b9e 100644 --- a/src/com/engine/organization/web/GroupController.java +++ b/src/com/engine/organization/web/GroupController.java @@ -4,12 +4,14 @@ import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; import com.engine.organization.util.response.ReturnResult; import com.engine.organization.wrapper.GroupWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; @@ -47,6 +49,18 @@ public class GroupController { } } + @POST + @Path("/updateGroup") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult updateGroup(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map map) { + try { + User user = HrmUserVarify.getUser(request, response); + return ReturnResult.successed(getGroupWrapper(user).updateGroup(map)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + /** * 列表页顶部按钮 * diff --git a/src/com/engine/organization/wrapper/GroupWrapper.java b/src/com/engine/organization/wrapper/GroupWrapper.java index 2c9bd5c0..f56a4a86 100644 --- a/src/com/engine/organization/wrapper/GroupWrapper.java +++ b/src/com/engine/organization/wrapper/GroupWrapper.java @@ -30,6 +30,16 @@ public class GroupWrapper extends Service { return getGroupService(user).getGroupFormField(params); } + /** + * 更新 + * + * @param params + * @return + */ + public boolean updateGroup(Map params) { + return getGroupService(user).updateGroup(params); + } + /** * 获取列表页面按钮信息 * From 5e8041348af020d461790ac64633338f7a3307af Mon Sep 17 00:00:00 2001 From: dxfeng Date: Tue, 17 May 2022 16:36:53 +0800 Subject: [PATCH 02/22] =?UTF-8?q?=E5=85=AC=E5=8F=B8/=E5=88=86=E9=83=A8=20?= =?UTF-8?q?=20=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/entity/comp/bo/CompBO.java | 31 +++++-- .../entity/comp/dto/CompListDTO.java | 8 +- .../entity/comp/param/CompSearchParam.java | 70 ++++++++++++++++ .../organization/entity/comp/po/CompPO.java | 43 +++++++++- .../organization/mapper/comp/CompMapper.java | 28 ++++++- .../organization/mapper/comp/CompMapper.xml | 81 +++++++++++++++++- .../organization/service/CompService.java | 36 +++++++- .../service/impl/CompServiceImpl.java | 83 ++++++++++++++++--- .../organization/web/CompController.java | 7 +- .../organization/wrapper/CompWrapper.java | 4 +- 10 files changed, 356 insertions(+), 35 deletions(-) create mode 100644 src/com/engine/organization/entity/comp/param/CompSearchParam.java diff --git a/src/com/engine/organization/entity/comp/bo/CompBO.java b/src/com/engine/organization/entity/comp/bo/CompBO.java index 02c59c37..635c6892 100644 --- a/src/com/engine/organization/entity/comp/bo/CompBO.java +++ b/src/com/engine/organization/entity/comp/bo/CompBO.java @@ -1,13 +1,11 @@ package com.engine.organization.entity.comp.bo; 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 org.apache.commons.collections.CollectionUtils; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -30,7 +28,6 @@ public class CompBO { .orgCode(e.getOrgCode()) .industry(e.getIndustry()) .compPrincipal(e.getCompPrincipal()) - .description(e.getDescription()) .forbiddenTag(e.getForbiddenTag()) .build() ).collect(Collectors.toList()); @@ -41,4 +38,28 @@ public class CompBO { }).collect(Collectors.toList()); } + public static CompPO convertParamToPO(CompSearchParam param, Long employeeId) { + if (null == param) { + return null; + } + return CompPO.builder() + .id(param.getId() == null ? 0 : param.getId()) + .compNo(param.getCompNo()) + .compName(param.getCompName()) + .compNameShort(param.getCompNameShort()) + .parentCompany(param.getParentCompany()) + .orgCode(param.getOrgCode()) + .industry(param.getIndustry()) + .compPrincipal(param.getCompPrincipal()) + .description(param.getDescription()) + .forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1) + .deleteType(0) + .createTime(new Date()) + .updateTime(new Date()) + .creator(employeeId) + .build(); + + } + + } diff --git a/src/com/engine/organization/entity/comp/dto/CompListDTO.java b/src/com/engine/organization/entity/comp/dto/CompListDTO.java index b7f8b2ee..de8b243e 100644 --- a/src/com/engine/organization/entity/comp/dto/CompListDTO.java +++ b/src/com/engine/organization/entity/comp/dto/CompListDTO.java @@ -78,17 +78,11 @@ public class CompListDTO { @TableTitle(title = "负责人", dataIndex = "compPrincipal", key = "compPrincipal") private Integer compPrincipal; - /** - * 说明 - */ - @TableTitle(title = "说明", dataIndex = "description", key = "description") - private String description; - /** * 禁用标记 */ @TableTitle(title = "禁用标记", dataIndex = "forbiddenTag", key = "forbiddenTag") - private String forbiddenTag; + private int forbiddenTag; /** * 子节点 diff --git a/src/com/engine/organization/entity/comp/param/CompSearchParam.java b/src/com/engine/organization/entity/comp/param/CompSearchParam.java new file mode 100644 index 00000000..0010a515 --- /dev/null +++ b/src/com/engine/organization/entity/comp/param/CompSearchParam.java @@ -0,0 +1,70 @@ +package com.engine.organization.entity.comp.param; + +import com.engine.organization.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/16 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CompSearchParam extends BaseQueryParam { + + /** + * 主键 + */ + private Long id; + + /** + * 编号 + */ + private String compNo; + + /** + * 名称 + */ + private String compName; + + /** + * 简称 + */ + private String compNameShort; + + /** + * 上级公司 + */ + private Long parentCompany; + + /** + * 组织机构代码 + */ + private String orgCode; + + /** + * 行业 + */ + private Integer industry; + + /** + * 负责人 + */ + private Integer compPrincipal; + + /** + * 说明 + */ + private String description; + + /** + * 禁用标记 + */ + private Boolean forbiddenTag; +} diff --git a/src/com/engine/organization/entity/comp/po/CompPO.java b/src/com/engine/organization/entity/comp/po/CompPO.java index c76234fa..671b17fe 100644 --- a/src/com/engine/organization/entity/comp/po/CompPO.java +++ b/src/com/engine/organization/entity/comp/po/CompPO.java @@ -18,16 +18,57 @@ import java.util.Date; @AllArgsConstructor @NoArgsConstructor public class CompPO { + + /** + * 主键 + */ private Long id; + + /** + * 编号 + */ private String compNo; + + /** + * 名称 + */ private String compName; + + /** + * 简称 + */ private String compNameShort; + + /** + * 上级公司 + */ private Long parentCompany; + + /** + * 组织机构代码 + */ private String orgCode; + + /** + * 行业 + */ private Integer industry; + + /** + * 负责人 + */ private Integer compPrincipal; + + /** + * 说明 + */ private String description; - private String forbiddenTag; + + /** + * 禁用标记 + */ + private Integer forbiddenTag; + private Long creator; private int deleteType; private Date createTime; diff --git a/src/com/engine/organization/mapper/comp/CompMapper.java b/src/com/engine/organization/mapper/comp/CompMapper.java index e5f2df15..38e543a5 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.java +++ b/src/com/engine/organization/mapper/comp/CompMapper.java @@ -1,9 +1,9 @@ package com.engine.organization.mapper.comp; -import com.engine.organization.common.BaseQueryParam; import com.engine.organization.entity.comp.po.CompPO; import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; /** @@ -15,8 +15,30 @@ import java.util.List; public interface CompMapper { /** * 列表查询 - * @param queryParam + * @param compPO * @return */ - List list(@Param("param") BaseQueryParam queryParam); + List list(CompPO compPO); + + /** + * 根据No查询数据 + * + * @param compNo + * @return + */ + List listByNo(@Param("compNo") String compNo); + + /** + * 更新禁用标记 + * + * @param compPO + * @return + */ + int updateForbiddenTagById(CompPO compPO); + /** + * 批量删除职务信息方案 + * + * @param ids + */ + int deleteByIds(@Param("ids") Collection ids); } diff --git a/src/com/engine/organization/mapper/comp/CompMapper.xml b/src/com/engine/organization/mapper/comp/CompMapper.xml index 44086a0f..e6556bab 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.xml +++ b/src/com/engine/organization/mapper/comp/CompMapper.xml @@ -38,13 +38,92 @@ , t.update_time - SELECT FROM jcl_org_comp t WHERE t.delete_type = 0 + + and parent_company = #{parentCompany} + + + and comp_principal = #{compPrincipal} + + + and industry = #{industry} + + + and forbidden_tag = #{forbiddenTag} + + + + + + + update jcl_org_comp + + forbidden_tag=#{forbiddenTag}, + + WHERE id = #{id} AND delete_type = 0 + + + + UPDATE jcl_org_comp + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + \ 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 73c7d549..dfeed7a8 100644 --- a/src/com/engine/organization/service/CompService.java +++ b/src/com/engine/organization/service/CompService.java @@ -1,7 +1,8 @@ package com.engine.organization.service; -import com.engine.organization.common.BaseQueryParam; +import com.engine.organization.entity.comp.param.CompSearchParam; +import java.util.Collection; import java.util.Map; /** @@ -14,8 +15,37 @@ public interface CompService { /** * 列表 - * @param baseQueryParam + * @param params * @return */ - Map listPage(BaseQueryParam baseQueryParam); + Map listPage(CompSearchParam params); + + /** + * 更新禁用标记 + * + * @param params + */ + int updateForbiddenTagById(CompSearchParam params); + + + /** + * 根据ID批量删除 + * + * @param ids + */ + int deleteByIds(Collection ids); + + /** + * 获取搜索条件 + * + * @param params + * @return + */ + Map getSearchCondition(Map params); + + /** + * 获取列表页面按钮信息 + * @return + */ + Map getHasRight(); } diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index dda51dfa..088b60af 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -1,25 +1,28 @@ package com.engine.organization.service.impl; +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; -import com.engine.organization.common.BaseQueryParam; import com.engine.organization.component.OrganizationWeaTable; 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.mapper.comp.CompMapper; import com.engine.organization.service.CompService; +import com.engine.organization.util.MenuBtn; +import com.engine.organization.util.OrganizationAssert; +import com.engine.organization.util.OrganizationFormItemUtil; 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 java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -34,18 +37,19 @@ public class CompServiceImpl extends Service implements CompService { } @Override - public Map listPage(BaseQueryParam queryParam) { + public Map listPage(CompSearchParam params) { Map datas = new HashMap<>(); - PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); - List list = getCompMapper().list(queryParam); + PageUtil.start(params.getCurrent(), params.getPageSize()); + List list = getCompMapper().list(CompBO.convertParamToPO(params,(long) user.getUID())); PageInfo pageInfo = new PageInfo<>(list, CompPO.class); Collection compPOS = pageInfo.getList(); + // List compListDTOS = CompBO.buildCompDTOList(compPOS); PageInfo pageInfos = new PageInfo<>(compListDTOS, CompListDTO.class); pageInfos.setTotal(pageInfo.getTotal()); - pageInfos.setPageNum(queryParam.getCurrent()); - pageInfos.setPageSize(queryParam.getPageSize()); + pageInfos.setPageNum(params.getCurrent()); + pageInfos.setPageSize(params.getPageSize()); OrganizationWeaTable table = new OrganizationWeaTable<>(user, CompListDTO.class); List columns = pageInfos.getColumns(); @@ -62,4 +66,63 @@ public class CompServiceImpl extends Service implements CompService { datas.put("dataKey",result.getResultMap()); return datas; } + + @Override + public int updateForbiddenTagById(CompSearchParam params) { + CompPO compPO = CompPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).build(); + return getCompMapper().updateForbiddenTagById(compPO); + } + + @Override + public int deleteByIds(Collection ids) { + OrganizationAssert.notEmpty(ids, "请选择要删除的数据"); + return getCompMapper().deleteByIds(ids); + } + + @Override + public Map getSearchCondition(Map params) { + Map apiDatas = new HashMap<>(); + List addGroups = new ArrayList<>(); + List conditionItems = new ArrayList<>(); + // 编号 + SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "compNo"); + // 名称 + SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "compName"); + // 简称 + SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "compNameShort"); + // 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.inputItem(user, 2, 16, 2, 50, "行业", "industry"); + // 负责人 + SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "负责人", "compPrincipal"); + // 禁用标记 + List selectOptions = new ArrayList<>(); + SearchConditionOption enableOption = new SearchConditionOption("0","启用"); + SearchConditionOption disableOption = new SearchConditionOption("1","禁用"); + selectOptions.add(enableOption); + selectOptions.add(disableOption); + SearchConditionItem forbiddenTagItem= OrganizationFormItemUtil.selectItem(user,selectOptions,2,16,6,false,"禁用标记","forbiddenTag"); + + conditionItems.add(compNoItem); + conditionItems.add(compNameItem); + conditionItems.add(compNameShortItem); + conditionItems.add(compBrowserItem); + conditionItems.add(orgCodeItem); + conditionItems.add(industryItem); + conditionItems.add(compPrincipalItem); + conditionItems.add(forbiddenTagItem); + + addGroups.add(new SearchConditionGroup("高级搜索条件", true, conditionItems)); + apiDatas.put("conditions", addGroups); + return apiDatas; + } + + @Override + public Map getHasRight() { + return MenuBtn.getCommonBtnDatas(); + } } diff --git a/src/com/engine/organization/web/CompController.java b/src/com/engine/organization/web/CompController.java index 5635f0cc..899ee098 100644 --- a/src/com/engine/organization/web/CompController.java +++ b/src/com/engine/organization/web/CompController.java @@ -1,7 +1,7 @@ package com.engine.organization.web; import com.engine.common.util.ServiceUtil; -import com.engine.organization.common.BaseQueryParam; +import com.engine.organization.entity.comp.param.CompSearchParam; import com.engine.organization.util.response.ReturnResult; import com.engine.organization.wrapper.CompWrapper; import io.swagger.v3.oas.annotations.parameters.RequestBody; @@ -32,15 +32,16 @@ public class CompController { * * @param request * @param response + * @param params * @return */ @POST @Path("/listComp") @Produces(MediaType.APPLICATION_JSON) - public ReturnResult listComp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody BaseQueryParam queryParam) { + public ReturnResult listComp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody CompSearchParam params) { try { User user = HrmUserVarify.getUser(request, response); - return ReturnResult.successed(getCompWrapper(user).listPage(queryParam)); + return ReturnResult.successed(getCompWrapper(user).listPage(params)); } 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 77dda5da..c19a6f5e 100644 --- a/src/com/engine/organization/wrapper/CompWrapper.java +++ b/src/com/engine/organization/wrapper/CompWrapper.java @@ -2,7 +2,7 @@ package com.engine.organization.wrapper; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; -import com.engine.organization.common.BaseQueryParam; +import com.engine.organization.entity.comp.param.CompSearchParam; import com.engine.organization.service.CompService; import com.engine.organization.service.impl.CompServiceImpl; import weaver.hrm.User; @@ -26,7 +26,7 @@ public class CompWrapper extends Service { * @param params * @return */ - public Map listPage(BaseQueryParam params) { + public Map listPage(CompSearchParam params) { return getCompService(user).listPage(params); } } From 5b088ce1463d187ca3889e8ff500f9da7cc191d4 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Wed, 18 May 2022 09:17:01 +0800 Subject: [PATCH 03/22] =?UTF-8?q?=E5=85=AC=E5=8F=B8/=E5=88=86=E9=83=A8=20?= =?UTF-8?q?=20=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/entity/comp/bo/CompBO.java | 4 +- .../organization/mapper/comp/CompMapper.xml | 55 --------------- .../service/impl/CompServiceImpl.java | 67 ++++++++++++++++--- 3 files changed, 60 insertions(+), 66 deletions(-) diff --git a/src/com/engine/organization/entity/comp/bo/CompBO.java b/src/com/engine/organization/entity/comp/bo/CompBO.java index 635c6892..23b8ceda 100644 --- a/src/com/engine/organization/entity/comp/bo/CompBO.java +++ b/src/com/engine/organization/entity/comp/bo/CompBO.java @@ -32,10 +32,10 @@ public class CompBO { .build() ).collect(Collectors.toList()); Map> collects = dtoList.stream().filter(item -> null != item.getParentCompany() && 0 != item.getParentCompany()).collect(Collectors.groupingBy(CompListDTO::getParentCompany)); - return dtoList.stream().filter(item -> null == item.getParentCompany() || 0 == item.getParentCompany()).map(e -> { + return dtoList.stream().map(e -> { e.setChildren(collects.get(e.getId())); return e; - }).collect(Collectors.toList()); + }).filter(item -> null == item.getParentCompany() || 0 == item.getParentCompany()).collect(Collectors.toList()); } public static CompPO convertParamToPO(CompSearchParam param, Long employeeId) { diff --git a/src/com/engine/organization/mapper/comp/CompMapper.xml b/src/com/engine/organization/mapper/comp/CompMapper.xml index e6556bab..f299610f 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.xml +++ b/src/com/engine/organization/mapper/comp/CompMapper.xml @@ -38,48 +38,6 @@ , t.update_time - - - and comp_no like CONCAT('%',#{compNo},'%') - - - and comp_name like CONCAT('%',#{compName},'%') - - - and comp_name_short like CONCAT('%',#{compNameShort},'%') - - - and org_code like CONCAT('%',#{orgCode},'%') - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + SELECT + + FROM + jcl_field_extendgroup t + WHERE t.delete_type = 0 + + and extend_type = #{extendType} + + + + + \ 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 dfeed7a8..df182b1f 100644 --- a/src/com/engine/organization/service/CompService.java +++ b/src/com/engine/organization/service/CompService.java @@ -15,10 +15,11 @@ public interface CompService { /** * 列表 + * * @param params * @return */ - Map listPage(CompSearchParam params); + Map listPage(CompSearchParam params); /** * 更新禁用标记 @@ -45,7 +46,25 @@ public interface CompService { /** * 获取列表页面按钮信息 + * * @return */ Map getHasRight(); + + + /** + * 获取基本信息、拓展信息Tab + * + * @return + */ + Map getTabInfo(); + + /** + * 获取基本信息表单 + * + * @param params + * @return + */ + Map getCompForm(Map params); + } diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index c040d33d..77425353 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -8,11 +8,14 @@ import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; import com.engine.organization.component.OrganizationWeaTable; +import com.engine.organization.entity.TopTab; 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.mapper.comp.CompMapper; +import com.engine.organization.mapper.comp.ExtendGroupMapper; import com.engine.organization.service.CompService; import com.engine.organization.util.MenuBtn; import com.engine.organization.util.OrganizationAssert; @@ -21,6 +24,7 @@ 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 org.apache.commons.collections4.CollectionUtils; import weaver.general.StringUtil; import java.util.*; @@ -37,24 +41,24 @@ public class CompServiceImpl extends Service implements CompService { return MapperProxyFactory.getProxy(CompMapper.class); } + private ExtendGroupMapper getExtendGroupMapper() { + return MapperProxyFactory.getProxy(ExtendGroupMapper.class); + } + + @Override public Map listPage(CompSearchParam params) { Map datas = new HashMap<>(); PageUtil.start(params.getCurrent(), params.getPageSize()); - List list = getCompMapper().list(CompBO.convertParamToPO(params, (long) user.getUID())); + 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 filterList = filterListByParams(compPOS, params); - // 递归添加父级数据 - Map poMaps = list.stream().collect(Collectors.toMap(item -> item.getId(), item -> item)); - List addedList = new ArrayList<>(); - for (CompPO po : filterList) { - dealParentData(addedList, po, poMaps); - } + List filterList = filterListByParams(compPOS, compPO); - List compListDTOS = CompBO.buildCompDTOList(addedList); + List compListDTOS = CompBO.buildCompDTOList(list, filterList); PageInfo pageInfos = new PageInfo<>(compListDTOS, CompListDTO.class); pageInfos.setTotal(pageInfos.getTotal()); pageInfos.setPageNum(params.getCurrent()); @@ -106,13 +110,13 @@ public class CompServiceImpl extends Service implements CompService { // 组织机构代码 SearchConditionItem orgCodeItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "组织机构代码", "orgCode"); // 行业 - SearchConditionItem industryItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "行业", "industry"); + SearchConditionItem industryItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "行业", "63", "industry", ""); // 负责人 - SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "负责人", "compPrincipal"); + SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "负责人", "1", "compPrincipal", ""); // 禁用标记 List selectOptions = new ArrayList<>(); - SearchConditionOption enableOption = new SearchConditionOption("0", "启用"); - SearchConditionOption disableOption = new SearchConditionOption("1", "禁用"); + 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"); @@ -133,29 +137,122 @@ public class CompServiceImpl extends Service implements CompService { @Override public Map getHasRight() { - return MenuBtn.getCommonBtnDatas(); + Map btnDatas = new HashMap<>(); + ArrayList topMenuList = new ArrayList<>(); + ArrayList rightMenuList = new ArrayList<>(); + // 新增 + topMenuList.add(MenuBtn.topMenu_addNew()); + // 批量删除 + topMenuList.add(MenuBtn.topMenu_batchDelete()); + btnDatas.put("topMenu", topMenuList); + // 新增 + rightMenuList.add(MenuBtn.rightMenu_addNew()); + // 日志 + rightMenuList.add(MenuBtn.rightMenu_btnLog()); + btnDatas.put("rightMenu", rightMenuList); + return btnDatas; + } + + @Override + public Map getTabInfo() { + Map apiDatas = new HashMap<>(); + List topTabs = new ArrayList<>(); + // 基本信息 + topTabs.add(TopTab.builder().color("#000000").groupId("0").showcount(false).title("基本信息").viewCondition("0").build()); + // 拓展信息 + 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()); + } + } + apiDatas.put("topTabs", topTabs); + return apiDatas; + } + + @Override + public Map getCompForm(Map params) { + // operateType 0 查看 1新增 2编辑 + String operateType = (String) params.get("operateType"); + long id = Long.parseLong((String) params.get("id")); + List conditionItems = new ArrayList<>(); + // 编号 + SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "compNo"); + // 名称 + SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "compName"); + // 简称 + SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "compNameShort"); + // 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", ""); + // 禁用标记 + 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"); + + conditionItems.add(compNoItem); + conditionItems.add(compNameItem); + conditionItems.add(compNameShortItem); + conditionItems.add(compBrowserItem); + conditionItems.add(orgCodeItem); + conditionItems.add(industryItem); + conditionItems.add(compPrincipalItem); + conditionItems.add(forbiddenTagItem); + + + HashMap conditionsMap = new HashMap<>(); + conditionsMap.put("items", conditionItems); + conditionsMap.put("title", "基本信息"); + conditionsMap.put("hide", false); + 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); + Map apiDatas = new HashMap<>(); + + apiDatas.put("result", resultMap); + + return apiDatas; } /** * 通过搜索条件过滤list数据 + * * @param compPOS - * @param params + * @param compPO * @return */ - private List filterListByParams(Collection compPOS, CompSearchParam params) { + private List filterListByParams(Collection compPOS, CompPO compPO) { // 搜索后的数据 List filterList = new ArrayList<>(); // 筛选数据 for (Iterator iterator = compPOS.iterator(); iterator.hasNext(); ) { CompPO next = iterator.next(); - boolean isAdd = (StringUtil.isEmpty(params.getCompName()) || next.getCompName().contains(params.getCompName())) // 名称 - && (StringUtil.isEmpty(params.getCompNo()) || next.getCompNo().contains(params.getCompNo()))//编号 - && (StringUtil.isEmpty(params.getCompNameShort()) || next.getCompNameShort().contains(params.getCompNameShort()))//简称 - && (null == params.getParentCompany() || next.getParentCompany().equals(params.getParentCompany()))//上级公司 - && (StringUtil.isEmpty(params.getOrgCode()) || next.getOrgCode().contains(params.getOrgCode()))//组织机构代码 - && (null == params.getIndustry() || next.getIndustry().equals(params.getIndustry()))//行业 - && (null == params.getCompPrincipal() || next.getCompPrincipal().equals(params.getCompPrincipal()))//负责人 - && (null == params.getForbiddenTag() || next.getForbiddenTag().equals(params.getForbiddenTag()));//禁用标记 + boolean isAdd = (StringUtil.isEmpty(compPO.getCompName()) || next.getCompName().contains(compPO.getCompName())) // 名称 + && (StringUtil.isEmpty(compPO.getCompNo()) || next.getCompNo().contains(compPO.getCompNo()))//编号 + && (StringUtil.isEmpty(compPO.getCompNameShort()) || next.getCompNameShort().contains(compPO.getCompNameShort()))//简称 + && (null == compPO.getParentCompany() || next.getParentCompany().equals(compPO.getParentCompany()))//上级公司 + && (StringUtil.isEmpty(compPO.getOrgCode()) || next.getOrgCode().contains(compPO.getOrgCode()))//组织机构代码 + && (null == compPO.getIndustry() || next.getIndustry().equals(compPO.getIndustry()))//行业 + && (null == compPO.getCompPrincipal() || next.getCompPrincipal().equals(compPO.getCompPrincipal()))//负责人 + && (null == compPO.getForbiddenTag() || next.getForbiddenTag().equals(compPO.getForbiddenTag()));//禁用标记 if (isAdd) { filterList.add(next); } @@ -163,21 +260,4 @@ public class CompServiceImpl extends Service implements CompService { } return filterList; } - - /** - * 递归获取查询后数据的父级数据 - * - * @param addedList - * @param po - * @param poMaps - */ - private void dealParentData(List addedList, CompPO po, Map poMaps) { - if (!addedList.contains(po)) { - addedList.add(po); - } - CompPO parentCompPO = poMaps.get(po.getParentCompany()); - if (null != parentCompPO) { - dealParentData(addedList, parentCompPO, poMaps); - } - } } diff --git a/src/com/engine/organization/web/CompController.java b/src/com/engine/organization/web/CompController.java index 55547548..c16954d3 100644 --- a/src/com/engine/organization/web/CompController.java +++ b/src/com/engine/organization/web/CompController.java @@ -130,4 +130,19 @@ public class CompController { return ReturnResult.exceptionHandle(e.getMessage()); } } + + @GET + @Path("/getCompForm") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getCompForm(@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)); + } 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 9f68e00c..d82142c4 100644 --- a/src/com/engine/organization/wrapper/CompWrapper.java +++ b/src/com/engine/organization/wrapper/CompWrapper.java @@ -67,4 +67,14 @@ public class CompWrapper extends Service { public Map getHasRight() { return getCompService(user).getHasRight(); } + + /** + * 获取基本信息表单 + * + * @param params + * @return + */ + public Map getCompForm(Map params) { + return getCompService(user).getCompForm(params); + } } From 1bc660ab8d3c00a02fb223f1241f56b8eb7e6a8e Mon Sep 17 00:00:00 2001 From: dxfeng Date: Thu, 19 May 2022 18:47:03 +0800 Subject: [PATCH 07/22] =?UTF-8?q?=E5=85=AC=E5=8F=B8/=E5=88=86=E9=83=A8=20?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=E3=80=81=E7=BC=96=E8=BE=91=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=20=E8=A1=A8=E7=BB=93=E6=9E=84=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/表结构SQL/MySQL.sql | 4 +- docs/表结构SQL/Oracle.sql | 4 +- docs/表结构SQL/SqlServer.sql | 4 +- .../entity/extend/bo/ExtendInfoBO.java | 120 ++++++++++ .../{comp => extend}/po/ExtendGroupPO.java | 2 +- .../entity/extend/po/ExtendInfoPO.java | 105 +++++++++ .../organization/mapper/comp/CompMapper.java | 40 +++- .../organization/mapper/comp/CompMapper.xml | 51 +++- .../{comp => extend}/ExtendGroupMapper.java | 12 +- .../{comp => extend}/ExtendGroupMapper.xml | 9 +- .../mapper/extend/ExtendInfoMapper.java | 24 ++ .../mapper/extend/ExtendInfoMapper.xml | 72 ++++++ .../organization/service/CompService.java | 10 +- .../service/impl/CompServiceImpl.java | 220 +++++++++++++++--- .../organization/web/CompController.java | 43 +++- .../organization/wrapper/CompWrapper.java | 22 +- 16 files changed, 691 insertions(+), 51 deletions(-) create mode 100644 src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java rename src/com/engine/organization/entity/{comp => extend}/po/ExtendGroupPO.java (92%) create mode 100644 src/com/engine/organization/entity/extend/po/ExtendInfoPO.java rename src/com/engine/organization/mapper/{comp => extend}/ExtendGroupMapper.java (58%) rename src/com/engine/organization/mapper/{comp => extend}/ExtendGroupMapper.xml (79%) create mode 100644 src/com/engine/organization/mapper/extend/ExtendInfoMapper.java create mode 100644 src/com/engine/organization/mapper/extend/ExtendInfoMapper.xml 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(); } } From 634f2d6b09acbab6cec6090f6b9b3068a4347e04 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Fri, 20 May 2022 15:00:03 +0800 Subject: [PATCH 08/22] =?UTF-8?q?=E8=81=94=E6=9F=A5=E9=83=A8=E9=97=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/DepartmentController.java | 13 ++++ .../entity/department/bo/DepartmentBO.java | 77 +++++++++++++++++++ .../param/QuerySingleDeptListParam.java | 23 ++++++ .../entity/department/po/DepartmentPO.java | 49 ++++++++++++ .../department/vo/SingleDeptTreeVO.java | 43 +++++++++++ .../entity/employee/Employee.java | 28 +++++++ .../mapper/department/DepartmentMapper.java | 21 +++++ .../mapper/department/DepartmentMapper.xml | 27 +++++++ .../mapper/employee/EmployeeMapper.java | 17 ++++ .../mapper/employee/EmployeeMapper.xml | 11 +++ .../service/DepartmentService.java | 22 ++++++ .../service/impl/DepartmentServiceImpl.java | 39 ++++++++++ .../web/DepartmentController.java | 44 +++++++++++ .../wrapper/DepartmentWrapper.java | 29 +++++++ 14 files changed, 443 insertions(+) create mode 100644 src/com/api/organization/web/DepartmentController.java create mode 100644 src/com/engine/organization/entity/department/bo/DepartmentBO.java create mode 100644 src/com/engine/organization/entity/department/param/QuerySingleDeptListParam.java create mode 100644 src/com/engine/organization/entity/department/po/DepartmentPO.java create mode 100644 src/com/engine/organization/entity/department/vo/SingleDeptTreeVO.java create mode 100644 src/com/engine/organization/entity/employee/Employee.java create mode 100644 src/com/engine/organization/mapper/department/DepartmentMapper.java create mode 100644 src/com/engine/organization/mapper/department/DepartmentMapper.xml create mode 100644 src/com/engine/organization/mapper/employee/EmployeeMapper.java create mode 100644 src/com/engine/organization/mapper/employee/EmployeeMapper.xml create mode 100644 src/com/engine/organization/service/DepartmentService.java create mode 100644 src/com/engine/organization/service/impl/DepartmentServiceImpl.java create mode 100644 src/com/engine/organization/web/DepartmentController.java create mode 100644 src/com/engine/organization/wrapper/DepartmentWrapper.java diff --git a/src/com/api/organization/web/DepartmentController.java b/src/com/api/organization/web/DepartmentController.java new file mode 100644 index 00000000..b79f621a --- /dev/null +++ b/src/com/api/organization/web/DepartmentController.java @@ -0,0 +1,13 @@ +package com.api.organization.web; + +import javax.ws.rs.Path; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/20 + * @Version V1.0 + **/ +@Path("/bs/hrmorganization/dept") +public class DepartmentController extends com.engine.organization.web.DepartmentController { +} diff --git a/src/com/engine/organization/entity/department/bo/DepartmentBO.java b/src/com/engine/organization/entity/department/bo/DepartmentBO.java new file mode 100644 index 00000000..da7bae34 --- /dev/null +++ b/src/com/engine/organization/entity/department/bo/DepartmentBO.java @@ -0,0 +1,77 @@ +package com.engine.organization.entity.department.bo; + +import com.engine.organization.entity.department.po.DepartmentPO; +import com.engine.organization.entity.department.vo.SingleDeptTreeVO; +import com.engine.organization.mapper.department.DepartmentMapper; +import com.engine.organization.mapper.employee.EmployeeMapper; +import com.engine.organization.util.db.MapperProxyFactory; +import org.apache.commons.collections.CollectionUtils; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/20 + * @Version V1.0 + **/ +public class DepartmentBO { + + public static List buildSingleDeptTreeVOS(List departmentPOs) { + + if (CollectionUtils.isEmpty(departmentPOs)) { + return Collections.emptyList(); + } + + + List singleDeptTreeVOS = departmentPOs.stream().map(e -> SingleDeptTreeVO.builder() + .id(e.getId()) + .deptName(e.getDeptName()) + .parentDeptName(getDeptNameById(e.getParentDept())) + .deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal())) + .children(recursiveData(e.getId())) + .build() + ).collect(Collectors.toList()); + + return singleDeptTreeVOS; + + } + + + public static String getDeptNameById(int id) { + return MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptNameById(id); + } + + public static String getEmployeeNameById(Long id) { + return MapperProxyFactory.getProxy(EmployeeMapper.class).getEmployeeNameById(id); + } + + + /** + * 递归获取 + * @param parentDeptId + * @return + */ + public static List recursiveData(long parentDeptId) { + List departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByPId(parentDeptId); + if (CollectionUtils.isEmpty(departmentPOS)) { + return Collections.emptyList(); + } + + List singleDeptTreeVOS = departmentPOS.stream().map(e -> SingleDeptTreeVO.builder() + .id(e.getId()) + .deptName(e.getDeptName()) + .parentDeptName(getDeptNameById(e.getParentDept())) + .deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal())) + .children(recursiveData(e.getId())) + .build() + ).collect(Collectors.toList()); + + return singleDeptTreeVOS; + } + + + +} diff --git a/src/com/engine/organization/entity/department/param/QuerySingleDeptListParam.java b/src/com/engine/organization/entity/department/param/QuerySingleDeptListParam.java new file mode 100644 index 00000000..a0dd33d0 --- /dev/null +++ b/src/com/engine/organization/entity/department/param/QuerySingleDeptListParam.java @@ -0,0 +1,23 @@ +package com.engine.organization.entity.department.param; + +import com.engine.organization.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/20 + * @Version V1.0 + **/ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class QuerySingleDeptListParam extends BaseQueryParam { + + private int parentComp; + +} diff --git a/src/com/engine/organization/entity/department/po/DepartmentPO.java b/src/com/engine/organization/entity/department/po/DepartmentPO.java new file mode 100644 index 00000000..e06c1a0b --- /dev/null +++ b/src/com/engine/organization/entity/department/po/DepartmentPO.java @@ -0,0 +1,49 @@ +package com.engine.organization.entity.department.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/19 + * @Version V1.0 + **/ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class DepartmentPO { + + private Long id; + + private String deptNo; + + private String deptName; + + private String deptNameShort; + + private int parentComp; + + private int parentDept; + + private int deptPrincipal; //部门负责人 + + private int showOrder; + + private String description; + + private int forbiddenTag; + + private Long creator; + + private int deleteType; + + private Date createTime; + + private Date updateTime; +} diff --git a/src/com/engine/organization/entity/department/vo/SingleDeptTreeVO.java b/src/com/engine/organization/entity/department/vo/SingleDeptTreeVO.java new file mode 100644 index 00000000..5055275b --- /dev/null +++ b/src/com/engine/organization/entity/department/vo/SingleDeptTreeVO.java @@ -0,0 +1,43 @@ +package com.engine.organization.entity.department.vo; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.organization.annotation.OrganizationTable; +import com.engine.organization.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/20 + * @Version V1.0 + **/ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@OrganizationTable(pageId = "01b397a9-638b-4d58-89c7-4a1d17f98656", + tableType = WeaTableType.NONE) +public class SingleDeptTreeVO { + + private Long id; + + @TableTitle(title = "部门名称", dataIndex = "deptName", key = "deptName") + private String deptName; + + @TableTitle(title = "上级部门", dataIndex = "parentDeptName", key = "parentDeptName") + private String parentDeptName; //上级部门 + + @TableTitle(title = "部门负责人", dataIndex = "deptPrincipalName", key = "deptPrincipalName") + private String deptPrincipalName; //部门负责人 + + //子节点 + private List children; + + + +} diff --git a/src/com/engine/organization/entity/employee/Employee.java b/src/com/engine/organization/entity/employee/Employee.java new file mode 100644 index 00000000..d64979c6 --- /dev/null +++ b/src/com/engine/organization/entity/employee/Employee.java @@ -0,0 +1,28 @@ +package com.engine.organization.entity.employee; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/20 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Employee { + + private Long employeeId; + + private String username; + + private Long departmentId; + + //.... + +} diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.java b/src/com/engine/organization/mapper/department/DepartmentMapper.java new file mode 100644 index 00000000..cbf2912b --- /dev/null +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.java @@ -0,0 +1,21 @@ +package com.engine.organization.mapper.department; + +import com.engine.organization.entity.department.po.DepartmentPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/20 + * @Version V1.0 + **/ +public interface DepartmentMapper { + + List getDeptListByCompId(@Param("parentComp") int parentComp); + + List getDeptListByPId(@Param("PId")Long PId); + + String getDeptNameById(@Param("id")int id); +} diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.xml b/src/com/engine/organization/mapper/department/DepartmentMapper.xml new file mode 100644 index 00000000..49ecedaa --- /dev/null +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/employee/EmployeeMapper.java b/src/com/engine/organization/mapper/employee/EmployeeMapper.java new file mode 100644 index 00000000..d6533bc5 --- /dev/null +++ b/src/com/engine/organization/mapper/employee/EmployeeMapper.java @@ -0,0 +1,17 @@ +package com.engine.organization.mapper.employee; + +import com.engine.organization.entity.department.po.DepartmentPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/20 + * @Version V1.0 + **/ +public interface EmployeeMapper { + + String getEmployeeNameById(@Param("employeeId") Long id); +} diff --git a/src/com/engine/organization/mapper/employee/EmployeeMapper.xml b/src/com/engine/organization/mapper/employee/EmployeeMapper.xml new file mode 100644 index 00000000..e00791d6 --- /dev/null +++ b/src/com/engine/organization/mapper/employee/EmployeeMapper.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/src/com/engine/organization/service/DepartmentService.java b/src/com/engine/organization/service/DepartmentService.java new file mode 100644 index 00000000..0a32073b --- /dev/null +++ b/src/com/engine/organization/service/DepartmentService.java @@ -0,0 +1,22 @@ +package com.engine.organization.service; + +import com.engine.organization.entity.department.param.QuerySingleDeptListParam; +import com.engine.organization.entity.department.vo.SingleDeptTreeVO; +import com.engine.organization.util.page.PageInfo; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/20 + * @Version V1.0 + **/ +public interface DepartmentService { + + /** + * 根据分部id获取部门tree + * 联查部门 + * @param param + * @return + */ + PageInfo getDeptListByPid(QuerySingleDeptListParam param); +} diff --git a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java new file mode 100644 index 00000000..3fdfca59 --- /dev/null +++ b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java @@ -0,0 +1,39 @@ +package com.engine.organization.service.impl; + +import com.engine.core.impl.Service; +import com.engine.organization.entity.department.bo.DepartmentBO; +import com.engine.organization.entity.department.param.QuerySingleDeptListParam; +import com.engine.organization.entity.department.po.DepartmentPO; +import com.engine.organization.entity.department.vo.SingleDeptTreeVO; +import com.engine.organization.mapper.department.DepartmentMapper; +import com.engine.organization.service.DepartmentService; +import com.engine.organization.util.db.MapperProxyFactory; +import com.engine.organization.util.page.PageInfo; +import com.engine.organization.util.page.PageUtil; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/20 + * @Version V1.0 + **/ +public class DepartmentServiceImpl extends Service implements DepartmentService { + + + @Override + public PageInfo getDeptListByPid(QuerySingleDeptListParam param) { + + //1.查询分部下所有部门 + PageUtil.start(param.getCurrent(),param.getPageSize()); + List departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByCompId(param.getParentComp()); + List singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS); + PageInfo pageInfos = new PageInfo<>(singleDeptTreeVOS,SingleDeptTreeVO.class); + pageInfos.setTotal(departmentPOS.size()); + pageInfos.setPageNum(param.getCurrent()); + pageInfos.setPageSize(param.getPageSize()); + + return pageInfos; + } +} diff --git a/src/com/engine/organization/web/DepartmentController.java b/src/com/engine/organization/web/DepartmentController.java new file mode 100644 index 00000000..d8b05372 --- /dev/null +++ b/src/com/engine/organization/web/DepartmentController.java @@ -0,0 +1,44 @@ +package com.engine.organization.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.organization.entity.department.param.QuerySingleDeptListParam; +import com.engine.organization.util.response.ReturnResult; +import com.engine.organization.wrapper.DepartmentWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/20 + * @Version V1.0 + **/ +public class DepartmentController { + + private DepartmentWrapper getDepartmentWrapper(User user) { + return ServiceUtil.getService(DepartmentWrapper.class,user); + } + + + @POST + @Path("/getDeptListByPid") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getDeptListByPid(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody QuerySingleDeptListParam querySingleDeptListParam) { + try { + User user = HrmUserVarify.getUser(request, response); + return getDepartmentWrapper(user).getDeptListByPid(querySingleDeptListParam); + }catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } +} diff --git a/src/com/engine/organization/wrapper/DepartmentWrapper.java b/src/com/engine/organization/wrapper/DepartmentWrapper.java new file mode 100644 index 00000000..114d5c50 --- /dev/null +++ b/src/com/engine/organization/wrapper/DepartmentWrapper.java @@ -0,0 +1,29 @@ +package com.engine.organization.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.organization.entity.department.param.QuerySingleDeptListParam; +import com.engine.organization.service.DepartmentService; +import com.engine.organization.service.impl.DepartmentServiceImpl; +import com.engine.organization.util.page.PageInfo; +import com.engine.organization.util.response.ReturnResult; +import com.engine.organization.entity.department.vo.SingleDeptTreeVO; +import weaver.hrm.User; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/20 + * @Version V1.0 + **/ +public class DepartmentWrapper extends Service { + + public DepartmentService getDepartmentService(User user) { + return ServiceUtil.getService(DepartmentServiceImpl.class,user); + } + + public ReturnResult getDeptListByPid(QuerySingleDeptListParam param) { + PageInfo singleDeptTreeVOS = getDepartmentService(user).getDeptListByPid(param); + return ReturnResult.successed(singleDeptTreeVOS); + } +} From 362b64ae661b5ba17f20ef8aa57c1ac506ca2ecb Mon Sep 17 00:00:00 2001 From: dxfeng Date: Fri, 20 May 2022 15:06:27 +0800 Subject: [PATCH 09/22] =?UTF-8?q?=E5=85=AC=E5=8F=B8/=E5=88=86=E9=83=A8=20?= =?UTF-8?q?=20=E6=8B=93=E5=B1=95=E8=A1=A8=20=E6=8B=93=E5=B1=95=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E8=A1=A8=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/extend/bo/ExtendInfoBO.java | 20 +- .../mapper/comp/CompExtDTMapper.java | 35 ++++ .../mapper/comp/CompExtDTMapper.xml | 18 ++ .../mapper/comp/CompExtMapper.java | 23 +++ .../mapper/comp/CompExtMapper.xml | 12 ++ .../organization/mapper/comp/CompMapper.java | 17 +- .../organization/mapper/comp/CompMapper.xml | 95 ++++++++- .../organization/service/CompService.java | 25 +++ .../service/impl/CompServiceImpl.java | 194 ++++++++++++++---- .../organization/web/CompController.java | 69 +++++++ .../organization/wrapper/CompWrapper.java | 31 +++ 11 files changed, 474 insertions(+), 65 deletions(-) create mode 100644 src/com/engine/organization/mapper/comp/CompExtDTMapper.java create mode 100644 src/com/engine/organization/mapper/comp/CompExtDTMapper.xml create mode 100644 src/com/engine/organization/mapper/comp/CompExtMapper.java create mode 100644 src/com/engine/organization/mapper/comp/CompExtMapper.xml diff --git a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java index fac9e9ec..50db87a4 100644 --- a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java +++ b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java @@ -18,7 +18,7 @@ import java.util.Map; public class ExtendInfoBO { // 封装对象为table组件 - public static List> convertInfoListToTable(List infoPOList, int operateType, boolean showLabel) { + public static List> convertInfoListToTable(List infoPOList, int viewAttr, boolean showLabel) { List> lsCol = new ArrayList>(); Map col = null; @@ -31,7 +31,7 @@ public class ExtendInfoBO { col.put("key", tmpkey); col.put("dataIndex", tmpkey); - col.put("com", getFieldDetialInfo(extendInfoPO, operateType, showLabel, width)); + col.put("com", getFieldDetialInfo(extendInfoPO, viewAttr, showLabel, width)); col.put("width", width + "%"); @@ -46,12 +46,12 @@ public class ExtendInfoBO { * 明细表字段 * * @param extendInfoPO - * @param operateType + * @param viewAttr * @return */ - private static List getFieldDetialInfo(ExtendInfoPO extendInfoPO, int operateType, boolean showLabel, int width) { + private static List getFieldDetialInfo(ExtendInfoPO extendInfoPO, int viewAttr, boolean showLabel, int width) { List ls = new ArrayList(); - FieldItem fieldItem = createField(extendInfoPO, operateType, showLabel, width); + FieldItem fieldItem = createField(extendInfoPO, viewAttr, showLabel, width); ls.add(fieldItem); return ls; } @@ -60,12 +60,12 @@ public class ExtendInfoBO { * 创建列表字段信息 * * @param extendInfoPO - * @param operateType + * @param viewAttr * @param showLabel * @param width * @return */ - private static FieldItem createField(ExtendInfoPO extendInfoPO, int operateType, boolean showLabel, int width) { + private static FieldItem createField(ExtendInfoPO extendInfoPO, int viewAttr, boolean showLabel, int width) { FieldItem fieldItem = new FieldItem(); if (showLabel) { fieldItem.setLabel(extendInfoPO.getFieldNameDesc()); @@ -76,8 +76,8 @@ public class ExtendInfoBO { fieldItem.setType(getFieldhtmltype(extendInfoPO.getControlType() + "")); fieldItem.setKey(extendInfoPO.getFieldName()); // 查看操作 全部设置为只读 - if (0 == operateType) { - fieldItem.setViewAttr(1); + if (1 == viewAttr) { + fieldItem.setViewAttr(viewAttr); } else { // 必填 if (1 == extendInfoPO.getIsrequired()) { @@ -98,7 +98,7 @@ public class ExtendInfoBO { * @param fieldhtmltype * @return */ - private static FieldType getFieldhtmltype(String fieldhtmltype) { + public static FieldType getFieldhtmltype(String fieldhtmltype) { FieldType fieldtype = null; if (fieldhtmltype.equals("1")) { fieldtype = FieldType.INPUT; diff --git a/src/com/engine/organization/mapper/comp/CompExtDTMapper.java b/src/com/engine/organization/mapper/comp/CompExtDTMapper.java new file mode 100644 index 00000000..3387a7ed --- /dev/null +++ b/src/com/engine/organization/mapper/comp/CompExtDTMapper.java @@ -0,0 +1,35 @@ +package com.engine.organization.mapper.comp; + +import org.apache.ibatis.annotations.MapKey; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/20 + * @version: 1.0 + */ +public interface CompExtDTMapper { + + /** + * 根据主表id,查询拓展表数据 + * + * @param tableName + * @param id + * @return + */ + @MapKey("id") + List> listCompExtDT(@Param("tableName") String tableName, @Param("id") long id, @Param("fields") String fields); + + /** + * 根据mainId删除指定明细表数据 + * + * @param tableName + * @param mainId + * @return + */ + int deleteByMainID(@Param("tableName") String tableName, @Param("mainId") String mainId); +} diff --git a/src/com/engine/organization/mapper/comp/CompExtDTMapper.xml b/src/com/engine/organization/mapper/comp/CompExtDTMapper.xml new file mode 100644 index 00000000..e48f947b --- /dev/null +++ b/src/com/engine/organization/mapper/comp/CompExtDTMapper.xml @@ -0,0 +1,18 @@ + + + + + delete + from ${tableName} + where mainid = #{id} + + + + + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/comp/CompExtMapper.java b/src/com/engine/organization/mapper/comp/CompExtMapper.java new file mode 100644 index 00000000..d5b66dd1 --- /dev/null +++ b/src/com/engine/organization/mapper/comp/CompExtMapper.java @@ -0,0 +1,23 @@ +package com.engine.organization.mapper.comp; + +import org.apache.ibatis.annotations.Param; + +import java.util.Map; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/20 + * @version: 1.0 + */ +public interface CompExtMapper { + + /** + * 根据主表id,查询主表拓展表数据 + * + * @param tableName + * @param id + * @return + */ + Map listCompExt(@Param("tableName") String tableName, @Param("fields") String fields, @Param("id") long id); +} diff --git a/src/com/engine/organization/mapper/comp/CompExtMapper.xml b/src/com/engine/organization/mapper/comp/CompExtMapper.xml new file mode 100644 index 00000000..3fa95837 --- /dev/null +++ b/src/com/engine/organization/mapper/comp/CompExtMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/comp/CompMapper.java b/src/com/engine/organization/mapper/comp/CompMapper.java index d2ef7201..1139155c 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.java +++ b/src/com/engine/organization/mapper/comp/CompMapper.java @@ -5,7 +5,6 @@ import org.apache.ibatis.annotations.Param; import java.util.Collection; import java.util.List; -import java.util.Map; /** * @description: TODO @@ -55,13 +54,21 @@ public interface CompMapper { /** - * 根据主表id,查询拓展表数据 + * 保存公司/分部基础信息 * - * @param tableName - * @param id + * @param compPO + * @return + */ + int insertIgnoreNull(CompPO compPO); + + + /** + * 更新主表内容 + * + * @param compPO * @return */ - List> listCompExtDT(@Param("tableName") String tableName, @Param("id") long id, @Param("fields") String fields); + int updateBaseComp(CompPO compPO); /** * 更新禁用标记 diff --git a/src/com/engine/organization/mapper/comp/CompMapper.xml b/src/com/engine/organization/mapper/comp/CompMapper.xml index 4fcda970..53f71cf7 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.xml +++ b/src/com/engine/organization/mapper/comp/CompMapper.xml @@ -50,6 +50,89 @@ and NVL(parent_company,'0')='0' + + INSERT INTO jcl_org_comp + + + creator, + + + delete_type, + + + create_time, + + + update_time, + + + comp_no, + + + comp_name, + + + comp_name_short, + + + parent_company, + + + org_code, + + + industry, + + + comp_principal, + + + description, + + forbidden_tag, + + + + #{creator}, + + + #{deleteType}, + + + #{createTime}, + + + #{updateTime}, + + + #{compNo}, + + + #{compName}, + + + #{compNameShort}, + + + #{parentCompany}, + + + #{orgCode}, + + + #{industry}, + + + #{compPrincipal}, + + + #{description}, + + 0, + + + - - - update jcl_org_comp @@ -120,4 +195,8 @@ + + + + \ 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 50c533f7..a33d7f79 100644 --- a/src/com/engine/organization/service/CompService.java +++ b/src/com/engine/organization/service/CompService.java @@ -21,6 +21,14 @@ public interface CompService { */ Map listPage(CompSearchParam params); + /** + * 保存公司/分部基础信息 + * + * @param params + * @return + */ + int saveBaseComp(CompSearchParam params); + /** * 更新禁用标记 * @@ -29,6 +37,15 @@ public interface CompService { int updateForbiddenTagById(CompSearchParam params); + /** + * 更新分部主表、拓展表、明细表 + * + * @param params + * @return + */ + int updateComp(Map params); + + /** * 根据ID批量删除 * @@ -67,6 +84,14 @@ public interface CompService { */ Map getCompBaseForm(Map params); + /** + * 获取拓展表单 + * + * @param params + * @return + */ + Map getCompExtForm(Map params); + /** * 获取新增表单 diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index 4408f5f3..f6d75f54 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.alibaba.fastjson.JSONObject; import com.api.browser.bean.BrowserBean; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; @@ -16,6 +17,8 @@ import com.engine.organization.entity.comp.param.CompSearchParam; import com.engine.organization.entity.comp.po.CompPO; import com.engine.organization.entity.extend.bo.ExtendInfoBO; import com.engine.organization.entity.extend.po.ExtendInfoPO; +import com.engine.organization.mapper.comp.CompExtDTMapper; +import com.engine.organization.mapper.comp.CompExtMapper; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.extend.ExtendGroupMapper; import com.engine.organization.mapper.extend.ExtendInfoMapper; @@ -30,6 +33,7 @@ import com.engine.organization.util.page.PageUtil; import org.apache.commons.collections4.CollectionUtils; import weaver.crm.Maint.SectorInfoComInfo; import weaver.general.StringUtil; +import weaver.general.Util; import weaver.hrm.resource.ResourceComInfo; import java.util.*; @@ -54,6 +58,14 @@ public class CompServiceImpl extends Service implements CompService { return MapperProxyFactory.getProxy(ExtendInfoMapper.class); } + private CompExtDTMapper getCompExtDTMapper() { + return MapperProxyFactory.getProxy(CompExtDTMapper.class); + } + + private CompExtMapper getCompExtMapper() { + return MapperProxyFactory.getProxy(CompExtMapper.class); + } + @Override public Map listPage(CompSearchParam params) { @@ -93,12 +105,50 @@ public class CompServiceImpl extends Service implements CompService { return datas; } + @Override + public int saveBaseComp(CompSearchParam params) { + List list = getCompMapper().listByNo(Util.null2String(params.getCompNo())); + OrganizationAssert.isEmpty(list, "编号不允许重复"); + CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID()); + return getCompMapper().insertIgnoreNull(compPO); + } + @Override public int updateForbiddenTagById(CompSearchParam params) { CompPO compPO = CompPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).build(); return getCompMapper().updateForbiddenTagById(compPO); } + @Override + public int updateComp(Map params) { + System.out.println(params); + CompSearchParam param = JSONObject.parseObject(JSONObject.toJSONString(params), CompSearchParam.class); + System.out.println(param); + + // TODO 更新主表数据 + + // 获取分部明细表的所有拓展列 + String tableName = "JCL_ORG_COMPEXT_DT1"; + List infoPOList = getExtendInfoMapper().listFields("1", "", tableName); + List dtFields = infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList()); + + List> insertList = new ArrayList<>(); + System.out.println(dtFields); + // TODO 删除明细表数据 + // 处理明细表数据 + int rowNum = Util.getIntValue((String) params.get("rownum")); + for (int i = 0; i < rowNum; i++) { + Map map = new HashMap<>(); + for (String dtField : dtFields) { + map.put(dtField, params.get(dtField + "_" + i)); + } + insertList.add(map); + } + System.out.println(insertList); + + return 0; + } + @Override public int deleteByIds(Collection ids) { OrganizationAssert.notEmpty(ids, "请选择要删除的数据"); @@ -186,7 +236,7 @@ public class CompServiceImpl extends Service implements CompService { @Override public Map getCompBaseForm(Map params) { - OrganizationAssert.notNull(params.get("operateType"), "请标识操作类型"); + OrganizationAssert.notNull(params.get("viewAttr"), "请标识操作类型"); List conditionItems = new ArrayList<>(); // 编号 SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "编号", "compNo"); @@ -207,7 +257,7 @@ public class CompServiceImpl extends Service implements CompService { // 负责人 SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "负责人", "1", "compPrincipal", ""); // 说明 - SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 17, true, 2, 60, "说明", "description"); + SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 2, 60, "说明", "description"); conditionItems.add(compNoItem); @@ -219,44 +269,43 @@ public class CompServiceImpl extends Service implements CompService { conditionItems.add(compPrincipalItem); conditionItems.add(descriptionItem); - // 0 查看 1新增 2编辑 - int operateType = Integer.parseInt((String) params.get("operateType")); + // 2编辑 1查看 + int viewAttr = Integer.parseInt((String) params.get("viewAttr")); 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); - } + // 赋值 + 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 (1 == viewAttr) { + for (SearchConditionItem item : conditionItems) { + item.setViewAttr(viewAttr); } } @@ -276,7 +325,7 @@ public class CompServiceImpl extends Service implements CompService { resultMap.put("buttons", buttonsMap); resultMap.put("conditions", conditionsMap); resultMap.put("id", id); - resultMap.put("tables", getExtendTables(id, operateType, false)); + resultMap.put("tables", getExtendTables(id, viewAttr, false)); Map apiDatas = new HashMap<>(); apiDatas.put("result", resultMap); @@ -284,6 +333,67 @@ public class CompServiceImpl extends Service implements CompService { return apiDatas; } + @Override + public Map getCompExtForm(Map params) { + Map apiDatas = new HashMap<>(); + List addGroups = new ArrayList<>(); + List conditionItems = new ArrayList<>(); + // 分组名称 + String groupId = (String) params.get("viewCondition"); + // 2编辑 1查看 + int viewAttr = Integer.parseInt((String) params.get("viewAttr")); + long id = Long.parseLong((String) params.get("id")); + OrganizationAssert.notNull(groupId, "请选择对应的拓展页"); + String tableName = "JCL_ORG_COMPEXT"; + List infoPOList = getExtendInfoMapper().listFields("1", groupId, tableName); + String fields = infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); + Map compExtMap = getCompExtMapper().listCompExt(tableName, fields, id); + + // 组装拓展页内容 + for (ExtendInfoPO extendInfoPO : infoPOList) { + SearchConditionItem item = null; + switch (ExtendInfoBO.getFieldhtmltype(extendInfoPO.getControlType() + "")) { + case INPUT: + item = OrganizationFormItemUtil.inputItem(user, 2, 16, 1, 50, extendInfoPO.getFieldNameDesc(), extendInfoPO.getFieldName()); + item.setValue(compExtMap.get(extendInfoPO.getFieldName())); + break; + case TEXTAREA: + item = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 1, 60, extendInfoPO.getFieldNameDesc(), extendInfoPO.getFieldName()); + item.setValue(compExtMap.get(extendInfoPO.getFieldName())); + break; + case BROWSER: + // TODO + // item=OrganizationFormItemUtil.browserItem() + break; + case CHECKBOX: + item = OrganizationFormItemUtil.checkboxItem(user, 2, 16, 1, true, extendInfoPO.getFieldNameDesc(), extendInfoPO.getFieldName()); + item.setValue(compExtMap.get(extendInfoPO.getFieldName())); + break; + case SELECT: + // TODO + // item = OrganizationFormItemUtil.selectItem(); + break; + case FILEUPLOAD: + case TEXT: + default: + break; + } + if (null != item) { + // 根据viewAttr设置编辑或只读 + item.setViewAttr(viewAttr); + // 是否必填 + if (1 == extendInfoPO.getIsrequired()) { + item.setViewAttr(3); + item.setRules("required|string"); + } + conditionItems.add(item); + } + } + addGroups.add(new SearchConditionGroup(getExtendGroupMapper().getGroupNameById(groupId), true, conditionItems)); + apiDatas.put("condition", addGroups); + return apiDatas; + } + @Override public Map getCompSaveForm() { Map apiDatas = new HashMap<>(); @@ -308,7 +418,7 @@ public class CompServiceImpl extends Service implements CompService { // 负责人 SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "负责人", "1", "compPrincipal", ""); // 说明 - SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 17, true, 2, 60, "说明", "description"); + SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 2, 60, "说明", "description"); conditionItems.add(compNoItem); conditionItems.add(compNameItem); @@ -378,7 +488,7 @@ public class CompServiceImpl extends Service implements CompService { * * @return */ - private List> getExtendTables(long id, int operateType, boolean showLabel) { + private List> getExtendTables(long id, int viewAttr, boolean showLabel) { List> tables = new ArrayList<>(); String tableName = "JCL_ORG_COMPEXT_DT1"; // 查询所有分布模块,拓展明细表信息 @@ -390,11 +500,11 @@ public class CompServiceImpl extends Service implements CompService { 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("columns", ExtendInfoBO.convertInfoListToTable(entry.getValue(), viewAttr, showLabel)); tabinfoMap.put("rownum", "rownum"); String fields = entry.getValue().stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); - tabinfoMap.put("datas", getCompMapper().listCompExtDT(tableName, id, fields)); + tabinfoMap.put("datas", getCompExtDTMapper().listCompExtDT(tableName, id, fields)); tableMap.put("tabinfo", tabinfoMap); tables.add(tableMap); } diff --git a/src/com/engine/organization/web/CompController.java b/src/com/engine/organization/web/CompController.java index d4a7dcf5..21b32223 100644 --- a/src/com/engine/organization/web/CompController.java +++ b/src/com/engine/organization/web/CompController.java @@ -51,6 +51,27 @@ 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) { + try { + User user = HrmUserVarify.getUser(request, response); + return ReturnResult.successed(getCompWrapper(user).saveBaseComp(params)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + /** * 更新禁用标记 * @@ -71,6 +92,26 @@ public class CompController { } } + /** + * 更新禁用标记 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/updateComp") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult updateComp(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + return ReturnResult.successed(getCompWrapper(user).updateComp(map)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + /** * 根据ID批量删除数据 @@ -151,6 +192,34 @@ public class CompController { } } + /** + * 获取拓展表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getCompExtForm") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getCompExtForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + return ReturnResult.successed(getCompWrapper(user).getCompExtForm(map)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + + + /** + * 新增保存表单 + * + * @param request + * @param response + * @return + */ @GET @Path("/getCompSaveForm") @Produces(MediaType.APPLICATION_JSON) diff --git a/src/com/engine/organization/wrapper/CompWrapper.java b/src/com/engine/organization/wrapper/CompWrapper.java index 699a6821..45a4d40f 100644 --- a/src/com/engine/organization/wrapper/CompWrapper.java +++ b/src/com/engine/organization/wrapper/CompWrapper.java @@ -31,6 +31,17 @@ public class CompWrapper extends Service { return getCompService(user).listPage(params); } + + /** + * 保存公司/分部基础信息 + * + * @param params + * @return + */ + public int saveBaseComp(CompSearchParam params) { + return getCompService(user).saveBaseComp(params); + } + /** * 更新禁用标记 * @@ -40,6 +51,16 @@ public class CompWrapper extends Service { return getCompService(user).updateForbiddenTagById(params); } + /** + * 更新分部主表、拓展表、明细表 + * + * @param params + * @return + */ + public int updateComp(Map params) { + return getCompService(user).updateComp(params); + } + /** * 根据ID批量删除 * @@ -78,6 +99,16 @@ public class CompWrapper extends Service { return getCompService(user).getCompBaseForm(params); } + /** + * 获取拓展表单 + * + * @param params + * @return + */ + public Map getCompExtForm(Map params) { + return getCompService(user).getCompExtForm(params); + } + /** * 新增表单 * From 0b9a5878ebfccc91d72338789c06e63ec144f7f2 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Fri, 20 May 2022 15:52:25 +0800 Subject: [PATCH 10/22] =?UTF-8?q?=E5=85=AC=E5=8F=B8/=E5=88=86=E9=83=A8=20?= =?UTF-8?q?=20=E6=8B=93=E5=B1=95=E8=A1=A8=20=E6=8B=93=E5=B1=95=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E8=A1=A8=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/comp/CompExtDTMapper.java | 10 ++++++- .../mapper/comp/CompExtDTMapper.xml | 17 +++++++++-- .../organization/mapper/comp/CompMapper.xml | 16 +++++++++-- .../service/impl/CompServiceImpl.java | 28 +++++++++++-------- 4 files changed, 55 insertions(+), 16 deletions(-) diff --git a/src/com/engine/organization/mapper/comp/CompExtDTMapper.java b/src/com/engine/organization/mapper/comp/CompExtDTMapper.java index 3387a7ed..31f05c9f 100644 --- a/src/com/engine/organization/mapper/comp/CompExtDTMapper.java +++ b/src/com/engine/organization/mapper/comp/CompExtDTMapper.java @@ -24,6 +24,14 @@ public interface CompExtDTMapper { @MapKey("id") List> listCompExtDT(@Param("tableName") String tableName, @Param("id") long id, @Param("fields") String fields); + /** + * 插入主表明细表 + * + * @param map + * @return + */ + int insertCompExtDT(@Param("tableName") String tableName, @Param("map") Map map); + /** * 根据mainId删除指定明细表数据 * @@ -31,5 +39,5 @@ public interface CompExtDTMapper { * @param mainId * @return */ - int deleteByMainID(@Param("tableName") String tableName, @Param("mainId") String mainId); + int deleteByMainID(@Param("tableName") String tableName, @Param("mainId") long mainId); } diff --git a/src/com/engine/organization/mapper/comp/CompExtDTMapper.xml b/src/com/engine/organization/mapper/comp/CompExtDTMapper.xml index e48f947b..4ecb3ac4 100644 --- a/src/com/engine/organization/mapper/comp/CompExtDTMapper.xml +++ b/src/com/engine/organization/mapper/comp/CompExtDTMapper.xml @@ -1,11 +1,24 @@ + + + + insert into ${tableName} ( + + ${key} + + ) + values ( + + #{value} + + ) + delete from ${tableName} - where mainid = #{id} - + where mainid = #{mainId} select ${fields} from ${tableName} where delete_type = 0 and id = #{id} + + \ No newline at end of file diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index 77db9804..78d72c6c 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -46,6 +46,22 @@ import java.util.stream.Collectors; * @version: 1.0 */ public class CompServiceImpl extends Service implements CompService { + /** + * 分组类型 + * 1:分部 + * 2:部门 + * 3:岗位 + */ + private static final String EXTEND_TYPE = "1"; + /** + * 主表拓展表 + */ + private static final String JCL_ORG_COMPEXT = "JCL_ORG_COMPEXT"; + /** + * 明细表拓展表 + */ + private static final String JCL_ORG_COMPEXT_DT1 = "JCL_ORG_COMPEXT_DT1"; + private CompMapper getCompMapper() { return MapperProxyFactory.getProxy(CompMapper.class); } @@ -122,18 +138,41 @@ public class CompServiceImpl extends Service implements CompService { @Override public int updateComp(Map params) { CompSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), CompSearchParam.class); - // 更新主表数据 + String groupId = (String) params.get("viewCondition"); + int updateBaseComp = 0; CompPO compPO = CompBO.convertParamToPO(searchParam, (long) user.getUID()); - int updateBaseComp = getCompMapper().updateBaseComp(compPO); + if (StringUtil.isEmpty(groupId) || "0".equals(groupId)) { + // 更新主表数据 + updateBaseComp = getCompMapper().updateBaseComp(compPO); + } else { + List extInfoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, groupId, JCL_ORG_COMPEXT); + List extFields = extInfoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList()); + Map map = new HashMap<>(); + for (String dtField : extFields) { + map.put(dtField, params.get(dtField)); + } + // 判断更新还是插入 + int count = getCompExtMapper().countCompExtById(JCL_ORG_COMPEXT, searchParam.getId()); + if (count > 0) { + map.put("update_time", compPO.getUpdateTime()); + updateBaseComp = getCompExtMapper().updateCompExt(JCL_ORG_COMPEXT, compPO.getId(), map); + } else { + map.put("creator", compPO.getCreator()); + map.put("delete_type", compPO.getDeleteType()); + map.put("create_time", compPO.getCreateTime()); + map.put("update_time", compPO.getUpdateTime()); + map.put("id", compPO.getId()); + updateBaseComp = getCompExtMapper().insertCompExt(JCL_ORG_COMPEXT, map); + } + } // 获取分部明细表的所有拓展列 - String tableName = "JCL_ORG_COMPEXT_DT1"; - List infoPOList = getExtendInfoMapper().listFields("1", "", tableName); - List dtFields = infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList()); + List dtInfoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, "", JCL_ORG_COMPEXT_DT1); + List dtFields = dtInfoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList()); List> insertList = new ArrayList<>(); // 删除明细表数据 - getCompExtDTMapper().deleteByMainID(tableName, compPO.getId()); + getCompExtDTMapper().deleteByMainID(JCL_ORG_COMPEXT_DT1, compPO.getId()); // 处理明细表数据 int rowNum = Util.getIntValue((String) params.get("rownum")); for (int i = 0; i < rowNum; i++) { @@ -150,7 +189,7 @@ public class CompServiceImpl extends Service implements CompService { } // 更新拓展表数据 for (Map map : insertList) { - getCompExtDTMapper().insertCompExtDT(tableName, map); + getCompExtDTMapper().insertCompExtDT(JCL_ORG_COMPEXT_DT1, map); } return updateBaseComp; @@ -235,21 +274,17 @@ public class CompServiceImpl extends Service implements CompService { buttonsMap.put("hasEdit", true); buttonsMap.put("hasSave", true); - HashMap conditionsMap = new HashMap<>(); + List addGroups = new ArrayList<>(); if (StringUtil.isEmpty(groupId) || "0".equals(groupId)) { - conditionsMap.put("items", getBaseForm(viewAttr, id)); - conditionsMap.put("title", "基本信息"); + addGroups.add(new SearchConditionGroup("基本信息", true, getBaseForm(viewAttr, id))); } else { - conditionsMap.put("items", getExtForm(viewAttr, id, groupId)); - conditionsMap.put("title", getExtendGroupMapper().getGroupNameById(groupId)); + addGroups.add(new SearchConditionGroup(getExtendGroupMapper().getGroupNameById(groupId), true, getExtForm(viewAttr, id, groupId))); } - conditionsMap.put("hide", false); - conditionsMap.put("defaultshow", true); HashMap resultMap = new HashMap<>(); resultMap.put("buttons", buttonsMap); - resultMap.put("conditions", conditionsMap); + resultMap.put("conditions", addGroups); resultMap.put("id", id); resultMap.put("tabInfo", getTabInfo()); resultMap.put("tables", getExtendTables(id, viewAttr, false)); @@ -357,9 +392,8 @@ public class CompServiceImpl extends Service implements CompService { */ private List> getExtendTables(long id, int viewAttr, boolean showLabel) { List> tables = new ArrayList<>(); - String tableName = "JCL_ORG_COMPEXT_DT1"; // 查询所有分布模块,拓展明细表信息 - List infoPOList = getExtendInfoMapper().listFields("1", "", tableName); + List infoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, "", JCL_ORG_COMPEXT_DT1); Map> groupMap = infoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId)); // 遍历Map,组装数据 for (Map.Entry> entry : groupMap.entrySet()) { @@ -371,7 +405,7 @@ public class CompServiceImpl extends Service implements CompService { tabinfoMap.put("rownum", "rownum"); String fields = entry.getValue().stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); - tabinfoMap.put("datas", getCompExtDTMapper().listCompExtDT(tableName, id, fields)); + tabinfoMap.put("datas", getCompExtDTMapper().listCompExtDT(JCL_ORG_COMPEXT_DT1, id, fields)); tableMap.put("tabinfo", tabinfoMap); tables.add(tableMap); } @@ -406,7 +440,7 @@ public class CompServiceImpl extends Service implements CompService { // 基本信息 topTabs.add(TopTab.builder().color("#000000").groupId("0").showcount(false).title("基本信息").viewCondition("0").build()); - List infoPOList = getExtendInfoMapper().listFields("1", "", "JCL_ORG_COMPEXT"); + List infoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, "", JCL_ORG_COMPEXT); List extendGroups = infoPOList.stream().map(ExtendInfoPO::getExtendGroupId).collect(Collectors.toList()); // 拓展信息 if (CollectionUtils.isNotEmpty(extendGroups)) { @@ -510,10 +544,9 @@ public class CompServiceImpl extends Service implements CompService { // 2编辑 1查看 OrganizationAssert.notNull(groupId, "请选择对应的拓展页"); - String tableName = "JCL_ORG_COMPEXT"; - List infoPOList = getExtendInfoMapper().listFields("1", groupId, tableName); + List infoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, groupId, JCL_ORG_COMPEXT); String fields = infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); - Map compExtMap = getCompExtMapper().listCompExt(tableName, fields, id); + Map compExtMap = getCompExtMapper().listCompExt(JCL_ORG_COMPEXT, fields, id); // 组装拓展页内容 for (ExtendInfoPO extendInfoPO : infoPOList) { From 4e391c5f7c5ba41059a4b9757b8fccd13bb6cad7 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Fri, 20 May 2022 18:03:27 +0800 Subject: [PATCH 14/22] =?UTF-8?q?=E5=85=AC=E5=8F=B8/=E5=88=86=E9=83=A8=20?= =?UTF-8?q?=E5=88=97=E8=A1=A8=20=E5=AD=97=E6=AE=B5=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/entity/comp/bo/CompBO.java | 18 +++++++++++++++--- .../entity/comp/dto/CompListDTO.java | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/com/engine/organization/entity/comp/bo/CompBO.java b/src/com/engine/organization/entity/comp/bo/CompBO.java index 05302028..c23e8dee 100644 --- a/src/com/engine/organization/entity/comp/bo/CompBO.java +++ b/src/com/engine/organization/entity/comp/bo/CompBO.java @@ -4,6 +4,9 @@ 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 org.apache.commons.collections.CollectionUtils; +import weaver.crm.Maint.SectorInfoComInfo; +import weaver.general.StringUtil; +import weaver.hrm.resource.ResourceComInfo; import java.util.*; import java.util.stream.Collectors; @@ -35,8 +38,8 @@ public class CompBO { .parentCompany(e.getParentCompany()) .parentCompName(null == poMaps.get(e.getParentCompany()) ? "" : poMaps.get(e.getParentCompany()).getCompName()) .orgCode(e.getOrgCode()) - .industry(e.getIndustry()) - .compPrincipal(e.getCompPrincipal()) + .industry(new SectorInfoComInfo().getSectorInfoname(e.getIndustry() + "")) + .compPrincipal(getUserNameById(e.getCompPrincipal() + "")) .forbiddenTag(e.getForbiddenTag()) .build() ).collect(Collectors.toList()); @@ -87,5 +90,14 @@ public class CompBO { } } - + private static String getUserNameById(String userId) { + try { + if (StringUtil.isEmpty(userId)) { + return ""; + } + return new ResourceComInfo().getLastname(userId); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } diff --git a/src/com/engine/organization/entity/comp/dto/CompListDTO.java b/src/com/engine/organization/entity/comp/dto/CompListDTO.java index 56fe61bb..1c1892b0 100644 --- a/src/com/engine/organization/entity/comp/dto/CompListDTO.java +++ b/src/com/engine/organization/entity/comp/dto/CompListDTO.java @@ -71,13 +71,13 @@ public class CompListDTO { * 行业 */ @TableTitle(title = "行业", dataIndex = "industry", key = "industry") - private Integer industry; + private String industry; /** * 负责人 */ @TableTitle(title = "负责人", dataIndex = "compPrincipal", key = "compPrincipal") - private Integer compPrincipal; + private String compPrincipal; /** * 禁用标记 From f5561b8e7db29ad983cd2c7e94b092f3979b2487 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Mon, 23 May 2022 17:33:10 +0800 Subject: [PATCH 15/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E6=80=BB=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/organization/service/impl/CompServiceImpl.java | 3 ++- .../organization/service/impl/DepartmentServiceImpl.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index 78d72c6c..22b1b10d 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -88,6 +88,7 @@ public class CompServiceImpl extends Service implements CompService { Map datas = new HashMap<>(); PageUtil.start(params.getCurrent(), params.getPageSize()); List parentList = getCompMapper().listParent(); + PageInfo pageInfo = new PageInfo<>(parentList); List list = new ArrayList<>(); list.addAll(parentList); @@ -100,7 +101,7 @@ public class CompServiceImpl extends Service implements CompService { List compListDTOS = CompBO.buildCompDTOList(list, filterList); PageInfo pageInfos = new PageInfo<>(compListDTOS, CompListDTO.class); - pageInfos.setTotal(pageInfos.getTotal()); + pageInfos.setTotal(pageInfo.getTotal()); pageInfos.setPageNum(params.getCurrent()); pageInfos.setPageSize(params.getPageSize()); diff --git a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java index 3fdfca59..44c9a89d 100644 --- a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java +++ b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java @@ -28,9 +28,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService //1.查询分部下所有部门 PageUtil.start(param.getCurrent(),param.getPageSize()); List departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByCompId(param.getParentComp()); + PageInfo pageInfo = new PageInfo<>(departmentPOS); List singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS); PageInfo pageInfos = new PageInfo<>(singleDeptTreeVOS,SingleDeptTreeVO.class); - pageInfos.setTotal(departmentPOS.size()); + pageInfos.setTotal(pageInfo.getTotal()); pageInfos.setPageNum(param.getCurrent()); pageInfos.setPageSize(param.getPageSize()); From cbd33dbd3b0f6fd960677f37a34b58f1734222da Mon Sep 17 00:00:00 2001 From: dxfeng Date: Mon, 23 May 2022 17:46:37 +0800 Subject: [PATCH 16/22] =?UTF-8?q?=E9=83=A8=E9=97=A8=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E5=88=97=E8=A1=A8=20=E5=AD=97=E6=AE=B5=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/department/bo/DepartmentBO.java | 101 ++++++++++-- .../department/dto/DepartmentListDTO.java | 98 +++++++++++ .../department/param/DeptSearchParam.java | 37 +++++ .../entity/department/po/DepartmentPO.java | 10 +- .../mapper/department/DepartmentMapper.java | 24 ++- .../mapper/department/DepartmentMapper.xml | 155 +++++++++++++++++- .../service/DepartmentService.java | 14 ++ .../service/impl/CompServiceImpl.java | 6 +- .../service/impl/DepartmentServiceImpl.java | 103 +++++++++++- .../web/DepartmentController.java | 29 +++- .../webservice/CustomBrowserService.java | 30 ++++ .../webservice/CustomBrowserServiceImpl.java | 53 ++++++ .../wrapper/DepartmentWrapper.java | 15 +- 13 files changed, 638 insertions(+), 37 deletions(-) create mode 100644 src/com/engine/organization/entity/department/dto/DepartmentListDTO.java create mode 100644 src/com/engine/organization/entity/department/param/DeptSearchParam.java create mode 100644 src/com/engine/organization/webservice/CustomBrowserService.java create mode 100644 src/com/engine/organization/webservice/CustomBrowserServiceImpl.java diff --git a/src/com/engine/organization/entity/department/bo/DepartmentBO.java b/src/com/engine/organization/entity/department/bo/DepartmentBO.java index da7bae34..df1d5b60 100644 --- a/src/com/engine/organization/entity/department/bo/DepartmentBO.java +++ b/src/com/engine/organization/entity/department/bo/DepartmentBO.java @@ -1,5 +1,7 @@ package com.engine.organization.entity.department.bo; +import com.engine.organization.entity.department.dto.DepartmentListDTO; +import com.engine.organization.entity.department.param.DeptSearchParam; import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.department.vo.SingleDeptTreeVO; import com.engine.organization.mapper.department.DepartmentMapper; @@ -7,8 +9,7 @@ import com.engine.organization.mapper.employee.EmployeeMapper; import com.engine.organization.util.db.MapperProxyFactory; import org.apache.commons.collections.CollectionUtils; -import java.util.Collections; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -19,7 +20,62 @@ import java.util.stream.Collectors; **/ public class DepartmentBO { - public static List buildSingleDeptTreeVOS(List departmentPOs) { + public static List buildDeptDTOList(Collection list, List filterList) { + // 搜索结果为空,直接返回空 + if (CollectionUtils.isEmpty(filterList)) { + return Collections.emptyList(); + } + // 递归添加父级数据 + Map poMaps = list.stream().collect(Collectors.toMap(item -> item.getId(), item -> item)); + List addedList = new ArrayList<>(); + for (DepartmentPO po : filterList) { + dealParentData(addedList, po, poMaps); + } + + List dtoList = addedList.stream().map(e -> DepartmentListDTO.builder() + .id(e.getId()) + .deptNo(e.getDeptNo()) + .deptName(e.getDeptName()) + .deptNameShort(e.getDeptNameShort()) + .parentComp(e.getParentComp() + "")// 命名 + .parentDept(e.getParentDept()) + .parentDeptName(null == poMaps.get(e.getParentDept()) ? "" : poMaps.get(e.getParentDept()).getDeptName()) + .deptPrincipal(getEmployeeNameById((long) e.getDeptPrincipal())) + .showOrder(e.getShowOrder()) + .forbiddenTag(e.getForbiddenTag()) + .build() + ).collect(Collectors.toList()); + Map> collects = dtoList.stream().filter(item -> null != item.getParentDept() && 0 != item.getParentDept()).collect(Collectors.groupingBy(DepartmentListDTO::getParentDept)); + System.out.println(collects); + return dtoList.stream().map(e -> { + System.out.println(e.getId()); + System.out.println(collects.get(e.getId())); + e.setChildren(collects.get(e.getId())); + return e; + }).filter(item -> null == item.getParentDept() || 0 == item.getParentDept()).collect(Collectors.toList()); + } + + public static DepartmentPO convertParamsToPO(DeptSearchParam param, Long employeeId) { + if (null == param) { + return null; + } + return DepartmentPO.builder() + .id(param.getId() == null ? 0 : param.getId()) + .deptNo(param.getDeptNo()) + .deptName(param.getDeptName()) + .deptNameShort(param.getDeptNameShort()) + .parentComp(param.getParentComp()) + .parentDept(param.getParentDept()) + .deptPrincipal(param.getDeptPrincipal()) + .showOrder(param.getShowOrder()) + .forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1) + .deleteType(0) + .createTime(new Date()) + .updateTime(new Date()) + .creator(employeeId).build(); + } + + public static List buildSingleDeptTreeVOS(List departmentPOs) { if (CollectionUtils.isEmpty(departmentPOs)) { return Collections.emptyList(); @@ -29,7 +85,7 @@ public class DepartmentBO { List singleDeptTreeVOS = departmentPOs.stream().map(e -> SingleDeptTreeVO.builder() .id(e.getId()) .deptName(e.getDeptName()) - .parentDeptName(getDeptNameById(e.getParentDept())) + .parentDeptName(getDeptNameById(e.getParentDept().intValue())) .deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal())) .children(recursiveData(e.getId())) .build() @@ -40,8 +96,8 @@ public class DepartmentBO { } - public static String getDeptNameById(int id) { - return MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptNameById(id); + public static String getDeptNameById(Integer id) { + return MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptNameById(id); } public static String getEmployeeNameById(Long id) { @@ -49,8 +105,26 @@ public class DepartmentBO { } + /** + * 递归获取查询后数据的父级数据 + * + * @param addedList + * @param po + * @param poMaps + */ + private static void dealParentData(List addedList, DepartmentPO po, Map poMaps) { + if (!addedList.contains(po)) { + addedList.add(po); + } + DepartmentPO parentPO = poMaps.get(po.getParentDept()); + if (null != parentPO) { + dealParentData(addedList, parentPO, poMaps); + } + } + /** * 递归获取 + * * @param parentDeptId * @return */ @@ -61,17 +135,16 @@ public class DepartmentBO { } List singleDeptTreeVOS = departmentPOS.stream().map(e -> SingleDeptTreeVO.builder() - .id(e.getId()) - .deptName(e.getDeptName()) - .parentDeptName(getDeptNameById(e.getParentDept())) - .deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal())) - .children(recursiveData(e.getId())) - .build() - ).collect(Collectors.toList()); + .id(e.getId()) + .deptName(e.getDeptName()) + .parentDeptName(getDeptNameById(e.getParentDept().intValue())) + .deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal())) + .children(recursiveData(e.getId())) + .build() + ).collect(Collectors.toList()); return singleDeptTreeVOS; } - } diff --git a/src/com/engine/organization/entity/department/dto/DepartmentListDTO.java b/src/com/engine/organization/entity/department/dto/DepartmentListDTO.java new file mode 100644 index 00000000..1731a5da --- /dev/null +++ b/src/com/engine/organization/entity/department/dto/DepartmentListDTO.java @@ -0,0 +1,98 @@ +package com.engine.organization.entity.department.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.organization.annotation.OrganizationTable; +import com.engine.organization.annotation.OrganizationTableOperate; +import com.engine.organization.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/19 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@OrganizationTable(pageId = "96f2bb0d-da73-11ec-a0da-00ffcbed7508", + tableType = WeaTableType.NONE, + operates = { + @OrganizationTableOperate(index = "0", text = "编辑"), + @OrganizationTableOperate(index = "1", text = "删除"), + @OrganizationTableOperate(index = "2", text = "合并"), + @OrganizationTableOperate(index = "3", text = "转移"), + @OrganizationTableOperate(index = "4", text = "联查岗位"), + @OrganizationTableOperate(index = "4", text = "联查人员") + }) +public class DepartmentListDTO { + + private Long id; + + /** + * 编号 + */ + @TableTitle(title = "编号", dataIndex = "deptNo", key = "deptNo") + private String deptNo; + + /** + * 名称 + */ + @TableTitle(title = "名称", dataIndex = "deptName", key = "deptName") + private String deptName; + + /** + * 简称 + */ + @TableTitle(title = "简称", dataIndex = "deptNameShort", key = "deptNameShort") + private String deptNameShort; + + /** + * 所属分部 + */ + @TableTitle(title = "所属分部", dataIndex = "parentComp", key = "parentComp") + private String parentComp; + + /** + * 上级部门 + */ + @TableTitle(title = "上级部门", dataIndex = "parentDeptName", key = "parentDeptName") + private String parentDeptName; + + private Long parentDept; + + /** + * 部门负责人 + */ + @TableTitle(title = "部门负责人", dataIndex = "deptPrincipal", key = "deptPrincipal") + private String deptPrincipal; + + /** + * 显示顺序 + */ + @TableTitle(title = "显示顺序", dataIndex = "showOrder", key = "showOrder") + private int showOrder; + + /** + * 说明 + */ + @TableTitle(title = "说明", dataIndex = "description", key = "description") + private String description; + + /** + * 禁用标记 + */ + @TableTitle(title = "禁用标记", dataIndex = "forbiddenTag", key = "forbiddenTag") + private int forbiddenTag; + + /** + * 子节点 + */ + private List children; +} diff --git a/src/com/engine/organization/entity/department/param/DeptSearchParam.java b/src/com/engine/organization/entity/department/param/DeptSearchParam.java new file mode 100644 index 00000000..75004134 --- /dev/null +++ b/src/com/engine/organization/entity/department/param/DeptSearchParam.java @@ -0,0 +1,37 @@ +package com.engine.organization.entity.department.param; + +import com.engine.organization.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/23 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class DeptSearchParam extends BaseQueryParam { + private Long id; + + private String deptNo; + + private String deptName; + + private String deptNameShort; + + private Long parentComp; + + private Long parentDept; + + private Integer deptPrincipal; + + private Integer showOrder; + + private Boolean forbiddenTag; +} diff --git a/src/com/engine/organization/entity/department/po/DepartmentPO.java b/src/com/engine/organization/entity/department/po/DepartmentPO.java index e06c1a0b..512b0367 100644 --- a/src/com/engine/organization/entity/department/po/DepartmentPO.java +++ b/src/com/engine/organization/entity/department/po/DepartmentPO.java @@ -27,17 +27,17 @@ public class DepartmentPO { private String deptNameShort; - private int parentComp; + private Long parentComp; - private int parentDept; + private Long parentDept; - private int deptPrincipal; //部门负责人 + private Integer deptPrincipal; //部门负责人 - private int showOrder; + private Integer showOrder; private String description; - private int forbiddenTag; + private Integer forbiddenTag; private Long creator; diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.java b/src/com/engine/organization/mapper/department/DepartmentMapper.java index cbf2912b..f11d7f57 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.java +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.java @@ -3,6 +3,7 @@ package com.engine.organization.mapper.department; import com.engine.organization.entity.department.po.DepartmentPO; import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; /** @@ -15,7 +16,26 @@ public interface DepartmentMapper { List getDeptListByCompId(@Param("parentComp") int parentComp); - List getDeptListByPId(@Param("PId")Long PId); + List getDeptListByPId(@Param("PId") Long PId); - String getDeptNameById(@Param("id")int id); + List getDeptList(DepartmentPO departmentPO); + + /** + * 获取顶级数据 + * + * @return + */ + List listParent(); + + /** + * 获取子层级数据 + * + * @param ids + * @return + */ + List listChild(@Param("ids") Collection ids); + + DepartmentPO getDeptById(@Param("id") int id); + + String getDeptNameById(@Param("id") int id); } diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.xml b/src/com/engine/organization/mapper/department/DepartmentMapper.xml index 49ecedaa..9b022ad2 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.xml +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.xml @@ -1,20 +1,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + and t.dept_no like CONCAT('%',#{deptNo},'%') + + + and t.dept_name like CONCAT('%',#{deptName},'%') + + + and t.dept_name_short like CONCAT('%',#{deptNameShort},'%') + + + + + + and t.dept_no like '%'||#{deptNo}||'%' + + + and t.dept_name like '%'||#{deptName}||'%' + + + and t.dept_name_short like '%'||#{deptNameShort}||'%' + + + + + + and t.dept_no like '%'+#{deptNo}+'%' + + + and t.dept_name like '%'+#{deptName}+'%' + + + and t.dept_name_short like '%'+#{deptNameShort}+'%' + + + + + and ifnull(parent_dept,'0')='0' + + + + and isnull(parent_dept,'0')='0' + + + + and NVL(parent_dept,'0')='0' + \ No newline at end of file diff --git a/src/com/engine/organization/service/DepartmentService.java b/src/com/engine/organization/service/DepartmentService.java index 0a32073b..13cc9d5a 100644 --- a/src/com/engine/organization/service/DepartmentService.java +++ b/src/com/engine/organization/service/DepartmentService.java @@ -1,9 +1,12 @@ package com.engine.organization.service; +import com.engine.organization.entity.department.param.DeptSearchParam; import com.engine.organization.entity.department.param.QuerySingleDeptListParam; import com.engine.organization.entity.department.vo.SingleDeptTreeVO; import com.engine.organization.util.page.PageInfo; +import java.util.Map; + /** * @Author weaver_cl * @Description: TODO @@ -15,8 +18,19 @@ public interface DepartmentService { /** * 根据分部id获取部门tree * 联查部门 + * * @param param * @return */ PageInfo getDeptListByPid(QuerySingleDeptListParam param); + + /** + * 列表数据展示 + * + * @param param + * @return + */ + public Map listPage(DeptSearchParam param); + + } diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index 78d72c6c..18186055 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -91,8 +91,10 @@ public class CompServiceImpl extends Service implements CompService { List list = new ArrayList<>(); list.addAll(parentList); - // 递归查询子数据 - getChildPOs(parentList, list); + if (CollectionUtils.isNotEmpty(parentList)) { + // 递归查询子数据 + getChildPOs(parentList, list); + } CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID()); // 搜索条件过滤数据 diff --git a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java index 3fdfca59..f6b4ffe8 100644 --- a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java +++ b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java @@ -1,17 +1,26 @@ package com.engine.organization.service.impl; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; +import com.engine.organization.component.OrganizationWeaTable; import com.engine.organization.entity.department.bo.DepartmentBO; +import com.engine.organization.entity.department.dto.DepartmentListDTO; +import com.engine.organization.entity.department.param.DeptSearchParam; import com.engine.organization.entity.department.param.QuerySingleDeptListParam; import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.department.vo.SingleDeptTreeVO; import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.service.DepartmentService; 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 org.apache.commons.collections4.CollectionUtils; +import weaver.general.StringUtil; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * @Author weaver_cl @@ -20,20 +29,106 @@ import java.util.List; * @Version V1.0 **/ public class DepartmentServiceImpl extends Service implements DepartmentService { - + private DepartmentMapper getDepartmentMapper() { + return MapperProxyFactory.getProxy(DepartmentMapper.class); + } @Override public PageInfo getDeptListByPid(QuerySingleDeptListParam param) { //1.查询分部下所有部门 - PageUtil.start(param.getCurrent(),param.getPageSize()); + PageUtil.start(param.getCurrent(), param.getPageSize()); List departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByCompId(param.getParentComp()); List singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS); - PageInfo pageInfos = new PageInfo<>(singleDeptTreeVOS,SingleDeptTreeVO.class); + PageInfo pageInfos = new PageInfo<>(singleDeptTreeVOS, SingleDeptTreeVO.class); pageInfos.setTotal(departmentPOS.size()); pageInfos.setPageNum(param.getCurrent()); pageInfos.setPageSize(param.getPageSize()); return pageInfos; } + + @Override + public Map listPage(DeptSearchParam param) { + Map datas = new HashMap<>(); + PageUtil.start(param.getCurrent(), param.getPageSize()); + List parentList = getDepartmentMapper().listParent(); + List list = new ArrayList<>(); + list.addAll(parentList); + + if(CollectionUtils.isNotEmpty(parentList)) { + // 递归查询子数据 + getChildPOs(parentList, list); + } + DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(param, (long) user.getUID()); + // 搜索条件过滤数据 + List filterList = filterListByParams(list, departmentPO); + + List departmentListDTOS = DepartmentBO.buildDeptDTOList(list, filterList); + PageInfo pageInfos = new PageInfo<>(departmentListDTOS, DepartmentListDTO.class); + pageInfos.setTotal(pageInfos.getTotal()); + pageInfos.setPageNum(param.getCurrent()); + pageInfos.setPageSize(param.getPageSize()); + + OrganizationWeaTable table = new OrganizationWeaTable<>(user, DepartmentListDTO.class); + List columns = pageInfos.getColumns(); + List weaTableColumn = columns.stream().map(v -> new WeaTableColumn("100", v.getTitle(), v.getKey())).collect(Collectors.toList()); + + + table.setColumns(weaTableColumn); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + + datas.put("pageInfo", pageInfos); + datas.put("dataKey", result.getResultMap()); + return datas; + } + + /** + * 通过搜索条件过滤list数据 + * + * @param departmentPOS + * @param departmentPO + * @return + */ + private List filterListByParams(Collection departmentPOS, DepartmentPO departmentPO) { + // 搜索后的数据 + List filterList = new ArrayList<>(); + // 筛选数据 + for (Iterator iterator = departmentPOS.iterator(); iterator.hasNext(); ) { + DepartmentPO next = iterator.next(); + boolean isAdd = (StringUtil.isEmpty(departmentPO.getDeptName()) || next.getDeptName().contains(departmentPO.getDeptName())) // 名称 + && (StringUtil.isEmpty(departmentPO.getDeptNo()) || next.getDeptNo().contains(departmentPO.getDeptNo()))//编号 + && (StringUtil.isEmpty(departmentPO.getDeptNameShort()) || next.getDeptNameShort().contains(departmentPO.getDeptNameShort()))//简称 + && (null == departmentPO.getParentComp() || next.getParentComp().equals(departmentPO.getParentComp()))//所属分部 + && (null == departmentPO.getParentDept() || next.getParentDept().equals(departmentPO.getParentDept()))//上级部门 + && (null == departmentPO.getDeptPrincipal() || next.getDeptPrincipal().equals(departmentPO.getDeptPrincipal()))//部门负责人 + && (null == departmentPO.getShowOrder() || next.getShowOrder().equals(departmentPO.getShowOrder()))//显示顺序 + && (null == departmentPO.getForbiddenTag() || next.getForbiddenTag().equals(departmentPO.getForbiddenTag()));//禁用标记 + + if (isAdd) { + filterList.add(next); + } + + } + return filterList; + } + + /** + * 递归获取子级数据 + * + * @param parentList + * @param list + */ + private void getChildPOs(List parentList, List list) { + List ids = parentList.stream().map(DepartmentPO::getId).collect(Collectors.toList()); + List listChild = getDepartmentMapper().listChild(ids); + if (CollectionUtils.isNotEmpty(listChild)) { + list.addAll(listChild); + getChildPOs(listChild, list); + } + } } diff --git a/src/com/engine/organization/web/DepartmentController.java b/src/com/engine/organization/web/DepartmentController.java index d8b05372..3edd5bc3 100644 --- a/src/com/engine/organization/web/DepartmentController.java +++ b/src/com/engine/organization/web/DepartmentController.java @@ -1,6 +1,7 @@ package com.engine.organization.web; import com.engine.common.util.ServiceUtil; +import com.engine.organization.entity.department.param.DeptSearchParam; import com.engine.organization.entity.department.param.QuerySingleDeptListParam; import com.engine.organization.util.response.ReturnResult; import com.engine.organization.wrapper.DepartmentWrapper; @@ -25,20 +26,40 @@ import javax.ws.rs.core.MediaType; public class DepartmentController { private DepartmentWrapper getDepartmentWrapper(User user) { - return ServiceUtil.getService(DepartmentWrapper.class,user); + return ServiceUtil.getService(DepartmentWrapper.class, user); } @POST @Path("/getDeptListByPid") @Produces(MediaType.APPLICATION_JSON) - public ReturnResult getDeptListByPid(@Context HttpServletRequest request, @Context HttpServletResponse response, - @RequestBody QuerySingleDeptListParam querySingleDeptListParam) { + public ReturnResult getDeptListByPid(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody QuerySingleDeptListParam querySingleDeptListParam) { try { User user = HrmUserVarify.getUser(request, response); return getDepartmentWrapper(user).getDeptListByPid(querySingleDeptListParam); - }catch (Exception e) { + } catch (Exception e) { return ReturnResult.exceptionHandle(e.getMessage()); } } + + /** + * 获取list列表 + * + * @param request + * @param response + * @param params + * @return + */ + @POST + @Path("/listDept") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult listDept(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DeptSearchParam params) { + try { + User user = HrmUserVarify.getUser(request, response); + return ReturnResult.successed(getDepartmentWrapper(user).listPage(params)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + } diff --git a/src/com/engine/organization/webservice/CustomBrowserService.java b/src/com/engine/organization/webservice/CustomBrowserService.java new file mode 100644 index 00000000..d6086e7f --- /dev/null +++ b/src/com/engine/organization/webservice/CustomBrowserService.java @@ -0,0 +1,30 @@ +package com.engine.organization.webservice; + +import com.engine.organization.entity.comp.po.CompPO; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import java.util.List; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/23 + * @version: 1.0 + */ +@WebService +public interface CustomBrowserService { + + + /** + * 公司/分部 树形列表 + * 只获取未删除且启用的数据 + * + * @return + */ + @WebMethod( + operationName = "getCompTreeList", + action = "com.engine.organization.webservice.CustomBrowserService.getCompTreeList" + ) + List getCompTreeList(); +} diff --git a/src/com/engine/organization/webservice/CustomBrowserServiceImpl.java b/src/com/engine/organization/webservice/CustomBrowserServiceImpl.java new file mode 100644 index 00000000..94c0d1e1 --- /dev/null +++ b/src/com/engine/organization/webservice/CustomBrowserServiceImpl.java @@ -0,0 +1,53 @@ +package com.engine.organization.webservice; + +import com.engine.organization.entity.comp.po.CompPO; +import com.engine.organization.mapper.comp.CompMapper; +import com.engine.organization.util.db.MapperProxyFactory; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/23 + * @version: 1.0 + */ +public class CustomBrowserServiceImpl implements CustomBrowserService { + private CompMapper getCompMapper() { + return MapperProxyFactory.getProxy(CompMapper.class); + } + + @Override + public List getCompTreeList() { + // 获取所有启用数据 + List allList = getCompMapper().list().stream().filter(item -> 0 == item.getForbiddenTag()).collect(Collectors.toList()); + + List parentList = allList.stream().filter(item -> (null == item.getParentCompany() || 0 == item.getParentCompany())).collect(Collectors.toList()); + Map> compMap = allList.stream().filter(item -> (null != item.getParentCompany() && 0 != item.getParentCompany())).collect(Collectors.groupingBy(CompPO::getParentCompany)); + List returnList = new ArrayList<>(); + dealChildren(parentList, returnList, compMap); + + return returnList; + } + + /** + * 处理分部子节点 + * + * @param parentList + * @param returnList + * @param compMap + */ + private void dealChildren(List parentList, List returnList, Map> compMap) { + if (CollectionUtils.isEmpty(parentList)) { + return; + } + for (CompPO compPO : parentList) { + returnList.add(compPO); + dealChildren(compMap.get(compPO.getId()), returnList, compMap); + } + } +} diff --git a/src/com/engine/organization/wrapper/DepartmentWrapper.java b/src/com/engine/organization/wrapper/DepartmentWrapper.java index 114d5c50..5167cbd1 100644 --- a/src/com/engine/organization/wrapper/DepartmentWrapper.java +++ b/src/com/engine/organization/wrapper/DepartmentWrapper.java @@ -2,6 +2,7 @@ package com.engine.organization.wrapper; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; +import com.engine.organization.entity.department.param.DeptSearchParam; import com.engine.organization.entity.department.param.QuerySingleDeptListParam; import com.engine.organization.service.DepartmentService; import com.engine.organization.service.impl.DepartmentServiceImpl; @@ -10,6 +11,8 @@ import com.engine.organization.util.response.ReturnResult; import com.engine.organization.entity.department.vo.SingleDeptTreeVO; import weaver.hrm.User; +import java.util.Map; + /** * @Author weaver_cl * @Description: TODO @@ -19,11 +22,21 @@ import weaver.hrm.User; public class DepartmentWrapper extends Service { public DepartmentService getDepartmentService(User user) { - return ServiceUtil.getService(DepartmentServiceImpl.class,user); + return ServiceUtil.getService(DepartmentServiceImpl.class, user); } public ReturnResult getDeptListByPid(QuerySingleDeptListParam param) { PageInfo singleDeptTreeVOS = getDepartmentService(user).getDeptListByPid(param); return ReturnResult.successed(singleDeptTreeVOS); } + + /** + * 列表数据展示 + * + * @param param + * @return + */ + public Map listPage(DeptSearchParam param) { + return getDepartmentService(user).listPage(param); + } } From cd6121f0b0a2f97e4829cc227f2df276c33ac943 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Mon, 23 May 2022 19:16:31 +0800 Subject: [PATCH 17/22] =?UTF-8?q?=E9=83=A8=E9=97=A8=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=A8=E5=8D=95=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/DepartmentService.java | 18 +++++- .../service/impl/DepartmentServiceImpl.java | 63 +++++++++++++++++-- .../web/DepartmentController.java | 21 +++++++ .../wrapper/DepartmentWrapper.java | 9 +++ 4 files changed, 106 insertions(+), 5 deletions(-) diff --git a/src/com/engine/organization/service/DepartmentService.java b/src/com/engine/organization/service/DepartmentService.java index 13cc9d5a..79ae4d39 100644 --- a/src/com/engine/organization/service/DepartmentService.java +++ b/src/com/engine/organization/service/DepartmentService.java @@ -30,7 +30,23 @@ public interface DepartmentService { * @param param * @return */ - public Map listPage(DeptSearchParam param); + Map listPage(DeptSearchParam param); + + /** + * 保存部门基础信息 + * + * @param params + * @return + */ + int saveBaseComp(DeptSearchParam params); + + + /** + * 获取新增表单 + * + * @return + */ + Map getSaveForm(); } diff --git a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java index c53cc3fc..e3e8756e 100644 --- a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java +++ b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java @@ -1,5 +1,7 @@ package com.engine.organization.service.impl; +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; @@ -12,6 +14,7 @@ import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.department.vo.SingleDeptTreeVO; import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.service.DepartmentService; +import com.engine.organization.util.OrganizationFormItemUtil; import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.page.Column; import com.engine.organization.util.page.PageInfo; @@ -19,7 +22,8 @@ import com.engine.organization.util.page.PageUtil; import org.apache.commons.collections4.CollectionUtils; import weaver.general.StringUtil; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * @Author weaver_cl @@ -29,6 +33,9 @@ import java.util.List; **/ public class DepartmentServiceImpl extends Service implements DepartmentService { + private DepartmentMapper getDepartmentMapper() { + return MapperProxyFactory.getProxy(DepartmentMapper.class); + } @Override public PageInfo getDeptListByPid(QuerySingleDeptListParam param) { @@ -38,7 +45,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService List departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByCompId(param.getParentComp()); PageInfo pageInfo = new PageInfo<>(departmentPOS); List singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS); - PageInfo pageInfos = new PageInfo<>(singleDeptTreeVOS,SingleDeptTreeVO.class); + PageInfo pageInfos = new PageInfo<>(singleDeptTreeVOS, SingleDeptTreeVO.class); pageInfos.setTotal(pageInfo.getTotal()); pageInfos.setPageNum(param.getCurrent()); pageInfos.setPageSize(param.getPageSize()); @@ -51,10 +58,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService Map datas = new HashMap<>(); PageUtil.start(param.getCurrent(), param.getPageSize()); List parentList = getDepartmentMapper().listParent(); + PageInfo pageInfo = new PageInfo<>(parentList); List list = new ArrayList<>(); list.addAll(parentList); - if(CollectionUtils.isNotEmpty(parentList)) { + if (CollectionUtils.isNotEmpty(parentList)) { // 递归查询子数据 getChildPOs(parentList, list); } @@ -64,7 +72,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService List departmentListDTOS = DepartmentBO.buildDeptDTOList(list, filterList); PageInfo pageInfos = new PageInfo<>(departmentListDTOS, DepartmentListDTO.class); - pageInfos.setTotal(pageInfos.getTotal()); + pageInfos.setTotal(pageInfo.getTotal()); pageInfos.setPageNum(param.getCurrent()); pageInfos.setPageSize(param.getPageSize()); @@ -85,6 +93,53 @@ public class DepartmentServiceImpl extends Service implements DepartmentService return datas; } + @Override + public int saveBaseComp(DeptSearchParam params) { + return 0; + } + + @Override + public Map getSaveForm() { + Map apiDatas = new HashMap<>(); + List addGroups = new ArrayList<>(); + List conditionItems = new ArrayList<>(); + // 编号 + SearchConditionItem deptNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "编号", "deptNo"); + deptNoItem.setRules("required|string"); + // 名称 + SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "deptName"); + deptNameItem.setRules("required|string"); + // 简称 + SearchConditionItem deptNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "简称", "deptNameShort"); + deptNameShortItem.setRules("required|string"); + // TODO 自定义按钮 + // 所属分部 + SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "161", "parentComp", "compBrowser"); + //上级部门 + SearchConditionItem deptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级公司", "161", "parentDept", "deptBrowser"); + // 部门负责人 + SearchConditionItem deptPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "部门负责人", "1", "deptPrincipal", ""); + // 显示顺序 + SearchConditionItem showOrderItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "编号", "showOrder"); + // 说明 + SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 2, 60, "说明", "description"); + + conditionItems.add(deptNoItem); + conditionItems.add(deptNameItem); + conditionItems.add(deptNameShortItem); + conditionItems.add(compBrowserItem); + conditionItems.add(deptBrowserItem); + conditionItems.add(deptPrincipalItem); + conditionItems.add(showOrderItem); + conditionItems.add(descriptionItem); + + + addGroups.add(new SearchConditionGroup("基本信息", true, conditionItems)); + apiDatas.put("condition", addGroups); + + return apiDatas; + } + /** * 通过搜索条件过滤list数据 * diff --git a/src/com/engine/organization/web/DepartmentController.java b/src/com/engine/organization/web/DepartmentController.java index 3edd5bc3..e191dc0d 100644 --- a/src/com/engine/organization/web/DepartmentController.java +++ b/src/com/engine/organization/web/DepartmentController.java @@ -11,6 +11,7 @@ import weaver.hrm.User; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; @@ -62,4 +63,24 @@ public class DepartmentController { } } + /** + * 新增保存表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSaveForm") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getSaveForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + return ReturnResult.successed(getDepartmentWrapper(user).getSaveForm()); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + + } diff --git a/src/com/engine/organization/wrapper/DepartmentWrapper.java b/src/com/engine/organization/wrapper/DepartmentWrapper.java index 5167cbd1..8e90b9fc 100644 --- a/src/com/engine/organization/wrapper/DepartmentWrapper.java +++ b/src/com/engine/organization/wrapper/DepartmentWrapper.java @@ -39,4 +39,13 @@ public class DepartmentWrapper extends Service { public Map listPage(DeptSearchParam param) { return getDepartmentService(user).listPage(param); } + + /** + * 获取保存表单 + * + * @return + */ + public Map getSaveForm() { + return getDepartmentService(user).getSaveForm(); + } } From cb1b37e05dfa1e7eb337fdc52b1e4665786fe95a Mon Sep 17 00:00:00 2001 From: dxfeng Date: Tue, 24 May 2022 13:53:41 +0800 Subject: [PATCH 18/22] =?UTF-8?q?=E9=83=A8=E9=97=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=8E=A5=E5=8F=A3=20=E6=8B=93=E5=B1=95?= =?UTF-8?q?=E8=A1=A8=E9=80=9A=E7=94=A8=E6=96=B9=E6=B3=95=E6=8A=BD=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/department/bo/DepartmentBO.java | 3 - .../entity/extend/bo/ExtendInfoBO.java | 310 +++++++++++++++++- .../entity/extend/po/ExtendInfoPO.java | 6 + .../ExtDTMapper.java} | 6 +- .../ExtDTMapper.xml} | 4 +- .../ExtMapper.java} | 4 +- .../ExtMapper.xml} | 2 +- .../mapper/extend/ExtendInfoMapper.xml | 2 + .../organization/service/ExtService.java | 77 +++++ .../service/impl/CompServiceImpl.java | 185 +---------- .../service/impl/ExtServiceImpl.java | 167 ++++++++++ 11 files changed, 577 insertions(+), 189 deletions(-) rename src/com/engine/organization/mapper/{comp/CompExtDTMapper.java => extend/ExtDTMapper.java} (85%) rename src/com/engine/organization/mapper/{comp/CompExtDTMapper.xml => extend/ExtDTMapper.xml} (84%) rename src/com/engine/organization/mapper/{comp/CompExtMapper.java => extend/ExtMapper.java} (92%) rename src/com/engine/organization/mapper/{comp/CompExtMapper.xml => extend/ExtMapper.xml} (93%) create mode 100644 src/com/engine/organization/service/ExtService.java create mode 100644 src/com/engine/organization/service/impl/ExtServiceImpl.java diff --git a/src/com/engine/organization/entity/department/bo/DepartmentBO.java b/src/com/engine/organization/entity/department/bo/DepartmentBO.java index df1d5b60..d07d15ab 100644 --- a/src/com/engine/organization/entity/department/bo/DepartmentBO.java +++ b/src/com/engine/organization/entity/department/bo/DepartmentBO.java @@ -46,10 +46,7 @@ public class DepartmentBO { .build() ).collect(Collectors.toList()); Map> collects = dtoList.stream().filter(item -> null != item.getParentDept() && 0 != item.getParentDept()).collect(Collectors.groupingBy(DepartmentListDTO::getParentDept)); - System.out.println(collects); return dtoList.stream().map(e -> { - System.out.println(e.getId()); - System.out.println(collects.get(e.getId())); e.setChildren(collects.get(e.getId())); return e; }).filter(item -> null == item.getParentDept() || 0 == item.getParentDept()).collect(Collectors.toList()); diff --git a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java index 50db87a4..479fcc67 100644 --- a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java +++ b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java @@ -1,8 +1,24 @@ package com.engine.organization.entity.extend.bo; +import com.api.browser.bean.BrowserBean; +import com.api.browser.bean.BrowserValueInfo; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.service.BrowserValueInfoService; +import com.api.browser.util.BrowserInitUtil; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; import com.api.hrm.bean.FieldItem; import com.api.hrm.util.FieldType; +import com.api.hrm.util.ServiceUtil; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; import com.engine.organization.entity.extend.po.ExtendInfoPO; +import com.engine.organization.util.OrganizationFormItemUtil; +import com.engine.sensitive.biz.SensitiveWordTypeComInfo; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.definedfield.HrmFieldManager; +import weaver.systeminfo.SystemEnv; import java.util.ArrayList; import java.util.HashMap; @@ -17,8 +33,14 @@ import java.util.Map; */ public class ExtendInfoBO { + public static String DATE_SELECT = "select"; + public static String DATE_FROM = "from"; + public static String DATE_TO = "to"; + public static String DATE_Time_FROM = "_start"; + public static String DATE_Time_TO = "_end"; + // 封装对象为table组件 - public static List> convertInfoListToTable(List infoPOList, int viewAttr, boolean showLabel) { + public static List> convertInfoListToTable(User user, List infoPOList, int viewAttr, boolean showLabel) { List> lsCol = new ArrayList>(); Map col = null; @@ -31,7 +53,7 @@ public class ExtendInfoBO { col.put("key", tmpkey); col.put("dataIndex", tmpkey); - col.put("com", getFieldDetialInfo(extendInfoPO, viewAttr, showLabel, width)); + col.put("com", getFieldDetialInfo(user, extendInfoPO, viewAttr, showLabel, width)); col.put("width", width + "%"); @@ -45,13 +67,14 @@ public class ExtendInfoBO { /** * 明细表字段 * + * @param user * @param extendInfoPO * @param viewAttr * @return */ - private static List getFieldDetialInfo(ExtendInfoPO extendInfoPO, int viewAttr, boolean showLabel, int width) { + private static List getFieldDetialInfo(User user, ExtendInfoPO extendInfoPO, int viewAttr, boolean showLabel, int width) { List ls = new ArrayList(); - FieldItem fieldItem = createField(extendInfoPO, viewAttr, showLabel, width); + FieldItem fieldItem = createField(user, extendInfoPO, viewAttr, showLabel, width); ls.add(fieldItem); return ls; } @@ -59,13 +82,14 @@ public class ExtendInfoBO { /** * 创建列表字段信息 * + * @param user * @param extendInfoPO * @param viewAttr * @param showLabel * @param width * @return */ - private static FieldItem createField(ExtendInfoPO extendInfoPO, int viewAttr, boolean showLabel, int width) { + private static FieldItem createField(User user, ExtendInfoPO extendInfoPO, int viewAttr, boolean showLabel, int width) { FieldItem fieldItem = new FieldItem(); if (showLabel) { fieldItem.setLabel(extendInfoPO.getFieldNameDesc()); @@ -88,6 +112,12 @@ public class ExtendInfoBO { } } + // 浏览按钮特殊处理 + if (FieldType.BROWSER.equals(fieldItem.getType())) { + BrowserBean browserConditionParam = OrganizationFormItemUtil.browserItem(user, 2, 16, fieldItem.getViewAttr(), false, extendInfoPO.getFieldNameDesc(), extendInfoPO.getBrowserType(), extendInfoPO.getFieldName(), "").getBrowserConditionParam(); + fieldItem.setBrowserConditionParam(browserConditionParam); + } + fieldItem.setWidth(width + "%"); return fieldItem; } @@ -98,7 +128,7 @@ public class ExtendInfoBO { * @param fieldhtmltype * @return */ - public static FieldType getFieldhtmltype(String fieldhtmltype) { + private static FieldType getFieldhtmltype(String fieldhtmltype) { FieldType fieldtype = null; if (fieldhtmltype.equals("1")) { fieldtype = FieldType.INPUT; @@ -117,4 +147,272 @@ public class ExtendInfoBO { } return fieldtype; } + + + public static SearchConditionItem getSearchConditionItem(User user, int viewAttr, ExtendInfoPO extendInfoPO, Object fieldvalue) { + SearchConditionItem searchConditionItem = null; + try { + if (user == null) { + user = new User(); + user.setLanguage(7); + } + ConditionFactory conditionFactory = new ConditionFactory(user); + HrmFieldManager hrmFieldManager = new HrmFieldManager(); + String fieldid = Util.null2String(extendInfoPO.getId());//字段id + String fieldname = Util.null2String(extendInfoPO.getFieldName());//字段名 + String fieldlabel = Util.null2String(extendInfoPO.getFieldNameDesc());//字段显示名 + String fieldhtmltype = Util.null2String(extendInfoPO.getControlType());//字段类型 + String detailtype = Util.null2String(extendInfoPO.getBrowserType());//字段二级类型(浏览框--单人力) + String dmlurl = Util.null2String(""); + boolean isQuickSearch = true; + boolean isScope = false; + + if (fieldhtmltype.equals("1")) {//单行文本框 + if (isScope) {//范围 + if (Util.null2String(fieldvalue).length() == 0) { + fieldvalue = new HashMap(); + } + searchConditionItem = conditionFactory.createCondition(ConditionType.SCOPE, fieldlabel, new String[]{fieldname, fieldname + "to"}); + } else if (detailtype.equals("2")) {//数字 + searchConditionItem = conditionFactory.createCondition(ConditionType.INPUTNUMBER, fieldlabel, fieldname, isQuickSearch); + } else { + searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, fieldlabel, fieldname, isQuickSearch); + } + } else if (fieldhtmltype.equals("2")) {//多行文本框 + searchConditionItem = conditionFactory.createCondition(ConditionType.TEXTAREA, fieldlabel, fieldname); + } else if (fieldhtmltype.equals("3")) {//浏览按钮 + if (detailtype.equals("2")) { + if (!extendInfoPO.getTableName().toLowerCase().contains("_dt")) { + searchConditionItem = conditionFactory.createCondition(ConditionType.DATEPICKER, fieldlabel, fieldname); + } else { + searchConditionItem = conditionFactory.createCondition(ConditionType.DATE, fieldlabel, fieldname, detailtype); + searchConditionItem.setDomkey(new String[]{fieldname + DATE_SELECT, fieldname + DATE_FROM, fieldname + DATE_TO}); + searchConditionItem.setOptions(ServiceUtil.getDateSelectFromTo(user.getLanguage())); + } + } else if (detailtype.equals("19")) { + searchConditionItem = conditionFactory.createCondition(ConditionType.TIMEPICKER, fieldlabel, fieldname, detailtype); + } else if (detailtype.equals("402")) { // 年 + searchConditionItem = conditionFactory.createCondition(ConditionType.DATEPICKER, fieldlabel, fieldname, detailtype); + searchConditionItem.setFormat("yyyy"); + searchConditionItem.setMode("year"); + searchConditionItem.setPlaceholder(SystemEnv.getHtmlLabelNames("526306", user.getLanguage())); + searchConditionItem.setShowTime(false); + } else if (detailtype.equals("403")) { + searchConditionItem = conditionFactory.createCondition(ConditionType.DATEPICKER, fieldlabel, fieldname, detailtype); + searchConditionItem.setFormat("yyyy-MM"); + searchConditionItem.setMode("month"); + searchConditionItem.setPlaceholder(SystemEnv.getHtmlLabelNames("126137", user.getLanguage())); + searchConditionItem.setShowTime(false); + } else if (detailtype.equals("RANGEPICKER")) {//日期区间 + String[] domkey = new String[]{DATE_FROM + fieldname, DATE_TO + fieldname}; + searchConditionItem = conditionFactory.createCondition(ConditionType.RANGEPICKER, fieldlabel, domkey); + searchConditionItem.setValue(fieldvalue); + } else if (detailtype.equals("TIMERANGEPICKER")) {//时间区间 + String[] domkey = new String[]{fieldname + DATE_Time_FROM, fieldname + DATE_Time_TO}; + searchConditionItem = conditionFactory.createCondition(ConditionType.TIMERANGEPICKER, fieldlabel, domkey); + searchConditionItem.setValue(fieldvalue); + } else { + //if (detailtype.equals("161") || detailtype.equals("162") || detailtype.equals("256") || detailtype.equals("257")) { + // BrowserBean browserbean = new BrowserBean(detailtype + ""); + // BrowserInitUtil browserInitUtil = new BrowserInitUtil(); + // String fielddbtype = dmlurl; + // if (!dmlurl.startsWith("browser.")) { + // fielddbtype = "browser." + dmlurl; + // } + // if (detailtype.equals("161") || detailtype.equals("162")) { + // browserInitUtil.initCustomizeBrow(browserbean, fielddbtype, Util.getIntValue(detailtype), user.getUID()); + // } else { + // browserbean.getDataParams().put("cube_treeid", dmlurl); + // browserbean.getDataParams().put("currenttime", System.currentTimeMillis()); + // browserInitUtil.initBrowser(browserbean, user.getLanguage()); + // } + // searchConditionItem = new SearchConditionItem(ConditionType.BROWSER, SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()), new String[]{fieldname}, browserbean); + //} else { + searchConditionItem = conditionFactory.createCondition(ConditionType.BROWSER, fieldlabel, fieldname, detailtype); + //} + // searchConditionItem.getBrowserConditionParam().setHideVirtualOrg(hrmFieldBean.getHideVirtualOrg()); + List> replaceDatas = new ArrayList>(); + String tmpFieldValue = Util.null2String(fieldvalue); + if (detailtype.equals("mkqshift")) { + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + String[] fieldvalues = Util.splitString(tmpFieldValue, ","); + for (int i = 0; fieldvalues != null && i < fieldvalues.length; i++) { + String fieldshowname = Util.null2String(shiftManagementToolKit.getShiftOnOffWorkSections(fieldvalues[i], user.getLanguage())); + if (fieldshowname.length() == 0) continue; + Map replaceData = new HashMap(); + replaceData.put("id", fieldvalues[i]); + replaceData.put("name", fieldshowname); + replaceDatas.add(replaceData); + } + } else if (detailtype.equals("sensitivewordstype")) { + SensitiveWordTypeComInfo sensitiveWordTypeComInfo = new SensitiveWordTypeComInfo(); + String[] fieldvalues = Util.splitString(tmpFieldValue, ","); + for (int i = 0; fieldvalues != null && i < fieldvalues.length; i++) { + String fieldshowname = Util.null2String(sensitiveWordTypeComInfo.getName(fieldvalues[i])); + if (fieldshowname.length() == 0) continue; + Map replaceData = new HashMap(); + replaceData.put("id", fieldvalues[i]); + replaceData.put("name", fieldshowname); + replaceDatas.add(replaceData); + } + } else if (detailtype.equals("doccategory")) { + List fieldvalues = new BrowserValueInfoService().getBrowserValueInfo(detailtype, Util.null2String(fieldvalue)); + for (int i = 0; fieldvalues != null && i < fieldvalues.size(); i++) { + BrowserValueInfo valueInfo = fieldvalues.get(i); + String fieldshowname = valueInfo.getName(); + if (fieldshowname.length() == 0) continue; + Map replaceData = new HashMap(); + replaceData.put("id", valueInfo.getId()); + replaceData.put("name", fieldshowname); + replaceDatas.add(replaceData); + } + } else { + if (tmpFieldValue.length() > 0) { + String fieldshowname = hrmFieldManager.getFieldvalue(user, dmlurl, Util.getIntValue(fieldid), Util.getIntValue(fieldhtmltype), Util.getIntValue(detailtype), tmpFieldValue, 0); + String[] fieldvalues = Util.splitString(tmpFieldValue, ","); + String[] fieldshownames = Util.splitString(fieldshowname, ","); + if (detailtype.equals("257")) { + if (fieldshowname.endsWith(" ")) { + fieldshowname = fieldshowname.substring(0, fieldshowname.length() - 5); + } + fieldshownames = Util.splitString(fieldshowname, " "); + } + for (int i = 0; fieldvalues != null && i < fieldvalues.length; i++) { + if (fieldvalues.length != fieldshownames.length) { + break; + } + if (Util.null2String(fieldshownames[i]).length() == 0) continue; + Map replaceData = new HashMap(); + replaceData.put("id", fieldvalues[i]); + replaceData.put("name", fieldshownames[i]); + replaceDatas.add(replaceData); + } + } + } + fieldvalue = replaceDatas; + } + } else if (fieldhtmltype.equals("4")) {//Check框 + searchConditionItem = conditionFactory.createCondition(ConditionType.CHECKBOX, fieldlabel, fieldname); + if (detailtype.equals("2")) { + searchConditionItem.setConditionType(ConditionType.SWITCH); + } + + } else if (fieldhtmltype.equals("5")) { //选择框 + // List statusOptions = hrmFieldBean.getSelectOption(); + // if (statusOptions == null) statusOptions = new ArrayList(); + // try { + // if (fieldid.length() > 0) { + // rs = new RecordSet(); + // char flag = Util.getSeparator(); + // if (hrmFieldBean.getIsFormField()) { + // if (Util.null2String(hrmFieldBean.getIssystem()).equals("1")) { + // rs.executeProc("hrm_selectitembyid_new", "" + fieldid + flag + 1); + // } else { + // rs.executeProc("cus_selectitembyid_new", "" + fieldid + flag + 1); + // } + // } else { + // if (fieldname.startsWith("column_")) { + // rs.executeProc("cus_selectitembyid_new", "" + fieldid + flag + 1); + // } else { + // rs.executeProc("hrm_searchselectitembyid", fieldid); + // } + // } + // while (rs.next()) { + // String tmpselectvalue = Util.null2String(rs.getString("selectvalue")); + // String tmpselectname = Util.toScreen(rs.getString("selectname"), user.getLanguage()); + // if (Util.null2String(rs.getString("cancel")).equals("1")) continue; + // boolean isDefault = Util.null2String(rs.getString("isdefault")).equals("y"); + // if (!isDefault) { + // isDefault = Util.null2String(rs.getString("hrm_isdefault")).equals("1"); + // } + // SearchConditionOption searchConditionOption = new SearchConditionOption(tmpselectvalue, tmpselectname, isDefault); + // if (!statusOptions.contains(searchConditionOption)) { + // statusOptions.add(searchConditionOption); + // } + // } + // } + // } catch (Exception e) { + // writeLog(e); + // } + // searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, fieldlabel, fieldname, statusOptions); + // if (detailtype.equals("") || detailtype.equals("0")) { + // detailtype = "1"; + // } + // searchConditionItem.setKey(Util.null2String(fieldvalue)); + // searchConditionItem.setValue(fieldvalue); + // searchConditionItem.setDetailtype(Util.getIntValue(detailtype, 3)); + } else if (fieldhtmltype.equals("6")) {//附件 + if (fieldname.equals("resourceimageid")) { + searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, fieldlabel, fieldname, isQuickSearch); + } else { + searchConditionItem = conditionFactory.createCondition(ConditionType.UPLOAD, fieldlabel, fieldname, isQuickSearch); + searchConditionItem.setUploadUrl("/api/doc/upload/uploadFile"); + searchConditionItem.setCategory("category"); + searchConditionItem.setMaxFilesNumber(10); + searchConditionItem.setMultiSelection(true); + Map otherParamsMap = new HashMap<>(); + otherParamsMap.put("showClearAll", false); + otherParamsMap.put("showOrder", true); + searchConditionItem.setOtherParams(otherParamsMap); + if (Util.null2String(fieldvalue).length() > 0) { + List datas = new ArrayList(); + Map data = null; + String[] tmpIds = Util.splitString(Util.null2String(fieldvalue), ","); + for (int i = 0; i < tmpIds.length; i++) { + String fileid = tmpIds[i]; + ImageFileManager manager = new ImageFileManager(); + manager.getImageFileInfoById(Util.getIntValue(fileid)); + String filename = manager.getImageFileName(); + String extname = filename.contains(".") ? filename.substring(filename.lastIndexOf(".") + 1) : ""; + data = new HashMap(); + data.put("acclink", "/weaver/weaver.file.FileDownload?fileid=" + fileid); + data.put("fileExtendName", extname); + data.put("fileid", fileid); + //if (Util.null2String(this.isMobile).equals("1")) { + // data.put("filelink", "/spa/document/static4mobile/index.html#/attach/" + fileid); + //} else { + data.put("filelink", "/spa/document/index2file.jsp?imagefileId=" + fileid + "#/main/document/fileView"); + //} + data.put("filename", filename); + data.put("filesize", manager.getImgsize()); + data.put("imgSrc", ""); + data.put("isImg", ""); + data.put("loadlink", "/weaver/weaver.file.FileDownload?fileid=" + fileid + "&download=1"); + data.put("showDelete", "true"); + data.put("showLoad", "true"); + datas.add(data); + } + searchConditionItem.setDatas(datas); + } + } + } else if (fieldhtmltype.equals("7")) {//颜色选择 + searchConditionItem = conditionFactory.createCondition(ConditionType.COLORPICKER, fieldlabel, fieldname, true); + searchConditionItem.setValue(fieldvalue); + } else if (fieldhtmltype.equals("8")) {//DESCRIPTION + searchConditionItem = conditionFactory.createCondition(ConditionType.DESCRIPTION, fieldlabel, fieldname); + searchConditionItem.setValue(fieldvalue); + } + if (searchConditionItem != null) { + BrowserInitUtil.setConditionItemDefaultValue(searchConditionItem, fieldvalue, 2); + searchConditionItem.setLabelcol(6); + searchConditionItem.setFieldcol(12); + searchConditionItem.setViewAttr(viewAttr); + if (searchConditionItem.getBrowserConditionParam() != null) { + searchConditionItem.getBrowserConditionParam().setViewAttr(viewAttr); + } + if (searchConditionItem.getConditionType().equals(ConditionType.DATE)) { + searchConditionItem.setFieldcol(18); + } + + if (Util.null2String(extendInfoPO.getFieldNameDesc()).length() > 0) { + searchConditionItem.setLabel(extendInfoPO.getFieldNameDesc()); + } + + } + } catch (Exception e) { + throw new RuntimeException(e); + } + + return searchConditionItem; + } } diff --git a/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java b/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java index acdd7b1a..aba76bc9 100644 --- a/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java +++ b/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java @@ -53,6 +53,12 @@ public class ExtendInfoPO { */ private Integer controlType; + + /** + * 浏览按钮类型 + */ + private String browserType; + /** * 分组主键 */ diff --git a/src/com/engine/organization/mapper/comp/CompExtDTMapper.java b/src/com/engine/organization/mapper/extend/ExtDTMapper.java similarity index 85% rename from src/com/engine/organization/mapper/comp/CompExtDTMapper.java rename to src/com/engine/organization/mapper/extend/ExtDTMapper.java index 31f05c9f..baf68619 100644 --- a/src/com/engine/organization/mapper/comp/CompExtDTMapper.java +++ b/src/com/engine/organization/mapper/extend/ExtDTMapper.java @@ -1,6 +1,5 @@ -package com.engine.organization.mapper.comp; +package com.engine.organization.mapper.extend; -import org.apache.ibatis.annotations.MapKey; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -12,7 +11,7 @@ import java.util.Map; * @createTime: 2022/05/20 * @version: 1.0 */ -public interface CompExtDTMapper { +public interface ExtDTMapper { /** * 根据主表id,查询拓展表数据 @@ -21,7 +20,6 @@ public interface CompExtDTMapper { * @param id * @return */ - @MapKey("id") List> listCompExtDT(@Param("tableName") String tableName, @Param("id") long id, @Param("fields") String fields); /** diff --git a/src/com/engine/organization/mapper/comp/CompExtDTMapper.xml b/src/com/engine/organization/mapper/extend/ExtDTMapper.xml similarity index 84% rename from src/com/engine/organization/mapper/comp/CompExtDTMapper.xml rename to src/com/engine/organization/mapper/extend/ExtDTMapper.xml index 4ecb3ac4..d9ef99a7 100644 --- a/src/com/engine/organization/mapper/comp/CompExtDTMapper.xml +++ b/src/com/engine/organization/mapper/extend/ExtDTMapper.xml @@ -1,6 +1,6 @@ - + @@ -21,7 +21,7 @@ where mainid = #{mainId} - select ${fields} from ${tableName} where mainid = #{id} diff --git a/src/com/engine/organization/mapper/comp/CompExtMapper.java b/src/com/engine/organization/mapper/extend/ExtMapper.java similarity index 92% rename from src/com/engine/organization/mapper/comp/CompExtMapper.java rename to src/com/engine/organization/mapper/extend/ExtMapper.java index ff6482d7..da7b11d5 100644 --- a/src/com/engine/organization/mapper/comp/CompExtMapper.java +++ b/src/com/engine/organization/mapper/extend/ExtMapper.java @@ -1,4 +1,4 @@ -package com.engine.organization.mapper.comp; +package com.engine.organization.mapper.extend; import org.apache.ibatis.annotations.Param; @@ -10,7 +10,7 @@ import java.util.Map; * @createTime: 2022/05/20 * @version: 1.0 */ -public interface CompExtMapper { +public interface ExtMapper { /** * 根据主表id,查询主表拓展表数据 diff --git a/src/com/engine/organization/mapper/comp/CompExtMapper.xml b/src/com/engine/organization/mapper/extend/ExtMapper.xml similarity index 93% rename from src/com/engine/organization/mapper/comp/CompExtMapper.xml rename to src/com/engine/organization/mapper/extend/ExtMapper.xml index e2305c1c..40b9672f 100644 --- a/src/com/engine/organization/mapper/comp/CompExtMapper.xml +++ b/src/com/engine/organization/mapper/extend/ExtMapper.xml @@ -1,6 +1,6 @@ - + diff --git a/src/com/engine/organization/mapper/extend/ExtendInfoMapper.xml b/src/com/engine/organization/mapper/extend/ExtendInfoMapper.xml index c06dec91..5d9855cc 100644 --- a/src/com/engine/organization/mapper/extend/ExtendInfoMapper.xml +++ b/src/com/engine/organization/mapper/extend/ExtendInfoMapper.xml @@ -9,6 +9,7 @@ + @@ -35,6 +36,7 @@ , t.field_name_desc , t.field_type , t.control_type + , t.browser_type , t.extend_group_id , t.isenable , t.isrequired diff --git a/src/com/engine/organization/service/ExtService.java b/src/com/engine/organization/service/ExtService.java new file mode 100644 index 00000000..4165b5b9 --- /dev/null +++ b/src/com/engine/organization/service/ExtService.java @@ -0,0 +1,77 @@ +package com.engine.organization.service; + +import com.api.browser.bean.SearchConditionItem; +import com.engine.organization.entity.TopTab; +import weaver.hrm.User; + +import java.util.List; +import java.util.Map; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/24 + * @version: 1.0 + */ +public interface ExtService { + + /** + * 组装主表拓展表表单 + * + * @param user + * @param extendType + * @param tableName + * @param viewAttr + * @param id + * @param groupId + * @return + */ + List getExtForm(User user, String extendType, String tableName, int viewAttr, long id, String groupId); + + /** + * 组装明细表表单 + * + * @param user + * @param extendType + * @param tableName + * @param id + * @param viewAttr + * @param showLabel + * @return + */ + List> getExtendTables(User user, String extendType, String tableName, long id, int viewAttr, boolean showLabel); + + /** + * 拓展页面分组 + * + * @param extendType + * @param tableName + * @return + */ + List getTabInfo(String extendType, String tableName); + + + /** + * 更新主表拓展表 + * + * @param user + * @param extendType + * @param tableName + * @param params + * @param groupId + * @param id + * @return + */ + int updateExtForm(User user, String extendType, String tableName, Map params, String groupId, Long id); + + /** + * 更新明细表 + * + * @param user + * @param extendType + * @param tableName + * @param params + * @param id + */ + void updateExtDT(User user, String extendType, String tableName, Map params, Long id); +} diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index 5ecb7eee..bd6f7765 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -8,21 +8,17 @@ import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.organization.component.OrganizationWeaTable; -import com.engine.organization.entity.TopTab; 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.extend.bo.ExtendInfoBO; -import com.engine.organization.entity.extend.po.ExtendInfoPO; -import com.engine.organization.mapper.comp.CompExtDTMapper; -import com.engine.organization.mapper.comp.CompExtMapper; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.extend.ExtendGroupMapper; -import com.engine.organization.mapper.extend.ExtendInfoMapper; import com.engine.organization.service.CompService; +import com.engine.organization.service.ExtService; import com.engine.organization.util.MenuBtn; import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.OrganizationFormItemUtil; @@ -34,6 +30,7 @@ import org.apache.commons.collections4.CollectionUtils; import weaver.crm.Maint.SectorInfoComInfo; import weaver.general.StringUtil; import weaver.general.Util; +import weaver.hrm.User; import weaver.hrm.resource.ResourceComInfo; import java.util.*; @@ -70,16 +67,8 @@ public class CompServiceImpl extends Service implements CompService { return MapperProxyFactory.getProxy(ExtendGroupMapper.class); } - private ExtendInfoMapper getExtendInfoMapper() { - return MapperProxyFactory.getProxy(ExtendInfoMapper.class); - } - - private CompExtDTMapper getCompExtDTMapper() { - return MapperProxyFactory.getProxy(CompExtDTMapper.class); - } - - private CompExtMapper getCompExtMapper() { - return MapperProxyFactory.getProxy(CompExtMapper.class); + private ExtService getExtService(User user) { + return ServiceUtil.getService(ExtServiceImpl.class, user); } @@ -148,52 +137,12 @@ public class CompServiceImpl extends Service implements CompService { // 更新主表数据 updateBaseComp = getCompMapper().updateBaseComp(compPO); } else { - List extInfoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, groupId, JCL_ORG_COMPEXT); - List extFields = extInfoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList()); - Map map = new HashMap<>(); - for (String dtField : extFields) { - map.put(dtField, params.get(dtField)); - } - // 判断更新还是插入 - int count = getCompExtMapper().countCompExtById(JCL_ORG_COMPEXT, searchParam.getId()); - if (count > 0) { - map.put("update_time", compPO.getUpdateTime()); - updateBaseComp = getCompExtMapper().updateCompExt(JCL_ORG_COMPEXT, compPO.getId(), map); - } else { - map.put("creator", compPO.getCreator()); - map.put("delete_type", compPO.getDeleteType()); - map.put("create_time", compPO.getCreateTime()); - map.put("update_time", compPO.getUpdateTime()); - map.put("id", compPO.getId()); - updateBaseComp = getCompExtMapper().insertCompExt(JCL_ORG_COMPEXT, map); - } + // 更新主表拓展表 + updateBaseComp = getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_COMPEXT, params, groupId, compPO.getId()); } - // 获取分部明细表的所有拓展列 - List dtInfoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, "", JCL_ORG_COMPEXT_DT1); - List dtFields = dtInfoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList()); - - List> insertList = new ArrayList<>(); - // 删除明细表数据 - getCompExtDTMapper().deleteByMainID(JCL_ORG_COMPEXT_DT1, compPO.getId()); - // 处理明细表数据 - int rowNum = Util.getIntValue((String) params.get("rownum")); - for (int i = 0; i < rowNum; i++) { - Map map = new HashMap<>(); - for (String dtField : dtFields) { - map.put(dtField, params.get(dtField + "_" + i)); - } - map.put("mainid", compPO.getId()); - map.put("creator", compPO.getCreator()); - map.put("delete_type", compPO.getDeleteType()); - map.put("create_time", compPO.getCreateTime()); - map.put("update_time", compPO.getUpdateTime()); - insertList.add(map); - } - // 更新拓展表数据 - for (Map map : insertList) { - getCompExtDTMapper().insertCompExtDT(JCL_ORG_COMPEXT_DT1, map); - } + //更新明细表 + getExtService(user).updateExtDT(user, EXTEND_TYPE, JCL_ORG_COMPEXT_DT1, params, compPO.getId()); return updateBaseComp; } @@ -281,16 +230,17 @@ public class CompServiceImpl extends Service implements CompService { if (StringUtil.isEmpty(groupId) || "0".equals(groupId)) { addGroups.add(new SearchConditionGroup("基本信息", true, getBaseForm(viewAttr, id))); } else { - addGroups.add(new SearchConditionGroup(getExtendGroupMapper().getGroupNameById(groupId), true, getExtForm(viewAttr, id, groupId))); + addGroups.add(new SearchConditionGroup(getExtendGroupMapper().getGroupNameById(groupId), true, getExtService(user).getExtForm(user, EXTEND_TYPE, JCL_ORG_COMPEXT, viewAttr, id, groupId))); } - HashMap resultMap = new HashMap<>(); resultMap.put("buttons", buttonsMap); resultMap.put("conditions", addGroups); resultMap.put("id", id); - resultMap.put("tabInfo", getTabInfo()); - resultMap.put("tables", getExtendTables(id, viewAttr, false)); + // 拓展页面分组 + resultMap.put("tabInfo", getExtService(user).getTabInfo(EXTEND_TYPE, JCL_ORG_COMPEXT)); + // 处理明细表 + resultMap.put("tables", getExtService(user).getExtendTables(user, EXTEND_TYPE, JCL_ORG_COMPEXT_DT1, id, viewAttr, false)); Map apiDatas = new HashMap<>(); apiDatas.put("result", resultMap); @@ -388,34 +338,6 @@ public class CompServiceImpl extends Service implements CompService { } - /** - * 处理明细表 - * - * @return - */ - private List> getExtendTables(long id, int viewAttr, boolean showLabel) { - List> tables = new ArrayList<>(); - // 查询所有分布模块,拓展明细表信息 - List infoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, "", JCL_ORG_COMPEXT_DT1); - 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(), viewAttr, showLabel)); - tabinfoMap.put("rownum", "rownum"); - - String fields = entry.getValue().stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); - tabinfoMap.put("datas", getCompExtDTMapper().listCompExtDT(JCL_ORG_COMPEXT_DT1, id, fields)); - tableMap.put("tabinfo", tabinfoMap); - tables.add(tableMap); - } - return tables; - } - - /** * 浏览按钮类型赋值转换 * @@ -433,26 +355,6 @@ public class CompServiceImpl extends Service implements CompService { } - /** - * 拓展页面分组 - * - * @return - */ - private List getTabInfo() { - List topTabs = new ArrayList<>(); - // 基本信息 - topTabs.add(TopTab.builder().color("#000000").groupId("0").showcount(false).title("基本信息").viewCondition("0").build()); - - List infoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, "", JCL_ORG_COMPEXT); - List extendGroups = infoPOList.stream().map(ExtendInfoPO::getExtendGroupId).collect(Collectors.toList()); - // 拓展信息 - 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()); - } - } - return topTabs; - } /** * 基本信息基础表单 @@ -534,63 +436,4 @@ public class CompServiceImpl extends Service implements CompService { } - /** - * 根据viewCondition获取拓展表单 - * - * @param viewAttr - * @param id - * @param groupId - * @return - */ - private List getExtForm(int viewAttr, long id, String groupId) { - List conditionItems = new ArrayList<>(); - - // 2编辑 1查看 - OrganizationAssert.notNull(groupId, "请选择对应的拓展页"); - List infoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, groupId, JCL_ORG_COMPEXT); - String fields = infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); - Map compExtMap = getCompExtMapper().listCompExt(JCL_ORG_COMPEXT, fields, id); - - // 组装拓展页内容 - for (ExtendInfoPO extendInfoPO : infoPOList) { - SearchConditionItem item = null; - switch (ExtendInfoBO.getFieldhtmltype(extendInfoPO.getControlType() + "")) { - case INPUT: - item = OrganizationFormItemUtil.inputItem(user, 2, 16, 1, 50, extendInfoPO.getFieldNameDesc(), extendInfoPO.getFieldName()); - item.setValue(compExtMap.get(extendInfoPO.getFieldName())); - break; - case TEXTAREA: - item = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 1, 60, extendInfoPO.getFieldNameDesc(), extendInfoPO.getFieldName()); - item.setValue(compExtMap.get(extendInfoPO.getFieldName())); - break; - case BROWSER: - // TODO - // item=OrganizationFormItemUtil.browserItem() - break; - case CHECKBOX: - item = OrganizationFormItemUtil.checkboxItem(user, 2, 16, 1, true, extendInfoPO.getFieldNameDesc(), extendInfoPO.getFieldName()); - item.setValue(compExtMap.get(extendInfoPO.getFieldName())); - break; - case SELECT: - // TODO - // item = OrganizationFormItemUtil.selectItem(); - break; - case FILEUPLOAD: - case TEXT: - default: - break; - } - if (null != item) { - // 根据viewAttr设置编辑或只读 - item.setViewAttr(viewAttr); - // 是否必填 - if (1 == extendInfoPO.getIsrequired()) { - item.setViewAttr(3); - item.setRules("required|string"); - } - conditionItems.add(item); - } - } - return conditionItems; - } } diff --git a/src/com/engine/organization/service/impl/ExtServiceImpl.java b/src/com/engine/organization/service/impl/ExtServiceImpl.java new file mode 100644 index 00000000..fc2b4edc --- /dev/null +++ b/src/com/engine/organization/service/impl/ExtServiceImpl.java @@ -0,0 +1,167 @@ +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.extend.bo.ExtendInfoBO; +import com.engine.organization.entity.extend.po.ExtendInfoPO; +import com.engine.organization.mapper.extend.ExtDTMapper; +import com.engine.organization.mapper.extend.ExtMapper; +import com.engine.organization.mapper.extend.ExtendGroupMapper; +import com.engine.organization.mapper.extend.ExtendInfoMapper; +import com.engine.organization.service.ExtService; +import com.engine.organization.util.OrganizationAssert; +import com.engine.organization.util.db.MapperProxyFactory; +import org.apache.commons.collections4.CollectionUtils; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/24 + * @version: 1.0 + */ +public class ExtServiceImpl extends Service implements ExtService { + + private ExtendInfoMapper getExtendInfoMapper() { + return MapperProxyFactory.getProxy(ExtendInfoMapper.class); + } + + private ExtendGroupMapper getExtendGroupMapper() { + return MapperProxyFactory.getProxy(ExtendGroupMapper.class); + } + + private ExtDTMapper getExtDTMapper() { + return MapperProxyFactory.getProxy(ExtDTMapper.class); + } + + private ExtMapper getExtMapper() { + return MapperProxyFactory.getProxy(ExtMapper.class); + } + + + @Override + public List getExtForm(User user, String extendType, String tableName, int viewAttr, long id, String groupId) { + List conditionItems = new ArrayList<>(); + + // 2编辑 1查看 + 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); + // 组装拓展页内容 + for (ExtendInfoPO extendInfoPO : infoPOList) { + SearchConditionItem item = ExtendInfoBO.getSearchConditionItem(user, viewAttr, extendInfoPO, compExtMap.get(extendInfoPO.getFieldName())); + item.setFieldcol(16); + if (null != item && 2 == viewAttr && 1 == extendInfoPO.getIsrequired()) { + item.setViewAttr(3); + item.setRules("required|string"); + } + 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<>(); + // 查询所有分布模块,拓展明细表信息 + List infoPOList = getExtendInfoMapper().listFields(extendType, "", 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(user, entry.getValue(), viewAttr, showLabel)); + tabinfoMap.put("rownum", "rownum"); + + String fields = entry.getValue().stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); + tabinfoMap.put("datas", getExtDTMapper().listCompExtDT(tableName, id, fields)); + tableMap.put("tabinfo", tabinfoMap); + tables.add(tableMap); + } + return tables; + } + + + /** + * 拓展页面分组 + * + * @return + */ + 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()); + // 拓展信息 + 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()); + } + } + return topTabs; + } + + @Override + public int updateExtForm(User user, String extendType, String tableName, Map params, String groupId, Long id) { + int updateBaseComp; + List extInfoPOList = getExtendInfoMapper().listFields(extendType, groupId, tableName); + List extFields = extInfoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList()); + Map map = new HashMap<>(); + for (String dtField : extFields) { + map.put(dtField, params.get(dtField)); + } + // 判断更新还是插入 + int count = getExtMapper().countCompExtById(tableName, id); + if (count > 0) { + map.put("update_time", new Date()); + updateBaseComp = getExtMapper().updateCompExt(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); + } + return updateBaseComp; + } + + @Override + public void updateExtDT(User user, String extendType, String tableName, Map params, Long id) { + List dtInfoPOList = getExtendInfoMapper().listFields(extendType, "", tableName); + List dtFields = dtInfoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList()); + + List> insertList = new ArrayList<>(); + // 删除明细表数据 + getExtDTMapper().deleteByMainID(tableName, id); + // 处理明细表数据 + int rowNum = Util.getIntValue((String) params.get("rownum")); + for (int i = 0; i < rowNum; i++) { + Map map = new HashMap<>(); + for (String dtField : dtFields) { + map.put(dtField, params.get(dtField + "_" + i)); + } + map.put("mainid", id); + map.put("creator", user.getUID()); + map.put("delete_type", 0); + map.put("create_time", new Date()); + map.put("update_time", new Date()); + insertList.add(map); + } + // 更新拓展表数据 + for (Map map : insertList) { + getExtDTMapper().insertCompExtDT(tableName, map); + } + } +} From 01ab659ef3b9b39f6af6b8cb16ec687c2978166a Mon Sep 17 00:00:00 2001 From: dxfeng Date: Tue, 24 May 2022 15:15:49 +0800 Subject: [PATCH 19/22] =?UTF-8?q?BUG=E4=BF=AE=E5=A4=8D=20=E8=A1=A8?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/表结构SQL/MySQL.sql | 18 +++--- docs/表结构SQL/Oracle.sql | 18 +++--- docs/表结构SQL/SqlServer.sql | 18 +++--- .../entity/staff/po/StaffPlanPO.java | 62 +++++++++++++++++++ .../mapper/scheme/LevelMapper.xml | 2 +- .../service/impl/CompServiceImpl.java | 14 +++-- .../service/impl/DepartmentServiceImpl.java | 3 +- .../service/impl/GradeServiceImpl.java | 2 + .../service/impl/LevelServiceImpl.java | 1 + 9 files changed, 103 insertions(+), 35 deletions(-) create mode 100644 src/com/engine/organization/entity/staff/po/StaffPlanPO.java diff --git a/docs/表结构SQL/MySQL.sql b/docs/表结构SQL/MySQL.sql index ed849c42..3f4162b0 100644 --- a/docs/表结构SQL/MySQL.sql +++ b/docs/表结构SQL/MySQL.sql @@ -339,12 +339,12 @@ CREATE TABLE JCL_ORG_JOBEXT_DT1 ( -- JCL_ORG_STAFFPLAN CREATE TABLE JCL_ORG_STAFFPLAN ( id int auto_increment NOT NULL, - staffplan_no varchar(100) NULL, - staffplan_name varchar(100) NULL, - staffplan_year varchar(100) NULL, + plan_no varchar(100) NULL, + plan_name varchar(100) NULL, + plan_year varchar(100) NULL, time_start date NULL, time_end date NULL, - apply_company int NULL, + company_id varchar(100) NULL, description text NULL, status int NULL, creator int null, @@ -357,17 +357,17 @@ CREATE TABLE JCL_ORG_STAFFPLAN ( -- JCL_ORG_STAFF CREATE TABLE JCL_ORG_STAFF ( id int auto_increment NOT NULL, - scheme_id int null, - comp int null, - dept int null, - job int null, + plan_id int null, + comp_id int null, + dept_id int null, + job_id int null, staff_num int null, control_policy int null, staff_permanent_num int null, freeze_num int null, lack_status int null, staff_description varchar(100) NULL, - instruction text null, + description text null, creator int null, delete_type int null, create_time date null, diff --git a/docs/表结构SQL/Oracle.sql b/docs/表结构SQL/Oracle.sql index 8d554d2f..e8718031 100644 --- a/docs/表结构SQL/Oracle.sql +++ b/docs/表结构SQL/Oracle.sql @@ -340,12 +340,12 @@ CREATE TABLE JCL_ORG_JOBEXT_DT1 ( -- JCL_ORG_STAFFPLAN CREATE TABLE JCL_ORG_STAFFPLAN ( ID NUMBER NOT NULL, - STAFFPLAN_NO NVARCHAR2(100) NULL, - STAFFPLAN_NAME NVARCHAR2(100) NULL, - STAFFPLAN_YEAR NVARCHAR2(100) NULL, + PLAN_NO NVARCHAR2(100) NULL, + PLAN_NAME NVARCHAR2(100) NULL, + PLAN_YEAR NVARCHAR2(100) NULL, TIME_START DATE NULL, TIME_END DATE NULL, - APPLY_COMPANY NUMBER NULL, + COMPANY_ID NVARCHAR2(100) NULL, DESCRIPTION NVARCHAR2(1000) NULL, STATUS NUMBER NULL, CREATOR NUMBER NULL, @@ -358,17 +358,17 @@ CREATE TABLE JCL_ORG_STAFFPLAN ( -- JCL_ORG_STAFF CREATE TABLE JCL_ORG_STAFF ( ID NUMBER NOT NULL, - SCHEME_ID NUMBER NULL, - COMP NUMBER NULL, - DEPT NUMBER NULL, - JOB NUMBER NULL, + PLAN_ID NUMBER NULL, + COMP_ID NUMBER NULL, + DEPT_ID NUMBER NULL, + JOB_ID NUMBER NULL, STAFF_NUM NUMBER NULL, CONTROL_POLICY NUMBER NULL, STAFF_PERMANENT_NUM NUMBER NULL, FREEZE_NUM NUMBER NULL, LACK_STATUS NUMBER NULL, STAFF_DESCRIPTION NVARCHAR2(100) NULL, - INSTRUCTION NVARCHAR2(1000) NULL, + DESCRIPTION NVARCHAR2(1000) NULL, CREATOR NUMBER NULL, DELETE_TYPE NUMBER NULL, CREATE_TIME DATE NULL, diff --git a/docs/表结构SQL/SqlServer.sql b/docs/表结构SQL/SqlServer.sql index 930a8b57..6b740ca7 100644 --- a/docs/表结构SQL/SqlServer.sql +++ b/docs/表结构SQL/SqlServer.sql @@ -339,12 +339,12 @@ CREATE TABLE JCL_ORG_JOBEXT_DT1 ( -- JCL_ORG_STAFFPLAN CREATE TABLE JCL_ORG_STAFFPLAN ( id int IDENTITY(1,1) NOT NULL, - staffplan_no varchar(100) COLLATE Chinese_PRC_CI_AS NULL, - staffplan_name varchar(100) COLLATE Chinese_PRC_CI_AS NULL, - staffplan_year varchar(100) COLLATE Chinese_PRC_CI_AS NULL, + plan_no varchar(100) COLLATE Chinese_PRC_CI_AS NULL, + plan_name varchar(100) COLLATE Chinese_PRC_CI_AS NULL, + plan_year varchar(100) COLLATE Chinese_PRC_CI_AS NULL, time_start date NULL, time_end date NULL, - apply_company int NULL, + company_id varchar(100) COLLATE Chinese_PRC_CI_AS NULL, description text NULL, status int NULL, creator int null, @@ -357,17 +357,17 @@ CREATE TABLE JCL_ORG_STAFFPLAN ( -- JCL_ORG_STAFF CREATE TABLE JCL_ORG_STAFF ( id int IDENTITY(1,1) NOT NULL, - scheme_id int null, - comp int null, - dept int null, - job int null, + plan_id int null, + comp_id int null, + dept_id int null, + job_id int null, staff_num int null, control_policy int null, staff_permanent_num int null, freeze_num int null, lack_status int null, staff_description varchar(100) COLLATE Chinese_PRC_CI_AS NULL, - instruction text null, + description text null, creator int null, delete_type int null, create_time date null, diff --git a/src/com/engine/organization/entity/staff/po/StaffPlanPO.java b/src/com/engine/organization/entity/staff/po/StaffPlanPO.java new file mode 100644 index 00000000..a396cf57 --- /dev/null +++ b/src/com/engine/organization/entity/staff/po/StaffPlanPO.java @@ -0,0 +1,62 @@ +package com.engine.organization.entity.staff.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/24 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class StaffPlanPO { + /** + * 主键 + */ + private Long id; + /** + * 编号 + */ + private String planNo; + /** + * 名称 + */ + private String planName; + /** + * 年度 + */ + private Integer planYear; + /** + * 时间开始 + */ + private Date time_start; + /** + * 时间结束 + */ + private Date time_end; + /** + * 适用公司 + */ + private String companyId; + /** + * 说明 + */ + private String description; + /** + * 状态 + */ + private Integer forbiddenTag; + + private Long creator; + private int deleteType; + private Date createTime; + private Date updateTime; +} diff --git a/src/com/engine/organization/mapper/scheme/LevelMapper.xml b/src/com/engine/organization/mapper/scheme/LevelMapper.xml index c34dfe85..2f597ead 100644 --- a/src/com/engine/organization/mapper/scheme/LevelMapper.xml +++ b/src/com/engine/organization/mapper/scheme/LevelMapper.xml @@ -42,7 +42,7 @@ from jcl_org_level t where level_no = #{levelNo} AND delete_type = 0 + update jcl_org_comp @@ -211,4 +231,49 @@ WHERE id = #{id} AND delete_type = 0 + + + and t.comp_no like CONCAT('%',#{compNo},'%') + + + and t.comp_name like CONCAT('%',#{compName},'%') + + + and t.comp_name_short like CONCAT('%',#{compNameShort},'%') + + + and t.org_code like CONCAT('%',#{orgCode},'%') + + + + + + and t.comp_no like '%'||#{compNo}||'%' + + + and t.comp_name like '%'||#{compName}||'%' + + + and t.comp_name_short like '%'||#{compNameShort}||'%' + + + and t.org_code like '%'||#{orgCode}||'%' + + + + + + and t.comp_no like '%'+#{compNo}+'%' + + + and t.comp_name like '%'+#{compName}+'%' + + + and t.comp_name_short like '%'+#{compNameShort}+'%' + + + and t.org_code like '%'+#{orgCode}+'%' + + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.xml b/src/com/engine/organization/mapper/department/DepartmentMapper.xml index 9b022ad2..d8804f61 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.xml +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.xml @@ -64,7 +64,7 @@ and t.show_order = #{showOrder} - + and t.forbidden_tag = #{forbiddenTag} diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index 848ef467..aac49022 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -26,7 +26,6 @@ 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 org.apache.commons.collections4.CollectionUtils; import weaver.crm.Maint.SectorInfoComInfo; import weaver.general.StringUtil; import weaver.general.Util; @@ -75,25 +74,27 @@ public class CompServiceImpl extends Service implements CompService { @Override public Map listPage(CompSearchParam params) { Map datas = new HashMap<>(); - PageUtil.start(params.getCurrent(), params.getPageSize()); - List parentList = getCompMapper().listParent(); - - List list = new ArrayList<>(); - list.addAll(parentList); - - if (CollectionUtils.isNotEmpty(parentList)) { - // 递归查询子数据 - getChildPOs(parentList, list); - } - CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID()); - // 搜索条件过滤数据 - List filterList = filterListByParams(list, compPO); + boolean filter = isFilter(compPO); + PageInfo pageInfos; + List alltList = getCompMapper().list(); + // 通过子级遍历父级元素 + if (filter) { + // 根据条件获取元素 + List filterCompPOs = getCompMapper().listByFilter(compPO); + // 添加父级元素 + List compListDTOS = CompBO.buildCompDTOList(alltList, filterCompPOs); + List subList = PageUtil.subList(params.getCurrent(), params.getPageSize(), compListDTOS); + pageInfos = new PageInfo<>(subList, CompListDTO.class); + pageInfos.setTotal(compListDTOS.size()); + } else { + // 组合list + List compListDTOS = CompBO.buildCompDTOList(alltList); + List subList = PageUtil.subList(params.getCurrent(), params.getPageSize(), compListDTOS); + pageInfos = new PageInfo<>(subList, CompListDTO.class); + pageInfos.setTotal(compListDTOS.size()); + } - List compListDTOS = CompBO.buildCompDTOList(list, filterList); - PageInfo pageInfo = new PageInfo<>(compListDTOS); - PageInfo pageInfos = new PageInfo<>(compListDTOS, CompListDTO.class); - pageInfos.setTotal(pageInfo.getTotal()); pageInfos.setPageNum(params.getCurrent()); pageInfos.setPageSize(params.getPageSize()); @@ -262,10 +263,8 @@ public class CompServiceImpl extends Service implements CompService { // 简称 SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "简称", "compNameShort"); compNameShortItem.setRules("required|string"); - // TODO 自定义按钮 // 上级公司 - SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "上级公司", "161", "parentCompany", "compBrowser"); - compBrowserItem.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"); @@ -293,50 +292,14 @@ public class CompServiceImpl extends Service implements CompService { 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数据 - * - * @param compPOS * @param compPO * @return */ - private List filterListByParams(Collection compPOS, CompPO compPO) { - // 搜索后的数据 - List filterList = new ArrayList<>(); - // 筛选数据 - for (Iterator iterator = compPOS.iterator(); iterator.hasNext(); ) { - CompPO next = iterator.next(); - boolean isAdd = (StringUtil.isEmpty(compPO.getCompName()) || next.getCompName().contains(compPO.getCompName())) // 名称 - && (StringUtil.isEmpty(compPO.getCompNo()) || next.getCompNo().contains(compPO.getCompNo()))//编号 - && (StringUtil.isEmpty(compPO.getCompNameShort()) || next.getCompNameShort().contains(compPO.getCompNameShort()))//简称 - && (null == compPO.getParentCompany() || next.getParentCompany().equals(compPO.getParentCompany()))//上级公司 - && (StringUtil.isEmpty(compPO.getOrgCode()) || next.getOrgCode().contains(compPO.getOrgCode()))//组织机构代码 - && (null == compPO.getIndustry() || next.getIndustry().equals(compPO.getIndustry()))//行业 - && (null == compPO.getCompPrincipal() || next.getCompPrincipal().equals(compPO.getCompPrincipal()))//负责人 - && (null == compPO.getForbiddenTag() || next.getForbiddenTag().equals(compPO.getForbiddenTag()));//禁用标记 - if (isAdd) { - filterList.add(next); - } - - } - return filterList; + private boolean isFilter(CompPO compPO) { + return !(StringUtil.isEmpty(compPO.getCompName()) && StringUtil.isEmpty(compPO.getCompNo()) && null == compPO.getParentCompany() && StringUtil.isEmpty(compPO.getOrgCode()) && null == compPO.getIndustry() && null == compPO.getCompPrincipal() && null == compPO.getForbiddenTag()); } @@ -380,10 +343,12 @@ public class CompServiceImpl extends Service implements CompService { SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级公司", "161", "parentCompany", "compBrowser"); // 组织机构代码 SearchConditionItem orgCodeItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "组织机构代码", "orgCode"); + orgCodeItem.setRules("required|string"); // 行业 SearchConditionItem industryItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "行业", "63", "industry", ""); // 负责人 SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "负责人", "1", "compPrincipal", ""); + compPrincipalItem.setRules("required|string"); // 说明 SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 2, 60, "说明", "description"); diff --git a/src/com/engine/organization/service/impl/ExtServiceImpl.java b/src/com/engine/organization/service/impl/ExtServiceImpl.java index fc2b4edc..7bdb6612 100644 --- a/src/com/engine/organization/service/impl/ExtServiceImpl.java +++ b/src/com/engine/organization/service/impl/ExtServiceImpl.java @@ -27,6 +27,8 @@ import java.util.stream.Collectors; */ public class ExtServiceImpl extends Service implements ExtService { + private static final Integer BROWSER_TYPE = 3; + private ExtendInfoMapper getExtendInfoMapper() { return MapperProxyFactory.getProxy(ExtendInfoMapper.class); } @@ -82,8 +84,17 @@ public class ExtServiceImpl extends Service implements ExtService { tabinfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, entry.getValue(), viewAttr, showLabel)); tabinfoMap.put("rownum", "rownum"); - String fields = entry.getValue().stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); - tabinfoMap.put("datas", getExtDTMapper().listCompExtDT(tableName, id, fields)); + // 浏览按钮添加filespan字段 + String fields = entry.getValue().stream().map(item -> { + if (BROWSER_TYPE == item.getControlType()) { + return item.getFieldName() + "," + item.getFieldName() + "span"; + } + return item.getFieldName(); + }).collect(Collectors.joining(",")); + // 去除null 元素 + List> maps = getExtDTMapper().listCompExtDT(tableName, id, fields); + maps.removeIf(Objects::isNull); + tabinfoMap.put("datas", maps); tableMap.put("tabinfo", tabinfoMap); tables.add(tableMap); } @@ -147,10 +158,14 @@ public class ExtServiceImpl extends Service implements ExtService { getExtDTMapper().deleteByMainID(tableName, id); // 处理明细表数据 int rowNum = Util.getIntValue((String) params.get("rownum")); + rowNum = 5; for (int i = 0; i < rowNum; i++) { Map map = new HashMap<>(); - for (String dtField : dtFields) { - map.put(dtField, params.get(dtField + "_" + i)); + for (ExtendInfoPO extendInfoPO : dtInfoPOList) { + if (BROWSER_TYPE == extendInfoPO.getControlType()) { + map.put(extendInfoPO.getFieldName() + "span", params.get(extendInfoPO.getFieldName() + "span_" + i)); + } + map.put(extendInfoPO.getFieldName(), params.get(extendInfoPO.getFieldName() + "_" + i)); } map.put("mainid", id); map.put("creator", user.getUID()); diff --git a/src/com/engine/organization/service/impl/SequenceServiceImpl.java b/src/com/engine/organization/service/impl/SequenceServiceImpl.java index d33aafaa..58e22368 100644 --- a/src/com/engine/organization/service/impl/SequenceServiceImpl.java +++ b/src/com/engine/organization/service/impl/SequenceServiceImpl.java @@ -109,6 +109,7 @@ public class SequenceServiceImpl extends Service implements SequenceService { sequenceNoCondition.setRules("required|string"); SearchConditionItem descriptionCondition = OrganizationFormItemUtil.textareaItem(user, 2, 17, true, 2, 60, "描述说明", "description"); SearchConditionItem browserItem = OrganizationFormItemUtil.browserItem(user, 2, 17, 3, false, "等级方案", "161", "schemeId", "schemeBrowser"); + browserItem.setRules("required|string"); // 编辑状态下赋值操作 String id = Util.null2String(params.get("id")); From 3578a0f166fde85257c9123f86be17360e7170e1 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Wed, 25 May 2022 10:56:53 +0800 Subject: [PATCH 21/22] =?UTF-8?q?=E6=98=8E=E7=BB=86=E8=A1=A8=E6=9B=B4?= =?UTF-8?q?=E6=96=B0BUG=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CompServiceImpl.java | 10 +++- .../service/impl/ExtServiceImpl.java | 51 +++++++++---------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index aac49022..53b08975 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -292,6 +292,7 @@ public class CompServiceImpl extends Service implements CompService { return apiDatas; } + /** * 是否为搜索查询 * @@ -299,7 +300,14 @@ public class CompServiceImpl extends Service implements CompService { * @return */ private boolean isFilter(CompPO compPO) { - return !(StringUtil.isEmpty(compPO.getCompName()) && StringUtil.isEmpty(compPO.getCompNo()) && null == compPO.getParentCompany() && StringUtil.isEmpty(compPO.getOrgCode()) && null == compPO.getIndustry() && null == compPO.getCompPrincipal() && null == compPO.getForbiddenTag()); + return !(StringUtil.isEmpty(compPO.getCompName()) + && StringUtil.isEmpty(compPO.getCompNo()) + && StringUtil.isEmpty(compPO.getCompNameShort()) + && StringUtil.isEmpty(compPO.getOrgCode()) + && null == compPO.getParentCompany() + && null == compPO.getIndustry() + && null == compPO.getCompPrincipal() + && null == compPO.getForbiddenTag()); } diff --git a/src/com/engine/organization/service/impl/ExtServiceImpl.java b/src/com/engine/organization/service/impl/ExtServiceImpl.java index 7bdb6612..0b49db23 100644 --- a/src/com/engine/organization/service/impl/ExtServiceImpl.java +++ b/src/com/engine/organization/service/impl/ExtServiceImpl.java @@ -82,7 +82,7 @@ public class ExtServiceImpl extends Service implements ExtService { tableMap.put("tabname", getExtendGroupMapper().getGroupNameById(entry.getKey() + "")); Map tabinfoMap = new HashMap<>(); tabinfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, entry.getValue(), viewAttr, showLabel)); - tabinfoMap.put("rownum", "rownum"); + tabinfoMap.put("rownum", "rownum" + entry.getKey()); // 浏览按钮添加filespan字段 String fields = entry.getValue().stream().map(item -> { @@ -150,33 +150,32 @@ public class ExtServiceImpl extends Service implements ExtService { @Override public void updateExtDT(User user, String extendType, String tableName, Map params, Long id) { - List dtInfoPOList = getExtendInfoMapper().listFields(extendType, "", tableName); - List dtFields = dtInfoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList()); - - List> insertList = new ArrayList<>(); - // 删除明细表数据 - getExtDTMapper().deleteByMainID(tableName, id); - // 处理明细表数据 - int rowNum = Util.getIntValue((String) params.get("rownum")); - rowNum = 5; - for (int i = 0; i < rowNum; i++) { - Map map = new HashMap<>(); - for (ExtendInfoPO extendInfoPO : dtInfoPOList) { - if (BROWSER_TYPE == extendInfoPO.getControlType()) { - map.put(extendInfoPO.getFieldName() + "span", params.get(extendInfoPO.getFieldName() + "span_" + i)); + List dtInfoPOList = getExtendInfoMapper().listFields(extendType, "", ""); + Map groups = dtInfoPOList.stream().collect(Collectors.toMap(ExtendInfoPO::getExtendGroupId, ExtendInfoPO::getTableName, (k1, k2) -> k1)); + // 删除原有明细表数据 + groups.forEach((k, v) -> { + if (v.toLowerCase().contains("_dt")) getExtDTMapper().deleteByMainID(v, id); + }); + + for (Map.Entry entry : groups.entrySet()) { + int rowNum = Util.getIntValue((String) params.get("rownum" + entry.getKey())); + List filterS = dtInfoPOList.stream().filter(item -> entry.getKey().equals(item.getExtendGroupId())).collect(Collectors.toList()); + for (int i = 0; i < rowNum; i++) { + Map map = new HashMap<>(); + + for (ExtendInfoPO extendInfoPO : filterS) { + if (BROWSER_TYPE == extendInfoPO.getControlType()) { + map.put(extendInfoPO.getFieldName() + "span", params.get(extendInfoPO.getFieldName() + "span_" + i)); + } + map.put(extendInfoPO.getFieldName(), params.get(extendInfoPO.getFieldName() + "_" + i)); } - map.put(extendInfoPO.getFieldName(), params.get(extendInfoPO.getFieldName() + "_" + i)); + map.put("mainid", id); + map.put("creator", user.getUID()); + map.put("delete_type", 0); + map.put("create_time", new Date()); + map.put("update_time", new Date()); + getExtDTMapper().insertCompExtDT(entry.getValue(), map); } - map.put("mainid", id); - map.put("creator", user.getUID()); - map.put("delete_type", 0); - map.put("create_time", new Date()); - map.put("update_time", new Date()); - insertList.add(map); - } - // 更新拓展表数据 - for (Map map : insertList) { - getExtDTMapper().insertCompExtDT(tableName, map); } } } From c3395b65092412186b87a9b68ebc93eb0fadef80 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Thu, 26 May 2022 10:04:04 +0800 Subject: [PATCH 22/22] =?UTF-8?q?=E8=81=94=E6=9F=A5=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/department/bo/DepartmentBO.java | 37 +++++-------------- .../param/QuerySingleDeptListParam.java | 2 +- .../department/vo/SingleDeptTreeVO.java | 4 ++ .../mapper/department/DepartmentMapper.java | 2 +- .../mapper/department/DepartmentMapper.xml | 3 +- .../service/impl/DepartmentServiceImpl.java | 6 +-- 6 files changed, 20 insertions(+), 34 deletions(-) diff --git a/src/com/engine/organization/entity/department/bo/DepartmentBO.java b/src/com/engine/organization/entity/department/bo/DepartmentBO.java index d07d15ab..18fced97 100644 --- a/src/com/engine/organization/entity/department/bo/DepartmentBO.java +++ b/src/com/engine/organization/entity/department/bo/DepartmentBO.java @@ -72,23 +72,28 @@ public class DepartmentBO { .creator(employeeId).build(); } - public static List buildSingleDeptTreeVOS(List departmentPOs) { + public static List buildSingleDeptTreeVOS(List departmentPOs,Long parentComp) { if (CollectionUtils.isEmpty(departmentPOs)) { return Collections.emptyList(); } - List singleDeptTreeVOS = departmentPOs.stream().map(e -> SingleDeptTreeVO.builder() .id(e.getId()) .deptName(e.getDeptName()) - .parentDeptName(getDeptNameById(e.getParentDept().intValue())) + .parentComp(e.getParentComp()) + .parentDept(e.getParentDept()) + .parentDeptName(e.getParentDept() == null ? "" : getDeptNameById(e.getParentDept().intValue())) .deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal())) - .children(recursiveData(e.getId())) .build() ).collect(Collectors.toList()); + //获取非一级部门 + Map> collects = singleDeptTreeVOS.stream().filter(item -> !parentComp.equals(item.getParentComp()) && null != item.getParentDept()).collect(Collectors.groupingBy(SingleDeptTreeVO :: getParentDept)); - return singleDeptTreeVOS; + return singleDeptTreeVOS.stream().map(e -> { + e.setChildren(collects.get(e.getId())); + return e; + }).filter(item -> parentComp.equals(item.getParentComp())).collect(Collectors.toList()); } @@ -119,29 +124,7 @@ public class DepartmentBO { } } - /** - * 递归获取 - * - * @param parentDeptId - * @return - */ - public static List recursiveData(long parentDeptId) { - List departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByPId(parentDeptId); - if (CollectionUtils.isEmpty(departmentPOS)) { - return Collections.emptyList(); - } - - List singleDeptTreeVOS = departmentPOS.stream().map(e -> SingleDeptTreeVO.builder() - .id(e.getId()) - .deptName(e.getDeptName()) - .parentDeptName(getDeptNameById(e.getParentDept().intValue())) - .deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal())) - .children(recursiveData(e.getId())) - .build() - ).collect(Collectors.toList()); - return singleDeptTreeVOS; - } } diff --git a/src/com/engine/organization/entity/department/param/QuerySingleDeptListParam.java b/src/com/engine/organization/entity/department/param/QuerySingleDeptListParam.java index a0dd33d0..aee890e3 100644 --- a/src/com/engine/organization/entity/department/param/QuerySingleDeptListParam.java +++ b/src/com/engine/organization/entity/department/param/QuerySingleDeptListParam.java @@ -18,6 +18,6 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class QuerySingleDeptListParam extends BaseQueryParam { - private int parentComp; + private Long parentComp; } diff --git a/src/com/engine/organization/entity/department/vo/SingleDeptTreeVO.java b/src/com/engine/organization/entity/department/vo/SingleDeptTreeVO.java index 5055275b..c1536203 100644 --- a/src/com/engine/organization/entity/department/vo/SingleDeptTreeVO.java +++ b/src/com/engine/organization/entity/department/vo/SingleDeptTreeVO.java @@ -29,6 +29,10 @@ public class SingleDeptTreeVO { @TableTitle(title = "部门名称", dataIndex = "deptName", key = "deptName") private String deptName; + private Long parentComp; //上级分部 + + private Long parentDept; //上级部门id + @TableTitle(title = "上级部门", dataIndex = "parentDeptName", key = "parentDeptName") private String parentDeptName; //上级部门 diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.java b/src/com/engine/organization/mapper/department/DepartmentMapper.java index f11d7f57..f4eb2d5f 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.java +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.java @@ -14,7 +14,7 @@ import java.util.List; **/ public interface DepartmentMapper { - List getDeptListByCompId(@Param("parentComp") int parentComp); + List getDeptListByCompId(); List getDeptListByPId(@Param("PId") Long PId); diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.xml b/src/com/engine/organization/mapper/department/DepartmentMapper.xml index d8804f61..11061587 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.xml +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.xml @@ -19,10 +19,9 @@