模块管理-复制规则 7.10

dev
zhc077 1 year ago
parent ed6b4d3abf
commit 26b60a2682
  1. 6
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 2
      ant-design-vue-jeecg/src/views/modulex/modules/ModulexForm.vue
  3. 2
      ant-design-vue-jeecg/src/views/rulex/modules/RulexForm.vue
  4. 38
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java

@ -71,6 +71,12 @@
<div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<a-button @click="fanhui" type="primary" icon="rollback">返回</a-button>
<a-button type="primary" icon="import">导入模块</a-button>
<a-button type="primary" icon="import">导入功能</a-button>
<a-button type="primary" icon="import">导入规则</a-button>
<a-button type="primary" icon="import">导入实体</a-button>
<a-button type="primary" icon="import">导入字段</a-button>
</div>
<!-- table区域-begin -->

@ -397,6 +397,8 @@ export default {
this.model.moduleEnName = this.model.moduleEnName + '+1'
this.model.moduleCode = this.model.moduleCode + '+1'
this.model.createTime = null
//id
this.model.copyId = record.id;
}
this.visible = true
},

@ -197,7 +197,7 @@ export default {
methods: {
sort() {
getAction(this.url.sort, { id: this.model.functionId }).then((res) => {
console.log(res)
console.log("the res:",JSON.stringify(res));
this.model.ruleNo = res.result.substring(0, 3);
this.model.ruleCode = res.result.substring(3) + this.model.ruleNo;
console.log(this.model.ruleNo)

@ -22,9 +22,9 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @Description: 模块管理
@ -186,6 +186,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
@Transactional(readOnly = false, rollbackFor = Exception.class)
@Override
public void copy(Modulex modulex) {
final String copyId = modulex.getCopyId();
Integer newVersion = this.getMaxVersion(modulex.getVerison());
modulex.setVerison(newVersion + 1);
modulex.setRelatedBean(null);
@ -195,6 +196,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String id = modulex.getId();
//复制实体&字段
Tablex tablex = iTablexService.getOne(new LambdaQueryWrapper<Tablex>().eq(Tablex::getModuleId, modulex.getCopyId()));
String tableId = null;
if (!ObjectUtils.isEmpty(tablex)) {
Tablex tablex1 = new Tablex();
BeanUtils.copyProperties(tablex, tablex1);
@ -204,6 +206,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
tablex1.setTableEnName(modulex.getModuleEnName());
tablex1.setCreateTime(new Date());
iTablexService.save(tablex1);
tableId = tablex1.getId();
List<Fieldx> fieldxList = iFieldxService.list(new LambdaQueryWrapper<Fieldx>().eq(Fieldx::getTableId, tablex.getId()));
if (!ObjectUtils.isEmpty(fieldxList)) {
List<Fieldx> addList = new LinkedList<>();
@ -234,8 +237,35 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
addList.add(functionx);
});
iFunctionxService.saveBatch(addList);
}
//复制每个功能的规则
List<Rulex> rulexList = iRulexService.list(new LambdaQueryWrapper<Rulex>().eq(Rulex::getModuleId, copyId));
List<Rulex> ruleAddList = new LinkedList<>();
if (!ObjectUtils.isEmpty(rulexList)) {
String finalTableId1 = tableId;
rulexList.stream().forEach(e -> {
//根据原已有规则funtion_id,查找该规则所属功能
Functionx functionx = iFunctionxService.getById(e.getFunctionId());
//根据原功能名称查询,已复制对象的功能
Functionx functionx1 = iFunctionxService.getOne(new LambdaQueryWrapper<Functionx>().eq(Functionx::getModuleId, id).eq(Functionx::getFunctionName, functionx.getFunctionName()));
Rulex rulex = new Rulex();
BeanUtils.copyProperties(e, rulex);
rulex.setId(null);
rulex.setModuleId(id);
rulex.setTableId(finalTableId1);
rulex.setFunctionId(functionx1.getId());
//根据原已有规则的field_id,查找该规则字段
Fieldx fieldx = iFieldxService.getById(e.getFieldId());
//根据源字段名称,查询对应字段id
Fieldx fieldx1 = iFieldxService.getOne(new LambdaQueryWrapper<Fieldx>().eq(Fieldx::getTableId, finalTableId1).eq(Fieldx::getFieldEnName, fieldx.getFieldEnName()));
rulex.setFieldId(fieldx1.getId());
rulex.setCreateTime(new Date());
ruleAddList.add(rulex);
});
iRulexService.saveBatch(ruleAddList);
}
}
}

Loading…
Cancel
Save