Commit 010a095f authored by fangxinjiang's avatar fangxinjiang

项目规则配置-fxj

parent 227d40fc
......@@ -247,6 +247,11 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
|| Common.isEmpty(autoMainRel.getDeptNo())){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
TAutoMainRel existRel = baseMapper.selectOne(Wrappers.<TAutoMainRel>query().lambda()
.eq(TAutoMainRel::getDeptNo,autoMainRel.getDeptNo()).last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(existRel)){
return R.failed("已存在对应项目规则配置!");
}
SysAutoDict autoDict = autoDictMapper.selectOne(Wrappers.<SysAutoDict>query().lambda()
.eq(SysAutoDict::getType,CommonConstants.POST_TYPE).last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(autoDict)){
......@@ -260,6 +265,14 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
return R.failed(errorMessage.getMessage());
}
}
//新增岗位字典
List<SysAutoDictItem> autoDictItems = entity.getAutoDictItems();
Set<String> repeatItems = new HashSet<>();
for (SysAutoDictItem item:autoDictItems) {
if (Common.isNotNull(repeatItems.contains(item.getLabel()))) {
return R.failed("同一项目岗位名称不可重复");
}
}
//新增主表
autoMainRel.setRuleUpdatePerson(user.getNickname());
autoMainRel.setRuleUpdateTime(DateUtil.getCurrentDateTime());
......@@ -267,17 +280,16 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
if (res <= CommonConstants.ZERO_INT){
return R.failed(CommonConstants.SAVE_FAILED);
}
//新增岗位字典
List<SysAutoDictItem> autoDictItems = entity.getAutoDictItems();
if (Common.isNotNull(autoDictItems)) {
autoDictItems.forEach(sysAutoDictItem -> {
for (SysAutoDictItem sysAutoDictItem:autoDictItems){
//初始化字典信息
initDictItem(sysAutoDictItem, user, autoDict, autoMainRel);
sysAutoDictItem.setCreateTime(LocalDateTime.now());
sysAutoDictItem.setCreateBy(user.getId());
sysAutoDictItem.setCreateName(user.getNickname());
autoDictItemMapper.insert(sysAutoDictItem);
});
}
}
//新增档案规则
if (Common.isNotNull(autoEmpRuleInfo)){
......@@ -324,6 +336,21 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
return R.failed(errorMessage.getMessage());
}
}
//更新岗位字典
List<SysAutoDictItem> autoDictItems = entity.getAutoDictItems();
Map<String,SysAutoDictItem> repeatItems = new HashMap<>();
//更新岗位字典
List<SysAutoDictItem> oldAutoDictItems = autoDictItemMapper.selectList(Wrappers.<SysAutoDictItem>query()
.lambda().eq(SysAutoDictItem::getDeptNo,autoMainRel.getDeptNo())
.eq(SysAutoDictItem::getDisable,CommonConstants.ZERO_STRING));
if (Common.isNotNull(oldAutoDictItems)){
repeatItems = oldAutoDictItems.stream().collect(Collectors.toMap(SysAutoDictItem::getLabel,v->v));
}
//检验岗位字典是否重复
R<Boolean> checkRes = checkItemRepeat(autoDictItems, repeatItems);
if (checkRes != null){
return checkRes;
}
//更新主表
autoMainRel.setRuleUpdatePerson(user.getNickname());
autoMainRel.setRuleUpdateTime(DateUtil.getCurrentDateTime());
......@@ -331,10 +358,9 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
Map<String,String> diffKeyMap = new HashMap<>();
Map<String,Object> oldMap = new HashMap<>();
Map<String,Object> newMap = new HashMap<>();
//更新岗位字典
List<SysAutoDictItem> autoDictItems = entity.getAutoDictItems();
//处理岗位字典数据
dictItemHandle(user, autoMainRel, autoDict, diffKeyMap, autoDictItems);
dictItemHandle(user, autoMainRel, autoDict, diffKeyMap, autoDictItems,oldAutoDictItems);
//更新档案管理规则
if (Common.isNotNull(autoEmpRuleNew)){
oldMap.put("oldEmpRule",autoEmpRuleOld);
......@@ -353,11 +379,27 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
return R.ok(true,CommonConstants.UPDATE_SUCCESS);
}
private void dictItemHandle(YifuUser user, TAutoMainRel autoMainRel, SysAutoDict autoDict, Map<String, String> diffKeyMap, List<SysAutoDictItem> autoDictItems) {
//更新岗位字典
List<SysAutoDictItem> oldAutoDictItems = autoDictItemMapper.selectList(Wrappers.<SysAutoDictItem>query()
.lambda().eq(SysAutoDictItem::getDeptNo,autoMainRel.getDeptNo())
.eq(SysAutoDictItem::getDisable,CommonConstants.ZERO_STRING));
private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<String, SysAutoDictItem> repeatItems) {
SysAutoDictItem checkItem;
for (SysAutoDictItem item: autoDictItems) {
if (Common.isNotNull(repeatItems)) {
checkItem = repeatItems.get(item.getLabel());
if (null != checkItem && item.getLabel().equals(checkItem.getLabel())){
return R.failed("同一项目岗位名称不可重复");
}
repeatItems.put(item.getLabel(),item);
}
}
return null;
}
private void dictItemHandle(YifuUser user,
TAutoMainRel autoMainRel,
SysAutoDict autoDict,
Map<String, String> diffKeyMap,
List<SysAutoDictItem> autoDictItems,
List<SysAutoDictItem> oldAutoDictItems) {
if (Common.isNotNull(autoDictItems)){
Map<Long, SysAutoDictItem> oldItemMap = null;
if (Common.isNotNull(oldAutoDictItems)){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment