commit
e2b7ca0072
|
|
@ -20,4 +20,29 @@ public interface CompExtMapper {
|
|||
* @return
|
||||
*/
|
||||
Map<String, Object> listCompExt(@Param("tableName") String tableName, @Param("fields") String fields, @Param("id") long id);
|
||||
|
||||
/**
|
||||
* 判断当前数据是否存在
|
||||
*
|
||||
* @param tableName
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int countCompExtById(@Param("tableName") String tableName, @Param("id") long id);
|
||||
|
||||
/**
|
||||
* 插入主表拓展表
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
int insertCompExt(@Param("tableName") String tableName, @Param("map") Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 更新主表拓展表
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
int updateCompExt(@Param("tableName") String tableName, @Param("id") long id, @Param("map") Map<String, Object> map);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,38 @@
|
|||
<mapper namespace="com.engine.organization.mapper.comp.CompExtMapper">
|
||||
|
||||
|
||||
<insert id="insertCompExt" parameterType="java.util.Map">
|
||||
insert into ${tableName} (
|
||||
<foreach collection="map" item="value" index="key" separator=",">
|
||||
${key}
|
||||
</foreach>
|
||||
)
|
||||
values (
|
||||
<foreach collection="map" item="value" index="key" separator=",">
|
||||
#{value}
|
||||
</foreach>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateCompExt" parameterType="java.util.Map">
|
||||
update ${tableName} set
|
||||
<foreach collection="map" item="value" index="key" separator=",">
|
||||
${key} = #{value}
|
||||
</foreach>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="listCompExt" resultType="map">
|
||||
select ${fields}
|
||||
from ${tableName}
|
||||
where delete_type = 0
|
||||
and id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="countCompExtById" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from ${tableName}
|
||||
where delete_type = 0
|
||||
and id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -46,6 +46,22 @@ import java.util.stream.Collectors;
|
|||
* @version: 1.0
|
||||
*/
|
||||
public class CompServiceImpl extends Service implements CompService {
|
||||
/**
|
||||
* 分组类型
|
||||
* 1:分部
|
||||
* 2:部门
|
||||
* 3:岗位
|
||||
*/
|
||||
private static final String EXTEND_TYPE = "1";
|
||||
/**
|
||||
* 主表拓展表
|
||||
*/
|
||||
private static final String JCL_ORG_COMPEXT = "JCL_ORG_COMPEXT";
|
||||
/**
|
||||
* 明细表拓展表
|
||||
*/
|
||||
private static final String JCL_ORG_COMPEXT_DT1 = "JCL_ORG_COMPEXT_DT1";
|
||||
|
||||
private CompMapper getCompMapper() {
|
||||
return MapperProxyFactory.getProxy(CompMapper.class);
|
||||
}
|
||||
|
|
@ -122,18 +138,41 @@ public class CompServiceImpl extends Service implements CompService {
|
|||
@Override
|
||||
public int updateComp(Map<String, Object> params) {
|
||||
CompSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), CompSearchParam.class);
|
||||
// 更新主表数据
|
||||
String groupId = (String) params.get("viewCondition");
|
||||
int updateBaseComp = 0;
|
||||
CompPO compPO = CompBO.convertParamToPO(searchParam, (long) user.getUID());
|
||||
int updateBaseComp = getCompMapper().updateBaseComp(compPO);
|
||||
if (StringUtil.isEmpty(groupId) || "0".equals(groupId)) {
|
||||
// 更新主表数据
|
||||
updateBaseComp = getCompMapper().updateBaseComp(compPO);
|
||||
} else {
|
||||
List<ExtendInfoPO> extInfoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, groupId, JCL_ORG_COMPEXT);
|
||||
List<String> extFields = extInfoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (String dtField : extFields) {
|
||||
map.put(dtField, params.get(dtField));
|
||||
}
|
||||
// 判断更新还是插入
|
||||
int count = getCompExtMapper().countCompExtById(JCL_ORG_COMPEXT, searchParam.getId());
|
||||
if (count > 0) {
|
||||
map.put("update_time", compPO.getUpdateTime());
|
||||
updateBaseComp = getCompExtMapper().updateCompExt(JCL_ORG_COMPEXT, compPO.getId(), map);
|
||||
} else {
|
||||
map.put("creator", compPO.getCreator());
|
||||
map.put("delete_type", compPO.getDeleteType());
|
||||
map.put("create_time", compPO.getCreateTime());
|
||||
map.put("update_time", compPO.getUpdateTime());
|
||||
map.put("id", compPO.getId());
|
||||
updateBaseComp = getCompExtMapper().insertCompExt(JCL_ORG_COMPEXT, map);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取分部明细表的所有拓展列
|
||||
String tableName = "JCL_ORG_COMPEXT_DT1";
|
||||
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields("1", "", tableName);
|
||||
List<String> dtFields = infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList());
|
||||
List<ExtendInfoPO> dtInfoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, "", JCL_ORG_COMPEXT_DT1);
|
||||
List<String> dtFields = dtInfoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList());
|
||||
|
||||
List<Map<String, Object>> insertList = new ArrayList<>();
|
||||
// 删除明细表数据
|
||||
getCompExtDTMapper().deleteByMainID(tableName, compPO.getId());
|
||||
getCompExtDTMapper().deleteByMainID(JCL_ORG_COMPEXT_DT1, compPO.getId());
|
||||
// 处理明细表数据
|
||||
int rowNum = Util.getIntValue((String) params.get("rownum"));
|
||||
for (int i = 0; i < rowNum; i++) {
|
||||
|
|
@ -150,7 +189,7 @@ public class CompServiceImpl extends Service implements CompService {
|
|||
}
|
||||
// 更新拓展表数据
|
||||
for (Map<String, Object> map : insertList) {
|
||||
getCompExtDTMapper().insertCompExtDT(tableName, map);
|
||||
getCompExtDTMapper().insertCompExtDT(JCL_ORG_COMPEXT_DT1, map);
|
||||
}
|
||||
|
||||
return updateBaseComp;
|
||||
|
|
@ -235,21 +274,17 @@ public class CompServiceImpl extends Service implements CompService {
|
|||
buttonsMap.put("hasEdit", true);
|
||||
buttonsMap.put("hasSave", true);
|
||||
|
||||
HashMap<String, Object> conditionsMap = new HashMap<>();
|
||||
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
||||
if (StringUtil.isEmpty(groupId) || "0".equals(groupId)) {
|
||||
conditionsMap.put("items", getBaseForm(viewAttr, id));
|
||||
conditionsMap.put("title", "基本信息");
|
||||
addGroups.add(new SearchConditionGroup("基本信息", true, getBaseForm(viewAttr, id)));
|
||||
} else {
|
||||
conditionsMap.put("items", getExtForm(viewAttr, id, groupId));
|
||||
conditionsMap.put("title", getExtendGroupMapper().getGroupNameById(groupId));
|
||||
addGroups.add(new SearchConditionGroup(getExtendGroupMapper().getGroupNameById(groupId), true, getExtForm(viewAttr, id, groupId)));
|
||||
}
|
||||
conditionsMap.put("hide", false);
|
||||
conditionsMap.put("defaultshow", true);
|
||||
|
||||
|
||||
HashMap<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("buttons", buttonsMap);
|
||||
resultMap.put("conditions", conditionsMap);
|
||||
resultMap.put("conditions", addGroups);
|
||||
resultMap.put("id", id);
|
||||
resultMap.put("tabInfo", getTabInfo());
|
||||
resultMap.put("tables", getExtendTables(id, viewAttr, false));
|
||||
|
|
@ -357,9 +392,8 @@ public class CompServiceImpl extends Service implements CompService {
|
|||
*/
|
||||
private List<Map<String, Object>> getExtendTables(long id, int viewAttr, boolean showLabel) {
|
||||
List<Map<String, Object>> tables = new ArrayList<>();
|
||||
String tableName = "JCL_ORG_COMPEXT_DT1";
|
||||
// 查询所有分布模块,拓展明细表信息
|
||||
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields("1", "", tableName);
|
||||
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, "", JCL_ORG_COMPEXT_DT1);
|
||||
Map<Long, List<ExtendInfoPO>> groupMap = infoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId));
|
||||
// 遍历Map,组装数据
|
||||
for (Map.Entry<Long, List<ExtendInfoPO>> entry : groupMap.entrySet()) {
|
||||
|
|
@ -371,7 +405,7 @@ public class CompServiceImpl extends Service implements CompService {
|
|||
tabinfoMap.put("rownum", "rownum");
|
||||
|
||||
String fields = entry.getValue().stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(","));
|
||||
tabinfoMap.put("datas", getCompExtDTMapper().listCompExtDT(tableName, id, fields));
|
||||
tabinfoMap.put("datas", getCompExtDTMapper().listCompExtDT(JCL_ORG_COMPEXT_DT1, id, fields));
|
||||
tableMap.put("tabinfo", tabinfoMap);
|
||||
tables.add(tableMap);
|
||||
}
|
||||
|
|
@ -406,7 +440,7 @@ public class CompServiceImpl extends Service implements CompService {
|
|||
// 基本信息
|
||||
topTabs.add(TopTab.builder().color("#000000").groupId("0").showcount(false).title("基本信息").viewCondition("0").build());
|
||||
|
||||
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields("1", "", "JCL_ORG_COMPEXT");
|
||||
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, "", JCL_ORG_COMPEXT);
|
||||
List<Long> extendGroups = infoPOList.stream().map(ExtendInfoPO::getExtendGroupId).collect(Collectors.toList());
|
||||
// 拓展信息
|
||||
if (CollectionUtils.isNotEmpty(extendGroups)) {
|
||||
|
|
@ -510,10 +544,9 @@ public class CompServiceImpl extends Service implements CompService {
|
|||
|
||||
// 2编辑 1查看
|
||||
OrganizationAssert.notNull(groupId, "请选择对应的拓展页");
|
||||
String tableName = "JCL_ORG_COMPEXT";
|
||||
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields("1", groupId, tableName);
|
||||
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, groupId, JCL_ORG_COMPEXT);
|
||||
String fields = infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(","));
|
||||
Map<String, Object> compExtMap = getCompExtMapper().listCompExt(tableName, fields, id);
|
||||
Map<String, Object> compExtMap = getCompExtMapper().listCompExt(JCL_ORG_COMPEXT, fields, id);
|
||||
|
||||
// 组装拓展页内容
|
||||
for (ExtendInfoPO extendInfoPO : infoPOList) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue