Merge remote-tracking branch 'origin/dev_2307' into dev_2307

dev
吱屋 1 year ago
commit 8e39eab674
  1. 7
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/controller/FunctionxController.java
  2. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/service/IRulexService.java
  3. 120
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/service/impl/RulexServiceImpl.java

@ -28,6 +28,7 @@ import org.jeecg.modules.demo.requirementfun.entity.RequirementFun;
import org.jeecg.modules.demo.requirementfun.service.IRequirementFunService; import org.jeecg.modules.demo.requirementfun.service.IRequirementFunService;
import org.jeecg.modules.demo.requirementitem.entity.RequirementItem; import org.jeecg.modules.demo.requirementitem.entity.RequirementItem;
import org.jeecg.modules.demo.requirementitem.service.IRequirementItemService; import org.jeecg.modules.demo.requirementitem.service.IRequirementItemService;
import org.jeecg.modules.demo.rulex.service.IRulexService;
import org.jeecg.modules.modulex.entity.Modulex; import org.jeecg.modules.modulex.entity.Modulex;
import org.jeecg.modules.modulex.service.IModulexService; import org.jeecg.modules.modulex.service.IModulexService;
import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.ExcelImportUtil;
@ -66,6 +67,9 @@ public class FunctionxController extends JeecgController<Functionx, IFunctionxSe
@Autowired @Autowired
private IRequirementItemService requirementItemService; private IRequirementItemService requirementItemService;
@Autowired
private IRulexService iRulexService;
/** /**
* 分页列表查询 * 分页列表查询
@ -131,6 +135,9 @@ public class FunctionxController extends JeecgController<Functionx, IFunctionxSe
//感觉不符合逻辑,上级模块如果是已发布,然后新增也是已发布状态,那样发布按钮还有什么用?? //感觉不符合逻辑,上级模块如果是已发布,然后新增也是已发布状态,那样发布按钮还有什么用??
// functionx.setWorkStatus(one.getWorkStatus()); // functionx.setWorkStatus(one.getWorkStatus());
functionxService.save(functionx); functionxService.save(functionx);
//功能管理新增规则操作时,如果功能类型是‘新增’和‘修改’,自动根据实体对应的字段,自动生成若干条记录(根据实体的字段生成多条规则)
iRulexService.saveRulex(functionx);
return Result.OK("添加成功!"); return Result.OK("添加成功!");
} }

@ -18,4 +18,6 @@ public interface IRulexService extends IService<Rulex> {
Result<?> sort(String id); Result<?> sort(String id);
List<Rulex> queryRuleListByFunctionId(Functionx functionx); List<Rulex> queryRuleListByFunctionId(Functionx functionx);
void saveRulex(Functionx functionx);
} }

@ -1,16 +1,23 @@
package org.jeecg.modules.demo.rulex.service.impl; package org.jeecg.modules.demo.rulex.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.functionx.entity.Functionx; import org.jeecg.modules.demo.functionx.entity.Functionx;
import org.jeecg.modules.demo.rulex.entity.Rulex; import org.jeecg.modules.demo.rulex.entity.Rulex;
import org.jeecg.modules.demo.rulex.mapper.RulexMapper; import org.jeecg.modules.demo.rulex.mapper.RulexMapper;
import org.jeecg.modules.demo.rulex.service.IRulexService; import org.jeecg.modules.demo.rulex.service.IRulexService;
import org.jeecg.modules.fieldx.entity.Fieldx;
import org.jeecg.modules.fieldx.service.IFieldxService;
import org.jeecg.modules.tablex.entity.Tablex;
import org.jeecg.modules.tablex.service.ITablexService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -19,39 +26,86 @@ import java.util.List;
* @Date: 2023-04-10 * @Date: 2023-04-10
* @Version: V1.0 * @Version: V1.0
*/ */
@Slf4j
@Service @Service
public class RulexServiceImpl extends ServiceImpl<RulexMapper, Rulex> implements IRulexService { public class RulexServiceImpl extends ServiceImpl<RulexMapper, Rulex> implements IRulexService {
@Autowired @Autowired
RulexMapper rulexMapper; RulexMapper rulexMapper;
@Override @Autowired
public Result<?> sort(String id) { private ITablexService iTablexService;
String sort = rulexMapper.sort(id);
String functioncode = rulexMapper.find(id); @Autowired
if (sort == null) { private IFieldxService iFieldxService;
return Result.OK("001" + functioncode);
} else { @Override
int i = Integer.parseInt(sort); public Result<?> sort(String id) {
i++; String sort = rulexMapper.sort(id);
String s = Integer.toString(i); String functioncode = rulexMapper.find(id);
while (s.length() < 3) { if (sort == null) {
s = "0" + s; return Result.OK("001" + functioncode);
} } else {
return Result.OK(s + functioncode); int i = Integer.parseInt(sort);
i++;
String s = Integer.toString(i);
while (s.length() < 3) {
s = "0" + s;
}
return Result.OK(s + functioncode);
}
}
/**
* 根据功能id查询对应的规则
*
* @param functionx functionx
* @return {@link List}<{@link Rulex}>
*/
@Override
public List<Rulex> queryRuleListByFunctionId(Functionx functionx) {
LambdaQueryWrapper<Rulex> ruleWrapper = new LambdaQueryWrapper<>();
ruleWrapper.eq(Rulex::getFunctionId, functionx.getId());
return this.list(ruleWrapper);
}
/**
* 功能管理新增规则操作时如果功能类型是新增修改自动根据实体对应的字段自动生成若干条记录根据实体的字段生成多条规则
*
* @param functionx
*/
@Override
public void saveRulex(Functionx functionx) {
int functionType = functionx.getFunctionType().intValue();
if (1 == functionType || 3 == functionType) {
String moduleId = functionx.getModuleId();
Tablex tablex = iTablexService.getOne(new LambdaQueryWrapper<Tablex>().eq(Tablex::getModuleId, moduleId));
if (!ObjectUtils.isEmpty(tablex)) {
List<Fieldx> fieldxList = iFieldxService.list(new LambdaQueryWrapper<Fieldx>().eq(Fieldx::getTableId, tablex.getId()));
if (!ObjectUtils.isEmpty(fieldxList)) {
fieldxList.stream().forEach(o -> {
//主键字段不创建规则
if (0 == o.getIsPk()) {
Rulex rulex = new Rulex();
rulex.setModuleId(moduleId);
rulex.setTableId(tablex.getId());
rulex.setFunctionId(functionx.getId());
rulex.setFieldId(o.getId());
rulex.setCreateTime(new Date());
Result<?> result = this.sort(functionx.getId());
String roleCodeStr = result.getResult().toString();
log.info("-----------------the roleCodeStr:{}", roleCodeStr);
String ruleNo = roleCodeStr.substring(0, 3);
String ruleCode = roleCodeStr.substring(3) + ruleNo;
rulex.setRuleNo(ruleNo);
rulex.setRuleCode(ruleCode);
rulex.setPmDescribe(JSON.toJSONString(o));
this.save(rulex);
}
});
}
}
}
} }
}
/**
* 根据功能id查询对应的规则
*
* @param functionx functionx
* @return {@link List}<{@link Rulex}>
*/
@Override
public List<Rulex> queryRuleListByFunctionId(Functionx functionx) {
LambdaQueryWrapper<Rulex> ruleWrapper = new LambdaQueryWrapper<>();
ruleWrapper.eq(Rulex::getFunctionId, functionx.getId());
return this.list(ruleWrapper);
}
} }

Loading…
Cancel
Save