|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
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.extend.bo.ExtendGroupBO;
|
|
|
|
|
import com.engine.organization.entity.extend.param.ExtendTitleSaveParam;
|
|
|
|
|
import com.engine.organization.entity.extend.po.ExtendGroupPO;
|
|
|
|
|
import com.engine.organization.entity.extend.po.ExtendTitlePO;
|
|
|
|
|
import com.engine.organization.entity.fieldset.vo.TypeTreeVO;
|
|
|
|
@ -14,13 +16,12 @@ import com.engine.organization.mapper.extend.ExtendTitleMapper;
|
|
|
|
|
import com.engine.organization.service.FieldDefinedService;
|
|
|
|
|
import com.engine.organization.util.OrganizationAssert;
|
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
|
import com.weaver.general.Util;
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author weaver_cl
|
|
|
|
@ -59,7 +60,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", editTable(extendTitle.getId()));
|
|
|
|
|
tab.put("editable", getExtendInfoMapper().countFieldsByGroupId(extendTitle.getId()) > 0);
|
|
|
|
|
tabs.add(tab);
|
|
|
|
|
}
|
|
|
|
|
datas.put("status", "1");
|
|
|
|
@ -78,13 +79,69 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断该分组下是否有字段
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean editTable(Long id) {
|
|
|
|
|
return getExtendInfoMapper().countFieldsByGroupId(id) > 0;
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> saveGroup(ExtendTitleSaveParam param) {
|
|
|
|
|
Map<String, Object> datas = new HashMap<>();
|
|
|
|
|
Long groupType = param.getGroupType();
|
|
|
|
|
Set<Long> lsDelGroupId = new HashSet<>();
|
|
|
|
|
List<ExtendTitlePO> extendTitleList = getExtendTitleMapper().getTitlesByGroupID(groupType);
|
|
|
|
|
extendTitleList.forEach(item -> lsDelGroupId.add(item.getId()));
|
|
|
|
|
String data = param.getData();
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
|
|
|
|
Set<Long> ids = new HashSet<>();
|
|
|
|
|
JSONArray records = (JSONArray) jsonObject.get("records");
|
|
|
|
|
for (int i = 0; i < records.size(); i++) {
|
|
|
|
|
ExtendTitlePO extendTitle = new ExtendTitlePO();
|
|
|
|
|
JSONObject object = (JSONObject) records.get(i);
|
|
|
|
|
extendTitle.setId(object.getLong("id"));
|
|
|
|
|
extendTitle.setGroupId(groupType);
|
|
|
|
|
extendTitle.setIsShow(object.getString("isShow"));
|
|
|
|
|
extendTitle.setTitle(object.getString("groupName"));
|
|
|
|
|
extendTitle.setShowOrder(i + 1);
|
|
|
|
|
|
|
|
|
|
if (null != extendTitle.getId()) {
|
|
|
|
|
lsDelGroupId.remove(extendTitle.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (null == extendTitle.getId()) {
|
|
|
|
|
extendTitle.setCreator(user.getUID());
|
|
|
|
|
extendTitle.setCreateTime(new Date());
|
|
|
|
|
extendTitle.setDeleteType(0);
|
|
|
|
|
getExtendTitleMapper().insertIgnoreNull(extendTitle);
|
|
|
|
|
} else {
|
|
|
|
|
extendTitle.setUpdateTime(new Date());
|
|
|
|
|
getExtendTitleMapper().updateExtendTitle(extendTitle);
|
|
|
|
|
}
|
|
|
|
|
ids.add(extendTitle.getId());
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtils.isNotEmpty(lsDelGroupId)) {
|
|
|
|
|
getExtendTitleMapper().deleteExtendTitleByIds(lsDelGroupId);
|
|
|
|
|
}
|
|
|
|
|
datas.put("groupid", StringUtils.join(ids, ","));
|
|
|
|
|
datas.put("status", "1");
|
|
|
|
|
return datas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> saveTitle(ExtendTitleSaveParam param) {
|
|
|
|
|
Map<String, Object> datas = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
List<ExtendTitlePO> titlesByGroupID = getExtendTitleMapper().getTitlesByGroupID(param.getGroupType());
|
|
|
|
|
ExtendTitlePO extendTitlePO = titlesByGroupID.stream().max(Comparator.comparing(ExtendTitlePO::getShowOrder)).get();
|
|
|
|
|
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.setCreator(user.getUID());
|
|
|
|
|
extendTitle.setCreateTime(new Date());
|
|
|
|
|
extendTitle.setDeleteType(0);
|
|
|
|
|
getExtendTitleMapper().insertIgnoreNull(extendTitle);
|
|
|
|
|
ids.add(extendTitle.getId());
|
|
|
|
|
|
|
|
|
|
datas.put("groupid", StringUtils.join(ids, ","));
|
|
|
|
|
datas.put("status", "1");
|
|
|
|
|
return datas;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|