diff --git a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java index 71166d97..c033a73a 100644 --- a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java +++ b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java @@ -81,6 +81,36 @@ public class ExtendInfoBO { } + /** + * 渲染列表时,根据每一列的viewAttr渲染 + * @param user + * @param infoPOList + * @param showLabel + * @param checkBox + * @return + */ + public static List> convertInfoListToTable(User user, List infoPOList, boolean showLabel, boolean checkBox) { + List> lsCol = new ArrayList<>(); + Map col; + + int width = 100 / infoPOList.size(); + for (ExtendInfoPO extendInfoPO : infoPOList) { + String tmpkey = extendInfoPO.getFieldName(); + col = new HashMap<>(); + col.put("title", extendInfoPO.getFieldNameDesc()); + col.put("key", tmpkey); + col.put("dataIndex", tmpkey); + col.put("com", getFieldDetailInfo(user, extendInfoPO, extendInfoPO.getViewAttr(), showLabel, width)); + col.put("width", width + "%"); + if (checkBox && Integer.valueOf(7).equals(extendInfoPO.getControlType())) { + col.put("checkType", "checkbox"); + } + lsCol.add(col); + } + return lsCol; + + } + public static List> convertInfoListToTable(User user, List infoPOList, int viewAttr, boolean showLabel) { return convertInfoListToTable(user, infoPOList, viewAttr, showLabel, false); } diff --git a/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java b/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java index da0033b1..57f48249 100644 --- a/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java +++ b/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java @@ -131,4 +131,6 @@ public class ExtendInfoPO { private int deleteType; private Date createTime; private Date updateTime; + + private Integer viewAttr; } diff --git a/src/com/engine/organization/entity/hrmresource/param/SearchTemplateParam.java b/src/com/engine/organization/entity/hrmresource/param/SearchTemplateParam.java index 90434e99..cd05eeff 100644 --- a/src/com/engine/organization/entity/hrmresource/param/SearchTemplateParam.java +++ b/src/com/engine/organization/entity/hrmresource/param/SearchTemplateParam.java @@ -16,7 +16,7 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class SearchTemplateParam { private String key; - private boolean selected; + //private boolean selected; private String showname; private String fields; } diff --git a/src/com/engine/organization/mapper/resource/HrmResourceMapper.java b/src/com/engine/organization/mapper/resource/HrmResourceMapper.java index d30faa75..e95578cd 100644 --- a/src/com/engine/organization/mapper/resource/HrmResourceMapper.java +++ b/src/com/engine/organization/mapper/resource/HrmResourceMapper.java @@ -57,8 +57,12 @@ public interface HrmResourceMapper { SearchTemplatePO getSearchTemplateById(@Param("id") String id); + SearchTemplatePO getSearchTemplateByName(@Param("userId") Integer userId, @Param("name") String name); + SearchTemplatePO getCustomTemplateById(@Param("id") String id); + SearchTemplatePO getCustomTemplateByName(@Param("userId") Integer userId, @Param("name") String name); + Integer insertSearchTemplate(SearchTemplatePO templatePO); Integer deleteSearchTemplate(@Param("id") Integer Id, @Param("userId") Integer userId); diff --git a/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml b/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml index 16a6fea4..161af435 100644 --- a/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml +++ b/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml @@ -12,7 +12,7 @@ - + @@ -117,8 +117,7 @@ @@ -138,8 +137,7 @@ @@ -390,5 +388,19 @@ from hrm_formfield a inner join htmllabelinfo b on a.fieldlabel = b.indexid and b.languageid = 7 + + \ No newline at end of file diff --git a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java index 341692c8..71e7fa87 100644 --- a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java +++ b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java @@ -18,7 +18,6 @@ import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.department.bo.DepartmentBO; import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.extend.bo.ExtendInfoBO; -import com.engine.organization.entity.extend.param.ExtendInfoParams; import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.entity.hrmresource.bo.HrmRelationBO; import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam; @@ -36,7 +35,6 @@ import com.engine.organization.entity.searchtree.SearchTreeParams; import com.engine.organization.enums.HrmGroupEnum; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.department.DepartmentMapper; -import com.engine.organization.mapper.extend.ExtMapper; import com.engine.organization.mapper.hrmresource.HrmRelationMapper; import com.engine.organization.mapper.hrmresource.SystemDataMapper; import com.engine.organization.mapper.job.JobMapper; @@ -56,12 +54,12 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.json.JSONException; import org.json.JSONObject; +import weaver.common.DateUtil; import weaver.conn.RecordSet; import weaver.general.StringUtil; import weaver.general.Util; import weaver.hrm.definedfield.HrmFieldManager; -import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -205,6 +203,9 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic @Override public Integer saveSearchTemplate(SearchTemplateParam params) { + // 重复名称校验 + SearchTemplatePO searchTemplateByName = getHrmResourceMapper().getSearchTemplateByName(user.getUID(), params.getShowname()); + OrganizationAssert.isNull(searchTemplateByName, "改模板名称已存在"); SearchTemplatePO templatePO = buildSearchTemplateByFields(params.getFields()); if (null == templatePO) { return -1; @@ -261,12 +262,15 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic } else { templates = getHrmResourceMapper().getSearchTemplatesByUser(userUID); } - templates.add(0, SearchTemplateParam.builder().key("-1").selected(false).showname("默认模板").build()); + templates.add(0, SearchTemplateParam.builder().key("-1").showname("默认模板").build()); return templates; } @Override public Integer saveCustomTemplate(SearchTemplateParam params) { + // 重复名称校验 + SearchTemplatePO searchTemplateByName = getHrmResourceMapper().getCustomTemplateByName(user.getUID(), params.getShowname()); + OrganizationAssert.isNull(searchTemplateByName, "改模板名称已存在"); SearchTemplatePO templatePO = buildSearchTemplateByFields(params.getFields()); if (null == templatePO) { return -1; @@ -502,10 +506,10 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic @Override public Map getCustomTemplate(Map params) { List infoPOList = new ArrayList<>(); - infoPOList.add(ExtendInfoPO.builder().id(null).fieldName("name").fieldNameDesc("模板名称").fieldType("varchar(255)").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"50\"]").showOrder(1).isrequired(0).isSystemDefault(0).build()); - infoPOList.add(ExtendInfoPO.builder().id(null).fieldName("createTime").fieldNameDesc("创建时间").fieldType("date").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"50\"]").showOrder(2).isrequired(0).isSystemDefault(0).build()); + infoPOList.add(ExtendInfoPO.builder().viewAttr(2).id(null).fieldName("name").fieldNameDesc("模板名称").fieldType("varchar(255)").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"50\"]").showOrder(1).isrequired(0).isSystemDefault(0).build()); + infoPOList.add(ExtendInfoPO.builder().viewAttr(1).id(null).fieldName("createTime").fieldNameDesc("创建时间").fieldType("date").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"50\"]").showOrder(2).isrequired(0).isSystemDefault(0).build()); Map tabInfoMap = new HashMap<>(); - tabInfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, infoPOList, 2, false, true)); + tabInfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, infoPOList, false, true)); List jclOrgCustomTemplatePOS = MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).listAll(); List isUsed = new ArrayList<>(); AtomicInteger index = new AtomicInteger(0); @@ -513,9 +517,9 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic Map resultMap = new HashMap<>(); resultMap.put("id", item.getId()); resultMap.put("name", item.getName()); - resultMap.put("createTime", item.getCreateTime()); + resultMap.put("createTime", DateUtil.getDate(item.getCreateTime(), DateUtil.FORMAT_FULL)); - if(item.getIsused()!=null){ + if (item.getIsused() != null) { if (1 == item.getIsused()) { isUsed.add(index.get()); @@ -571,6 +575,9 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic continue; } String key = entry.getKey(); + if ("lastName".equals(key)) { + sb.append(" and t.lastname ").append(dbType.like(value)); + } SearchConditionItem searchConditionItem = allFieldsMap.get(key); buildDynamicSql(searchConditionItem, key, value, sb, dbType); // 根据不同的类型,不同的查询方式 @@ -1093,7 +1100,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic private static String getFieldName(String fieldabel) { RecordSet recordSet = new RecordSet(); String fieldname = null; - recordSet.executeQuery("select fieldname from jcl_org_field where fieldlabel='" + fieldabel+"'"); + recordSet.executeQuery("select fieldname from jcl_org_field where fieldlabel='" + fieldabel + "'"); if (recordSet.next()) { fieldname = recordSet.getString("fieldname"); } diff --git a/src/com/engine/organization/web/HrmResourceController.java b/src/com/engine/organization/web/HrmResourceController.java index e8ea8c7e..dee144f0 100644 --- a/src/com/engine/organization/web/HrmResourceController.java +++ b/src/com/engine/organization/web/HrmResourceController.java @@ -332,6 +332,7 @@ public class HrmResourceController { } } + @POST @Path("/updateCustomTemplate") @Produces(MediaType.APPLICATION_JSON) public ReturnResult updateCustomTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) {