From 7c02e9bc61b33b780754b5d69a26d2a4b6d8c910 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Wed, 15 Jun 2022 18:03:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=86=E7=BB=84=E5=88=A0=E9=99=A4=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/extend/bo/ExtendGroupBO.java | 41 ++++++++- .../entity/extend/bo/ExtendInfoBO.java | 12 ++- .../extend/param/ExtendInfoFieldParam.java | 92 +++++++++++++++++++ .../extend/param/ExtendInfoTypeParam.java | 26 ++++++ .../extend/param/ExtendTitleSaveParam.java | 2 +- .../mapper/extend/ExtendGroupMapper.java | 2 + .../mapper/extend/ExtendGroupMapper.xml | 7 ++ .../service/FieldDefinedService.java | 18 ++++ .../service/impl/FieldDefinedServiceImpl.java | 40 ++++++-- .../web/FieldDefinedController.java | 16 +++- .../wrapper/FieldDefinedWrapper.java | 8 +- 11 files changed, 249 insertions(+), 15 deletions(-) create mode 100644 src/com/engine/organization/entity/extend/param/ExtendInfoFieldParam.java create mode 100644 src/com/engine/organization/entity/extend/param/ExtendInfoTypeParam.java diff --git a/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java b/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java index cf4f9b6a..2b49bf14 100644 --- a/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java +++ b/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java @@ -22,7 +22,7 @@ public class ExtendGroupBO { public static List buildTypeTree(List extendGroupPOS) { - if(CollectionUtils.isEmpty(extendGroupPOS)){ + if (CollectionUtils.isEmpty(extendGroupPOS)) { return Collections.emptyList(); } @@ -40,9 +40,12 @@ public class ExtendGroupBO { .build()).collect(Collectors.toList()); //获取非一级 - Map> collects = typeTreeVOS.stream().filter(item -> item.getPid() != null).collect(Collectors.groupingBy(TypeTreeVO :: getPid)); + 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);}).filter(item -> item.getPid() == null).collect(Collectors.toList()); + return typeTreeVOS.stream().peek(e -> { + e.setChilds(collects.get(e.getKey())); + e.setHaschild(collects.get(e.getKey()) != null && collects.get(e.getKey()).size() > 0); + }).filter(item -> item.getPid() == null).collect(Collectors.toList()); } @@ -50,4 +53,36 @@ public class ExtendGroupBO { List titlesByGroupID = MapperProxyFactory.getProxy(ExtendTitleMapper.class).getTitlesByGroupID(id); return titlesByGroupID.size() > 0; } + + /** + * 获取对应表名 + * + * @param extendGroupPO + * @return + */ + public static String getTableNameByGroupPO(ExtendGroupPO extendGroupPO) { + String tableName = ""; + switch (extendGroupPO.getExtendType()) { + case -1: + tableName = "JCL_ORG_COMP"; + break; + case -2: + tableName = "JCL_ORG_DEPT"; + break; + case -3: + tableName = "JCL_ORG_JOB"; + break; + default: + break; + } + + if (extendGroupPO.getId() < 0) { + + } else if (null == extendGroupPO.getPid()) { + tableName += "EXT"; + } else { + tableName += "EXT_DT1"; + } + return tableName; + } } diff --git a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java index bd3a85c3..73a2f1c8 100644 --- a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java +++ b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java @@ -13,6 +13,7 @@ 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.SelectOptionParam; +import com.engine.organization.entity.extend.param.ExtendInfoFieldParam; import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.util.OrganizationFormItemUtil; import com.engine.sensitive.biz.SensitiveWordTypeComInfo; @@ -65,6 +66,15 @@ public class ExtendInfoBO { } + public static ExtendInfoPO convertFieldParam2ExtendInfo(ExtendInfoFieldParam infoFieldParam) { + if (null == infoFieldParam) { + return null; + } + return ExtendInfoPO + .builder() + + .build(); + } /** * 明细表字段 @@ -311,7 +321,7 @@ public class ExtendInfoBO { detailtype = "1"; } searchConditionItem.setKey(Util.null2String(fieldvalue)); - searchConditionItem.setValue(fieldvalue+""); + searchConditionItem.setValue(fieldvalue + ""); searchConditionItem.setDetailtype(Util.getIntValue(detailtype, 3)); } else if (fieldhtmltype.equals("6")) {//附件 if (fieldname.equals("resourceimageid")) { diff --git a/src/com/engine/organization/entity/extend/param/ExtendInfoFieldParam.java b/src/com/engine/organization/entity/extend/param/ExtendInfoFieldParam.java new file mode 100644 index 00000000..783eefe9 --- /dev/null +++ b/src/com/engine/organization/entity/extend/param/ExtendInfoFieldParam.java @@ -0,0 +1,92 @@ +package com.engine.organization.entity.extend.param; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import weaver.general.Util; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/06/15 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ExtendInfoFieldParam { + private String id; + // field_name + private String fieldname; + // field_name_desc + private String fieldlabel; + + private Object fieldType; + + private ExtendInfoTypeParam infoTypeParam; + + private String enable; + + private String required; + + private String isModify; + + private String key; + + public String getControlType() { + JSONArray fieldType = (JSONArray) this.getFieldType(); + ExtendInfoTypeParam infoTypeParam = new ExtendInfoTypeParam(); + String fieldHtmlType = Util.null2String(fieldType.get(0)); + if (fieldHtmlType.equals("input")) { + fieldHtmlType = "1"; + } else if (fieldHtmlType.equals("textarea")) { + fieldHtmlType = "2"; + } else if (fieldHtmlType.equals("browser")) { + fieldHtmlType = "3"; + } else if (fieldHtmlType.equals("check")) { + fieldHtmlType = "4"; + } else if (fieldHtmlType.equals("select")) { + fieldHtmlType = "5"; + } else if (fieldHtmlType.equals("upload")) { + fieldHtmlType = "6"; + } + return fieldHtmlType; + } + + public String getBrowserType(String controlType) { + String browserType = "1"; + JSONArray fieldType = (JSONArray) this.getFieldType(); + if (fieldType.size() > 1) { + browserType = Util.null2String(fieldType.get(1)); + } + if (controlType.equals("1")) { + if (browserType.equals("text")) { + browserType = "1"; + } else if (browserType.equals("int")) { + browserType = "2"; + } else if (browserType.equals("float")) { + browserType = "3"; + } else if (browserType.equals("file")) { + browserType = "1"; + } + } + if (controlType.equals("2")) { + browserType = "1"; + } else if (controlType.equals("3")) { + browserType = Util.null2String(((JSONObject) fieldType.get(1)).get("value")); + } else if (controlType.equals("4")) { + browserType = "1"; + } else if (controlType.equals("5")) { + browserType = "1"; + } else if (controlType.equals("6")) { + if (browserType.equals("file")) { + browserType = "1"; + } + } + return browserType; + } +} \ No newline at end of file diff --git a/src/com/engine/organization/entity/extend/param/ExtendInfoTypeParam.java b/src/com/engine/organization/entity/extend/param/ExtendInfoTypeParam.java new file mode 100644 index 00000000..c87de8e2 --- /dev/null +++ b/src/com/engine/organization/entity/extend/param/ExtendInfoTypeParam.java @@ -0,0 +1,26 @@ +package com.engine.organization.entity.extend.param; + +import com.engine.hrm.entity.FieldSelectOptionBean; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/06/15 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ExtendInfoTypeParam { + private String fieldHtmlType; + private String fieldType; + private Object otherParam; + private List lsSelectOption; +} diff --git a/src/com/engine/organization/entity/extend/param/ExtendTitleSaveParam.java b/src/com/engine/organization/entity/extend/param/ExtendTitleSaveParam.java index 802a425d..60e54077 100644 --- a/src/com/engine/organization/entity/extend/param/ExtendTitleSaveParam.java +++ b/src/com/engine/organization/entity/extend/param/ExtendTitleSaveParam.java @@ -17,7 +17,7 @@ import lombok.NoArgsConstructor; public class ExtendTitleSaveParam { private String data; private Long groupType; - + private Long id; private String groupName; private String isShow; diff --git a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java index 5e9f00fb..fc963a71 100644 --- a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java +++ b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java @@ -29,6 +29,8 @@ public interface ExtendGroupMapper { */ List listGroupByIds(@Param("ids") Collection ids); + ExtendGroupPO getGroupById(@Param("id") Long id); + /** * 根据ID 查询数据 * diff --git a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml index 16fa249a..370e821c 100644 --- a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml +++ b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml @@ -59,6 +59,13 @@ WHERE t.delete_type = 0 and t.is_show = 1 and t.pid= #{pid} + \ 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 6a5cdd02..07215b80 100644 --- a/src/com/engine/organization/service/FieldDefinedService.java +++ b/src/com/engine/organization/service/FieldDefinedService.java @@ -20,6 +20,7 @@ public interface FieldDefinedService { /** * 获取左侧树 + * * @param moduleTypeEnum * @return */ @@ -60,10 +61,27 @@ public interface FieldDefinedService { /** * 新增类型树 + * * @param moduleTypeEnum * @param fieldTypeTreeParam * @return */ void addTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam); + /** + * 删除标题信息 + * + * @param param + * @return + */ + int deleteTitle(ExtendTitleSaveParam param); + + /** + * 获取自定义字段列表 + * + * @param param + * @return + */ + Map getFieldDefinedInfo(ExtendTitleSaveParam param); + } diff --git a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java index 10a95554..6e237cc7 100644 --- a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java +++ b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.engine.core.impl.Service; +import com.engine.organization.entity.DeleteParam; import com.engine.organization.entity.extend.bo.ExtendGroupBO; import com.engine.organization.entity.extend.param.ExtendTitleSaveParam; import com.engine.organization.entity.extend.po.ExtendGroupPO; @@ -19,7 +20,6 @@ import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.db.MapperProxyFactory; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; -import weaver.general.Util; import java.util.*; import java.util.stream.Collectors; @@ -32,6 +32,10 @@ import java.util.stream.Collectors; **/ public class FieldDefinedServiceImpl extends Service implements FieldDefinedService { + private ExtendGroupMapper getExtendGroupMapper() { + return MapperProxyFactory.getProxy(ExtendGroupMapper.class); + } + private ExtendTitleMapper getExtendTitleMapper() { return MapperProxyFactory.getProxy(ExtendTitleMapper.class); } @@ -62,7 +66,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ tab.put("isShow", extendTitle.getIsShow()); tab.put("groupid", extendTitle.getGroupId()); tab.put("viewAttr", extendTitle.getGroupId() < 0 ? 1 : 2); - tab.put("editable", getExtendInfoMapper().countFieldsByGroupId(extendTitle.getId()) > 0); + tab.put("editable", !(getExtendInfoMapper().countFieldsByGroupId(extendTitle.getId()) > 0)); tabs.add(tab); } datas.put("status", "1"); @@ -76,8 +80,19 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ return 0; } JSONObject jsonObject = JSON.parseObject(data); - String groupType = Util.null2String(jsonObject.getString("groupType")); - String groupId = Util.null2String(jsonObject.getString("groupId")); + // extend_group主键 + Long groupType = jsonObject.getLong("groupType"); + ExtendGroupPO extendGroup = getExtendGroupMapper().getGroupById(groupType); + Integer extendType = extendGroup.getExtendType(); + String tableName = ExtendGroupBO.getTableNameByGroupPO(extendGroup); + + // 主表、主表拓展表为extend_title主键;明细表为extend_group主键 + Long extendGroupId = jsonObject.getLong("groupId"); + + JSONArray records = (JSONArray) jsonObject.get("records"); + for (int i = 0; i < records.size(); i++) { + + } return 0; } @@ -140,6 +155,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ extendTitle.setCreateTime(new Date()); extendTitle.setDeleteType(0); getExtendTitleMapper().insertIgnoreNull(extendTitle); + ids.add(extendTitle.getId()); datas.put("groupid", StringUtils.join(ids, ",")); @@ -147,16 +163,26 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ return datas; } + @Override public void addTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { - buildExtentGroup(moduleTypeEnum,fieldTypeTreeParam); + buildExtentGroup(moduleTypeEnum, fieldTypeTreeParam); } - private void buildExtentGroup(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { - + @Override + public int deleteTitle(ExtendTitleSaveParam param) { + int countFields = getExtendInfoMapper().countFieldsByGroupId(param.getGroupType()); + OrganizationAssert.isTrue(countFields == 0, "当前分组下仍有字段信息,请删除字段信息后删除分组"); + return getExtendTitleMapper().deleteExtendTitleByIds(DeleteParam.builder().ids(param.getId().toString()).build().getIds()); } + @Override + public Map getFieldDefinedInfo(ExtendTitleSaveParam param) { + return null; + } + private void buildExtentGroup(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { + } } diff --git a/src/com/engine/organization/web/FieldDefinedController.java b/src/com/engine/organization/web/FieldDefinedController.java index 552a6717..2ed51ae1 100644 --- a/src/com/engine/organization/web/FieldDefinedController.java +++ b/src/com/engine/organization/web/FieldDefinedController.java @@ -34,7 +34,7 @@ public class FieldDefinedController { @Path("/{moduleTypeEnum}/getTree") @Produces(MediaType.APPLICATION_JSON) public ReturnResult getTree(@Context HttpServletRequest request, @Context HttpServletResponse response, - @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum) { + @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum) { try { User user = HrmUserVarify.getUser(request, response); return getFieldDefinedWrapper(user).getTree(moduleTypeEnum); @@ -63,7 +63,7 @@ public class FieldDefinedController { @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum, @RequestBody FieldTypeTreeParam fieldTypeTreeParam) { try { User user = HrmUserVarify.getUser(request, response); - return getFieldDefinedWrapper(user).addTree(moduleTypeEnum,fieldTypeTreeParam); + return getFieldDefinedWrapper(user).addTree(moduleTypeEnum, fieldTypeTreeParam); } catch (Exception e) { return ReturnResult.exceptionHandle(e.getMessage()); } @@ -135,4 +135,16 @@ public class FieldDefinedController { return ReturnResult.exceptionHandle(e.getMessage()); } } + + @POST + @Path("/deleteTitle") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult deleteTitle(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtendTitleSaveParam param) { + try { + User user = HrmUserVarify.getUser(request, response); + return ReturnResult.successed(getFieldDefinedWrapper(user).deleteTitle(param)); + } 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 0aa5b93e..31353d3c 100644 --- a/src/com/engine/organization/wrapper/FieldDefinedWrapper.java +++ b/src/com/engine/organization/wrapper/FieldDefinedWrapper.java @@ -34,6 +34,7 @@ public class FieldDefinedWrapper extends Service { /** * 获取标题分组 + * * @param groupType * @return */ @@ -53,6 +54,7 @@ public class FieldDefinedWrapper extends Service { /** * 新建分组 + * * @param param * @return */ @@ -62,7 +64,11 @@ public class FieldDefinedWrapper extends Service { public ReturnResult addTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { - getFieldDefinedService(user).addTree(moduleTypeEnum,fieldTypeTreeParam); + getFieldDefinedService(user).addTree(moduleTypeEnum, fieldTypeTreeParam); return ReturnResult.successed(); } + + public int deleteTitle(ExtendTitleSaveParam param) { + return getFieldDefinedService(user).deleteTitle(param); + } } From 70de6bbbd7ac12158afe2bd20d4f7456bdd68486 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Wed, 15 Jun 2022 18:12:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=84=E7=90=86=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/service/FieldDefinedService.java | 14 ++++++++++++++ .../service/impl/FieldDefinedServiceImpl.java | 13 ++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/com/engine/organization/service/FieldDefinedService.java b/src/com/engine/organization/service/FieldDefinedService.java index 82f386ee..958a4aa9 100644 --- a/src/com/engine/organization/service/FieldDefinedService.java +++ b/src/com/engine/organization/service/FieldDefinedService.java @@ -65,6 +65,20 @@ public interface FieldDefinedService { * @return */ void changeTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam); + /** + * 删除标题信息 + * + * @param param + * @return + */ + int deleteTitle(ExtendTitleSaveParam param); + /** + * 获取自定义字段列表 + * + * @param param + * @return + */ + Map getFieldDefinedInfo(ExtendTitleSaveParam param); } diff --git a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java index 89d46f92..87a10e94 100644 --- a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java +++ b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java @@ -21,7 +21,6 @@ import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.db.MapperProxyFactory; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; -import weaver.general.Util; import java.util.*; import java.util.stream.Collectors; @@ -164,6 +163,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ return datas; } + @Override public void changeTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { if (fieldTypeTreeParam.getId() == null) { ExtendGroupPO extendGroupPO = buildExtendGroupType(moduleTypeEnum, fieldTypeTreeParam); @@ -176,6 +176,17 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ } } + @Override + public int deleteTitle(ExtendTitleSaveParam param) { + int countFields = getExtendInfoMapper().countFieldsByGroupId(param.getGroupType()); + OrganizationAssert.isTrue(countFields == 0, "当前分组下仍有字段信息,请删除字段信息后删除分组"); + return getExtendTitleMapper().deleteExtendTitleByIds(DeleteParam.builder().ids(param.getId().toString()).build().getIds()); + } + + @Override + public Map getFieldDefinedInfo(ExtendTitleSaveParam param) { + return null; + } private ExtendTitlePO buildExtendTitleType(ExtendGroupPO extendGroupPO) { return ExtendTitlePO.builder()