diff --git a/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java b/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java index 3b54528e..9212661c 100644 --- a/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java +++ b/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java @@ -50,4 +50,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 2ecd1227..18ee6c5f 100644 --- a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java +++ b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java @@ -30,6 +30,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 fd6efbcb..a2b11df7 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} + getFieldDefinedInfo(ExtendTitleSaveParam param); } diff --git a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java index ab4e7471..87a10e94 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; @@ -20,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; @@ -33,6 +33,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); } @@ -63,7 +67,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"); @@ -77,8 +81,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; } @@ -148,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); @@ -160,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() diff --git a/src/com/engine/organization/web/FieldDefinedController.java b/src/com/engine/organization/web/FieldDefinedController.java index 8ac9d72d..4651fca6 100644 --- a/src/com/engine/organization/web/FieldDefinedController.java +++ b/src/com/engine/organization/web/FieldDefinedController.java @@ -124,4 +124,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 02622852..b8a39171 100644 --- a/src/com/engine/organization/wrapper/FieldDefinedWrapper.java +++ b/src/com/engine/organization/wrapper/FieldDefinedWrapper.java @@ -67,4 +67,8 @@ public class FieldDefinedWrapper extends Service { } + + public int deleteTitle(ExtendTitleSaveParam param) { + return getFieldDefinedService(user).deleteTitle(param); + } }