自定义字段列表
This commit is contained in:
parent
456e2ecc59
commit
08ca2e0c5d
|
|
@ -57,4 +57,34 @@ public class SelectOptionParam {
|
|||
}
|
||||
return customValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取自定义浏览按钮标识
|
||||
*
|
||||
* @param customValue
|
||||
* @return
|
||||
*/
|
||||
public static String getCustomBrowserValueSpan(String customValue) {
|
||||
JSONArray objects = JSONObject.parseArray(customValue);
|
||||
if (null != objects && objects.size() > 2) {
|
||||
JSONObject object = (JSONObject) objects.get(2);
|
||||
return object.getString("valueSpan");
|
||||
}
|
||||
return customValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文本长度
|
||||
*
|
||||
* @param customValue
|
||||
* @return
|
||||
*/
|
||||
public static String getTextLength(String customValue) {
|
||||
JSONArray objects = JSONObject.parseArray(customValue);
|
||||
|
||||
if (null != objects && objects.size() > 2) {
|
||||
return objects.get(2).toString();
|
||||
}
|
||||
return customValue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.engine.organization.entity.extend.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/06/16
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ExtendFieldSearchParam {
|
||||
private String groupId;
|
||||
private String groupType;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.engine.organization.service;
|
||||
|
||||
|
||||
import com.engine.organization.entity.extend.param.ExtendFieldSearchParam;
|
||||
import com.engine.organization.entity.extend.param.ExtendTitleSaveParam;
|
||||
import com.engine.organization.entity.fieldset.param.FieldTypeTreeParam;
|
||||
import com.engine.organization.entity.fieldset.vo.TypeTreeVO;
|
||||
|
|
@ -79,6 +80,6 @@ public interface FieldDefinedService {
|
|||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getFieldDefinedInfo(ExtendTitleSaveParam param);
|
||||
Map<String, Object> getFieldDefinedInfo(ExtendFieldSearchParam param);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ 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.SelectOptionParam;
|
||||
import com.engine.organization.entity.extend.bo.ExtendGroupBO;
|
||||
import com.engine.organization.entity.extend.bo.ExtendInfoBO;
|
||||
import com.engine.organization.entity.extend.param.ExtendFieldSearchParam;
|
||||
import com.engine.organization.entity.extend.param.ExtendInfoFieldParam;
|
||||
import com.engine.organization.entity.extend.param.ExtendTitleSaveParam;
|
||||
import com.engine.organization.entity.extend.po.ExtendGroupPO;
|
||||
|
|
@ -24,6 +26,9 @@ 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 weaver.systeminfo.SystemEnv;
|
||||
import weaver.workflow.field.BrowserComInfo;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -91,7 +96,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
|
|||
// 主表、主表拓展表为extend_title主键;明细表为extend_group主键
|
||||
Long extendGroupId = jsonObject.getLong("groupId");
|
||||
|
||||
JSONArray records = (JSONArray) jsonObject.get("records");
|
||||
JSONArray records = jsonObject.getJSONArray("records");
|
||||
int updateCount = 0;
|
||||
for (int i = 0; i < records.size(); i++) {
|
||||
// 存在ID则更新 ,不存在ID则增加
|
||||
|
|
@ -130,7 +135,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
|
|||
String data = param.getData();
|
||||
JSONObject jsonObject = JSON.parseObject(data);
|
||||
Set<Long> ids = new HashSet<>();
|
||||
JSONArray records = (JSONArray) jsonObject.get("records");
|
||||
JSONArray records = jsonObject.getJSONArray("records");
|
||||
for (int i = 0; i < records.size(); i++) {
|
||||
ExtendTitlePO extendTitle = new ExtendTitlePO();
|
||||
JSONObject object = (JSONObject) records.get(i);
|
||||
|
|
@ -168,13 +173,13 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
|
|||
Map<String, Object> datas = new HashMap<>();
|
||||
|
||||
List<ExtendTitlePO> titlesByGroupID = getExtendTitleMapper().getTitlesByGroupID(param.getGroupType());
|
||||
ExtendTitlePO extendTitlePO = titlesByGroupID.stream().max(Comparator.comparing(ExtendTitlePO::getShowOrder)).get();
|
||||
ExtendTitlePO extendTitlePO = titlesByGroupID.stream().max(Comparator.comparing(ExtendTitlePO::getShowOrder)).orElse(ExtendTitlePO.builder().showOrder(1).build());
|
||||
Set<Long> ids = titlesByGroupID.stream().map(ExtendTitlePO::getId).collect(Collectors.toSet());
|
||||
ExtendTitlePO extendTitle = new ExtendTitlePO();
|
||||
extendTitle.setGroupId(param.getGroupType());
|
||||
extendTitle.setIsShow(param.getIsShow());
|
||||
extendTitle.setTitle(param.getGroupName());
|
||||
extendTitle.setShowOrder(null == extendTitlePO ? 0 : extendTitlePO.getShowOrder() + 1);
|
||||
extendTitle.setShowOrder(extendTitlePO.getShowOrder() + 1);
|
||||
extendTitle.setCreator((long) user.getUID());
|
||||
extendTitle.setCreateTime(new Date());
|
||||
extendTitle.setDeleteType(0);
|
||||
|
|
@ -206,8 +211,208 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getFieldDefinedInfo(ExtendTitleSaveParam param) {
|
||||
return null;
|
||||
public Map<String, Object> getFieldDefinedInfo(ExtendFieldSearchParam param) {
|
||||
Map<String, Object> returnMap = new HashMap<>();
|
||||
List<Map<String, Object>> lsFieldInfo = new ArrayList<>();
|
||||
Map<String, Object> fieldInfo;
|
||||
Map<String, Object> recordInfo;
|
||||
Map<String, Object> propsInfo;
|
||||
Map<String, Object> comInfo;
|
||||
List<Object> fieldTypeInfo;
|
||||
List<Object> lsComDetialInfo;
|
||||
Map<String, Object> comDetialInfo;
|
||||
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields("", param.getGroupId(), "", "");
|
||||
for (ExtendInfoPO extendInfoPO : infoPOList) {
|
||||
Long fieldId = extendInfoPO.getId();
|
||||
String fieldName = extendInfoPO.getFieldName();
|
||||
String fieldLabel = extendInfoPO.getFieldNameDesc();
|
||||
String fieldHtmlType = extendInfoPO.getControlType().toString();
|
||||
String fieldtype = extendInfoPO.getBrowserType();
|
||||
String customValue = extendInfoPO.getCustomValue();
|
||||
String fielddmlurl = "";
|
||||
String fieldstrlength = SelectOptionParam.getTextLength(customValue);
|
||||
//自定义字段排序 标识rowKey
|
||||
String fieldidrowKey;
|
||||
int dsporder = extendInfoPO.getShowOrder();
|
||||
boolean isUsed = false;
|
||||
// 系统字段id<0
|
||||
boolean isSysField = extendInfoPO.getId() < 0;
|
||||
if (isSysField) {
|
||||
fieldidrowKey = fieldId + "_hrm";
|
||||
} else {
|
||||
fieldidrowKey = fieldId + "_cus";
|
||||
}
|
||||
// TODO 字段是否已使用
|
||||
// if (!isSysField) isUsed = hfm.fieldIsUsed("field" + hfm.getFieldid());
|
||||
boolean allowhide = extendInfoPO.getId() < 0;
|
||||
boolean allowModify = extendInfoPO.getId() < 0;
|
||||
|
||||
|
||||
BrowserComInfo BrowserComInfo = new BrowserComInfo();
|
||||
List<Object> fieldTypeObj = new ArrayList<>();
|
||||
String fieldType = "";
|
||||
switch (fieldHtmlType) {
|
||||
case "1":
|
||||
fieldTypeObj.add("input");
|
||||
fieldType = SystemEnv.getHtmlLabelName(688, user.getLanguage());
|
||||
|
||||
if (fieldtype.equals("1")) {
|
||||
fieldTypeObj.add("text");
|
||||
fieldType += " " + SystemEnv.getHtmlLabelName(608, user.getLanguage());
|
||||
fieldType += " " + SystemEnv.getHtmlLabelName(608, user.getLanguage()) + ":" + fieldstrlength;
|
||||
fieldTypeObj.add(fieldstrlength);
|
||||
} else if (fieldtype.equals("2")) {
|
||||
fieldTypeObj.add("int");
|
||||
fieldType += " " + SystemEnv.getHtmlLabelName(696, user.getLanguage());
|
||||
} else if (fieldtype.equals("3")) {
|
||||
fieldTypeObj.add("float");
|
||||
fieldType += " " + SystemEnv.getHtmlLabelName(697, user.getLanguage());
|
||||
}
|
||||
break;
|
||||
case "2":
|
||||
fieldTypeObj.add("textarea");
|
||||
fieldType = SystemEnv.getHtmlLabelName(689, user.getLanguage());
|
||||
break;
|
||||
case "3": {
|
||||
fieldTypeObj.add("browser");
|
||||
List<Object> replaceDatas = new ArrayList<>();
|
||||
Map<String, Object> tmp = new HashMap<>();
|
||||
tmp.put("value", fieldtype);
|
||||
tmp.put("valueSpan", SystemEnv.getHtmlLabelName(Util.getIntValue(BrowserComInfo.getBrowserlabelid(fieldtype), 0), user.getLanguage()));
|
||||
Map<String, Object> tmp1 = new HashMap<>();
|
||||
tmp1.put("id", fieldtype);
|
||||
tmp1.put("name", SystemEnv.getHtmlLabelName(Util.getIntValue(BrowserComInfo.getBrowserlabelid(fieldtype), 0), user.getLanguage()));
|
||||
replaceDatas.add(tmp1);
|
||||
tmp.put("replaceDatas", replaceDatas);
|
||||
fieldTypeObj.add(tmp);
|
||||
if (fieldtype.equals("161") || fieldtype.equals("162") || fieldtype.equals("256") || fieldtype.equals("257")) {
|
||||
tmp = new HashMap<>();
|
||||
tmp.put("value", SelectOptionParam.getCustomBrowserId(customValue));
|
||||
tmp.put("valueSpan", SelectOptionParam.getCustomBrowserValueSpan(customValue));
|
||||
fieldTypeObj.add(tmp);
|
||||
}
|
||||
fieldType = SystemEnv.getHtmlLabelName(695, user.getLanguage());
|
||||
fieldType += " " + SystemEnv.getHtmlLabelName(Util.getIntValue(BrowserComInfo.getBrowserlabelid(fieldtype), 0), user.getLanguage());
|
||||
// TODO
|
||||
if ("emptyVal".equals(fielddmlurl) || "".equals(fielddmlurl)) {
|
||||
} else {
|
||||
fieldType += " " + SelectOptionParam.getCustomBrowserValueSpan(customValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "4":
|
||||
fieldTypeObj.add("check");
|
||||
fieldType = SystemEnv.getHtmlLabelName(691, user.getLanguage());
|
||||
break;
|
||||
case "5": {
|
||||
fieldTypeObj.add("select");
|
||||
fieldTypeObj.add("select");
|
||||
Map<String, Object> tmp = new HashMap<>();
|
||||
tmp.put("datas", SelectOptionParam.convertJsonToListOption(customValue));
|
||||
tmp.put("sort", "horizontal");
|
||||
fieldTypeObj.add(tmp);
|
||||
fieldType = SystemEnv.getHtmlLabelName(690, user.getLanguage());
|
||||
break;
|
||||
}
|
||||
case "6":
|
||||
fieldTypeObj.add("upload");
|
||||
fieldTypeObj.add("file");
|
||||
fieldType = SystemEnv.getHtmlLabelName(17616, user.getLanguage());
|
||||
fieldType += " " + SystemEnv.getHtmlLabelName(20798, user.getLanguage());
|
||||
//fieldType += " " + (fieldtype.equals("1") ? SystemEnv.getHtmlLabelName(20798, user.getLanguage()) : SystemEnv.getHtmlLabelName(20001, user.getLanguage()));
|
||||
break;
|
||||
}
|
||||
|
||||
fieldInfo = new HashMap<>();
|
||||
recordInfo = new HashMap<>();
|
||||
recordInfo.put("id", "" + fieldId);
|
||||
recordInfo.put("fieldlabel", fieldLabel);
|
||||
recordInfo.put("fieldname", fieldName);
|
||||
recordInfo.put("fieldType", fieldType);
|
||||
recordInfo.put("fieldTypeObj", fieldTypeObj);
|
||||
recordInfo.put("enable", extendInfoPO.getIsenable());
|
||||
recordInfo.put("required", extendInfoPO.getIsrequired());
|
||||
recordInfo.put("isModify", extendInfoPO.getEditShow());
|
||||
recordInfo.put("viewAttr", isUsed || isSysField ? 1 : 2);
|
||||
recordInfo.put("key", "" + dsporder);
|
||||
recordInfo.put("fieldidrowKey", fieldidrowKey);
|
||||
|
||||
fieldInfo.put("record", recordInfo);
|
||||
|
||||
propsInfo = new HashMap<>();
|
||||
Map<String, Object> checkPropsInfo = new HashMap<>();
|
||||
Map<String, Object> checkPropsEnableInfo = new HashMap<>();
|
||||
Map<String, Object> checkPropsRequiredInfo = new HashMap<>();
|
||||
//允许个人修改字段check框属性
|
||||
Map<String, Object> checkPropsModifyInfo = new HashMap<>();
|
||||
checkPropsEnableInfo.put("viewAttr", allowhide ? 2 : 1);
|
||||
checkPropsModifyInfo.put("viewAttr", allowModify ? 2 : 1);
|
||||
checkPropsRequiredInfo.put("viewAttr", allowhide ? 2 : 1);
|
||||
|
||||
checkPropsInfo.put("enable", checkPropsEnableInfo);
|
||||
checkPropsInfo.put("required", checkPropsRequiredInfo);
|
||||
checkPropsInfo.put("isModify", checkPropsModifyInfo);
|
||||
propsInfo.put("checkProps", checkPropsInfo);
|
||||
fieldInfo.put("props", propsInfo);
|
||||
|
||||
comInfo = new HashMap<>();
|
||||
|
||||
lsComDetialInfo = new ArrayList<>();
|
||||
comDetialInfo = new HashMap<>();
|
||||
comDetialInfo.put("label", "");
|
||||
if (isSysField) {
|
||||
comDetialInfo.put("type", "TEXT");
|
||||
} else {
|
||||
comDetialInfo.put("type", "INPUT");
|
||||
}
|
||||
comDetialInfo.put("width", "15%");
|
||||
comDetialInfo.put("key", "fieldlabel");
|
||||
comDetialInfo.put("viewAttr", "3");
|
||||
lsComDetialInfo.add(comDetialInfo);
|
||||
comInfo.put("fieldlabel", lsComDetialInfo);
|
||||
|
||||
lsComDetialInfo = new ArrayList<>();
|
||||
comDetialInfo = new HashMap<>();
|
||||
comDetialInfo.put("label", "");
|
||||
comDetialInfo.put("type", "TEXT");
|
||||
comDetialInfo.put("width", "15%");
|
||||
comDetialInfo.put("key", "fieldname");
|
||||
comDetialInfo.put("viewAttr", "3");
|
||||
lsComDetialInfo.add(comDetialInfo);
|
||||
comInfo.put("fieldname", lsComDetialInfo);
|
||||
|
||||
lsComDetialInfo = new ArrayList<>();
|
||||
comDetialInfo = new HashMap<>();
|
||||
comDetialInfo.put("label", "");
|
||||
comDetialInfo.put("type", fieldHtmlType.equals("5") ? "CUSTOMFIELD" : "TEXT");
|
||||
comDetialInfo.put("width", "60%");
|
||||
comDetialInfo.put("key", "fieldType");
|
||||
lsComDetialInfo.add(comDetialInfo);
|
||||
comInfo.put("fieldType", lsComDetialInfo);
|
||||
|
||||
fieldInfo.put("com", comInfo);
|
||||
fieldInfo.put("isSysField", isSysField);
|
||||
|
||||
fieldTypeInfo = new ArrayList<>();
|
||||
fieldTypeInfo.add("select");
|
||||
fieldTypeInfo.add("select");
|
||||
Map<String, Object> fieldTypeParamInfo = new HashMap<>();
|
||||
|
||||
if (fieldHtmlType.equals("5")) {
|
||||
|
||||
fieldTypeParamInfo.put("datas", SelectOptionParam.convertJsonToListOption(customValue));
|
||||
fieldTypeParamInfo.put("sort", "horizontal");
|
||||
fieldTypeInfo.add(fieldTypeParamInfo);
|
||||
fieldInfo.put("fieldType", fieldTypeInfo);
|
||||
}
|
||||
lsFieldInfo.add(fieldInfo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
returnMap.put("data", lsFieldInfo);
|
||||
returnMap.put("encryptEnable", false);
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
private ExtendTitlePO buildExtendTitleType(ExtendGroupPO extendGroupPO) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.engine.organization.web;
|
|||
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.organization.entity.extend.param.ExtendFieldSearchParam;
|
||||
import com.engine.organization.entity.extend.param.ExtendTitleSaveParam;
|
||||
import com.engine.organization.entity.fieldset.param.FieldTypeTreeParam;
|
||||
import com.engine.organization.enums.ModuleTypeEnum;
|
||||
|
|
@ -147,4 +148,19 @@ public class FieldDefinedController {
|
|||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{moduleTypeEnum}/getFieldDefinedInfo")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult getFieldDefinedInfo(@Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
String groupType = (String) map.get("groupType");
|
||||
String groupId = (String) map.get("groupId");
|
||||
return ReturnResult.successed(getFieldDefinedWrapper(user).getFieldDefinedInfo(ExtendFieldSearchParam.builder().groupType(groupType).groupId(groupId).build()));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.extend.param.ExtendFieldSearchParam;
|
||||
import com.engine.organization.entity.extend.param.ExtendTitleSaveParam;
|
||||
import com.engine.organization.entity.fieldset.param.FieldTypeTreeParam;
|
||||
import com.engine.organization.entity.fieldset.vo.TypeTreeVO;
|
||||
|
|
@ -75,4 +76,8 @@ public class FieldDefinedWrapper extends Service {
|
|||
public int saveFields(String data) {
|
||||
return getFieldDefinedService(user).saveFields(data);
|
||||
}
|
||||
|
||||
public Map<String, Object> getFieldDefinedInfo(ExtendFieldSearchParam param) {
|
||||
return getFieldDefinedService(user).getFieldDefinedInfo(param);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue