From 6d4448ec51c98ec9f4a5bbece6d3710d80b7651b Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Thu, 16 Jun 2022 17:57:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=90=E4=BF=A1=E6=81=AF=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/extend/bo/ExtendGroupBO.java | 5 +- .../entity/extend/po/ExtendGroupPO.java | 2 + .../fieldset/param/FieldTypeTreeParam.java | 4 +- .../mapper/extend/ExtendGroupMapper.java | 8 ++- .../mapper/extend/ExtendGroupMapper.xml | 27 ++++++++ .../service/FieldDefinedService.java | 12 ++++ .../service/impl/FieldDefinedServiceImpl.java | 63 +++++++++++++++++-- .../web/FieldDefinedController.java | 23 +++++-- .../wrapper/FieldDefinedWrapper.java | 13 +++- 9 files changed, 141 insertions(+), 16 deletions(-) diff --git a/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java b/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java index 9212661c..2ff9f23b 100644 --- a/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java +++ b/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java @@ -5,6 +5,7 @@ import com.engine.organization.entity.extend.po.ExtendTitlePO; import com.engine.organization.entity.fieldset.vo.TypeTreeVO; import com.engine.organization.mapper.extend.ExtendTitleMapper; import com.engine.organization.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; import org.apache.commons.collections.CollectionUtils; import java.util.Collections; @@ -29,7 +30,9 @@ public class ExtendGroupBO { List typeTreeVOS = extendGroupPOS.stream().map(e -> TypeTreeVO.builder() .canClick(true) + .addChild(e.getPid() == null) .domid(String.valueOf(e.getId())) + .childs(Lists.newArrayList()) .hasGroup(isHasGroup(e.getId())) .isShow(e.getIsShow()) .key(e.getId()) @@ -42,7 +45,7 @@ public class ExtendGroupBO { Map> collects = typeTreeVOS.stream().filter(item -> item.getPid() != null).collect(Collectors.groupingBy(TypeTreeVO :: getPid)); return typeTreeVOS.stream().peek(e -> {e.setChilds(collects.get(e.getKey())); e.setHaschild(collects.get(e.getKey()) != null && collects.get(e.getKey()).size() > 0); - e.setAddChild(collects.get(e.getKey()) != null && collects.get(e.getKey()).size() > 0);}).filter(item -> item.getPid() == null).collect(Collectors.toList()); + }).filter(item -> item.getPid() == null).collect(Collectors.toList()); } diff --git a/src/com/engine/organization/entity/extend/po/ExtendGroupPO.java b/src/com/engine/organization/entity/extend/po/ExtendGroupPO.java index 1c9404d7..5e549ee3 100644 --- a/src/com/engine/organization/entity/extend/po/ExtendGroupPO.java +++ b/src/com/engine/organization/entity/extend/po/ExtendGroupPO.java @@ -40,6 +40,8 @@ public class ExtendGroupPO { private String isShow; + private Integer showOrder; + private Long creator; private int deleteType; private Date createTime; diff --git a/src/com/engine/organization/entity/fieldset/param/FieldTypeTreeParam.java b/src/com/engine/organization/entity/fieldset/param/FieldTypeTreeParam.java index 57e20c61..a9100ecc 100644 --- a/src/com/engine/organization/entity/fieldset/param/FieldTypeTreeParam.java +++ b/src/com/engine/organization/entity/fieldset/param/FieldTypeTreeParam.java @@ -20,9 +20,11 @@ import java.util.List; @AllArgsConstructor public class FieldTypeTreeParam { + private String data; //信息维护json数据 + private Long id; - private Long parentid; + private Long parentId; private String name; diff --git a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java index 18ee6c5f..48aaae09 100644 --- a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java +++ b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java @@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param; import java.util.Collection; import java.util.List; +import java.util.Set; /** * @description: @@ -48,10 +49,13 @@ public interface ExtendGroupMapper { */ String getGroupNameById(@Param("id") String id); + void insertIgnoreNull(ExtendGroupPO extendGroupPO); + void update(@Param("id")Long id, @Param("name")String name); - void insertIgnoreNull(ExtendGroupPO extendGroupPO); + void delete(@Param("id") Long id); + void updateNameAndOrder(@Param("id")Long id, @Param("groupName")String groupName, @Param("showOrder")Integer showOrder); - void update(@Param("id")Long id, @Param("name")String name); + void batchDelete(@Param("ids")Set removeSet); } diff --git a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml index a2b11df7..d3b24e9d 100644 --- a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml +++ b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml @@ -134,4 +134,31 @@ WHERE id = #{id} AND delete_type = 0 + + update jcl_field_extendgroup + + delete_type=1, + + WHERE id = #{id} AND delete_type = 0 + + + + update jcl_field_extendgroup + + group_name=#{groupName}, + show_order=#{showOrder} + + WHERE id = #{id} AND delete_type = 0 + + + + UPDATE jcl_field_extendgroup + 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/FieldDefinedService.java b/src/com/engine/organization/service/FieldDefinedService.java index 113eeea9..3d7244ef 100644 --- a/src/com/engine/organization/service/FieldDefinedService.java +++ b/src/com/engine/organization/service/FieldDefinedService.java @@ -81,4 +81,16 @@ public interface FieldDefinedService { */ Map getFieldDefinedInfo(ExtendTitleSaveParam param); + /** + * 删除树类型 + * @param id + */ + void deleteTree(Long id); + + /** + * 子信息维护 + * @param moduleTypeEnum + * @param fieldTypeTreeParam + */ + void saveTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam); } diff --git a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java index c2cc48b8..ad7a26e9 100644 --- a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java +++ b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java @@ -27,6 +27,7 @@ import org.apache.commons.lang.StringUtils; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @Author weaver_cl @@ -180,10 +181,14 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ @Override public void changeTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { if (fieldTypeTreeParam.getId() == null) { - ExtendGroupPO extendGroupPO = buildExtendGroupType(moduleTypeEnum, fieldTypeTreeParam); + List extendGroupPOList = MapperProxyFactory.getProxy(ExtendGroupMapper.class).listGroupByPid(fieldTypeTreeParam.getParentId()); + ExtendGroupPO extendGroup = extendGroupPOList.stream().max(Comparator.comparing(ExtendGroupPO::getShowOrder)).get(); + ExtendGroupPO extendGroupPO = buildExtendGroupType(moduleTypeEnum, fieldTypeTreeParam,extendGroup.getShowOrder()); MapperProxyFactory.getProxy(ExtendGroupMapper.class).insertIgnoreNull(extendGroupPO); //默认新增title - ExtendTitlePO extendTitlePO = buildExtendTitleType(extendGroupPO); + List titlesByGroupID = getExtendTitleMapper().getTitlesByGroupID(extendGroup.getId()); + ExtendTitlePO extendTitle = titlesByGroupID.stream().max(Comparator.comparing(ExtendTitlePO::getShowOrder)).get(); + ExtendTitlePO extendTitlePO = buildExtendTitleType(extendGroupPO,extendTitle.getShowOrder()); MapperProxyFactory.getProxy(ExtendTitleMapper.class).insertIgnoreNull(extendTitlePO); } else { MapperProxyFactory.getProxy(ExtendGroupMapper.class).update(fieldTypeTreeParam.getId(), fieldTypeTreeParam.getName()); @@ -198,14 +203,59 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ @Override public Map getFieldDefinedInfo(ExtendTitleSaveParam param) { + return null; } - private ExtendTitlePO buildExtendTitleType(ExtendGroupPO extendGroupPO) { + @Override + public void deleteTree(Long id) { + MapperProxyFactory.getProxy(ExtendGroupMapper.class).delete(id); + } + + @Override + public void saveTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { + List collect = MapperProxyFactory.getProxy(ExtendGroupMapper.class) + .listGroupByPid(fieldTypeTreeParam.getParentId()).stream().map(ExtendGroupPO::getId).collect(Collectors.toList()); + Integer extendType = moduleTypeEnum.getValue(); + List extendGroupPOS = JSONArray.parseArray(fieldTypeTreeParam.getData(),ExtendGroupPO.class); + + List collect1 = extendGroupPOS.stream().map(ExtendGroupPO::getId).collect(Collectors.toList()); + Set removeSet = new HashSet<>(); + collect1.forEach(e->{ + if(!collect.contains(e)){ + removeSet.add(e); + } + }); + MapperProxyFactory.getProxy(ExtendGroupMapper.class).batchDelete(removeSet); + + int showOrder = 0; + extendGroupPOS.forEach(e -> { + e.setExtendType(extendType); + e.setPid(fieldTypeTreeParam.getParentId()); + e.setIsShow(fieldTypeTreeParam.getIsShow()); + e.setShowOrder(showOrder+1); + e.setCreator((long)user.getUID()); + e.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + e.setCreateTime(new Date()); + e.setUpdateTime(new Date()); + + if (e.getId() == null){//新增 + MapperProxyFactory.getProxy(ExtendGroupMapper.class).insertIgnoreNull(e); + }else { //更新 + MapperProxyFactory.getProxy(ExtendGroupMapper.class).updateNameAndOrder(e.getId(),e.getGroupName(),e.getShowOrder()); + } + }); + + + + + } + + private ExtendTitlePO buildExtendTitleType(ExtendGroupPO extendGroupPO,Integer max) { return ExtendTitlePO.builder() .groupId(extendGroupPO.getId()) .title(extendGroupPO.getGroupName()) - .showOrder(1) + .showOrder(++max) .isShow("1") .creator((long) user.getUID()) .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) @@ -214,15 +264,16 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ } - private ExtendGroupPO buildExtendGroupType(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { + private ExtendGroupPO buildExtendGroupType(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam,Integer max) { return ExtendGroupPO.builder() .extendType(moduleTypeEnum.getValue()) .groupName(fieldTypeTreeParam.getName()) + .showOrder(++max) .creator((long) user.getUID()) .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) .createTime(new Date()) .updateTime(new Date()) - .pid(fieldTypeTreeParam.getParentid()) + .pid(fieldTypeTreeParam.getParentId()) .isShow(fieldTypeTreeParam.getIsShow() == null ? "1" : fieldTypeTreeParam.getIsShow()).build(); } diff --git a/src/com/engine/organization/web/FieldDefinedController.java b/src/com/engine/organization/web/FieldDefinedController.java index dbefccf1..d45ddaea 100644 --- a/src/com/engine/organization/web/FieldDefinedController.java +++ b/src/com/engine/organization/web/FieldDefinedController.java @@ -47,10 +47,10 @@ public class FieldDefinedController { @Path("/{moduleTypeEnum}/saveTree") @Produces(MediaType.APPLICATION_JSON) public ReturnResult saveTree(@Context HttpServletRequest request, @Context HttpServletResponse response, - @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum) { + @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum,@RequestBody FieldTypeTreeParam fieldTypeTreeParam) { try { User user = HrmUserVarify.getUser(request, response); - return getFieldDefinedWrapper(user).getTree(moduleTypeEnum); + return getFieldDefinedWrapper(user).saveTree(moduleTypeEnum,fieldTypeTreeParam); } catch (Exception e) { return ReturnResult.exceptionHandle(e.getMessage()); } @@ -69,6 +69,21 @@ public class FieldDefinedController { } } + @POST + @Path("/{moduleTypeEnum}/deleteTree") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult deleteTree(@Context HttpServletRequest request, @Context HttpServletResponse response, + @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum, @RequestBody FieldTypeTreeParam fieldTypeTreeParam) { + try { + User user = HrmUserVarify.getUser(request, response); + return getFieldDefinedWrapper(user).deleteTree(fieldTypeTreeParam.getId()); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + + + @GET @Path("/{moduleTypeEnum}/getTabInfo") @@ -127,10 +142,10 @@ public class FieldDefinedController { @POST @Path("/{moduleTypeEnum}/deleteTitle") @Produces(MediaType.APPLICATION_JSON) - public ReturnResult deleteTitle(@Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum, @QueryParam("id") Long id) { + public ReturnResult deleteTitle(@Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum, @RequestBody ExtendTitleSaveParam param) { try { User user = HrmUserVarify.getUser(request, response); - return ReturnResult.successed(getFieldDefinedWrapper(user).deleteTitle(id)); + return ReturnResult.successed(getFieldDefinedWrapper(user).deleteTitle(param.getId())); } catch (Exception e) { return ReturnResult.exceptionHandle(e.getMessage()); } diff --git a/src/com/engine/organization/wrapper/FieldDefinedWrapper.java b/src/com/engine/organization/wrapper/FieldDefinedWrapper.java index 77876ce4..a6ff4abb 100644 --- a/src/com/engine/organization/wrapper/FieldDefinedWrapper.java +++ b/src/com/engine/organization/wrapper/FieldDefinedWrapper.java @@ -66,9 +66,18 @@ public class FieldDefinedWrapper extends Service { return ReturnResult.successed(); } - - public int deleteTitle(Long id) { return getFieldDefinedService(user).deleteTitle(id); } + + + public ReturnResult deleteTree(Long id) { + getFieldDefinedService(user).deleteTree(id); + return ReturnResult.successed(); + } + + public ReturnResult saveTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { + getFieldDefinedService(user).saveTree(moduleTypeEnum, fieldTypeTreeParam); + return ReturnResult.successed(); + } }