功能模块导入代码优化

dev^2
lijinyu 1 year ago
parent dd55a401d1
commit 04107fa659
  1. 7
      jeecg-boot/jeecg-boot-module-system/pom.xml
  2. 5
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/entity/FunctionxTest.java
  3. 29
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/service/impl/FunctionXTestServiceImpl.java
  4. 13
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/entity/ModulexTemplate.java
  5. 1
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/IModulexService.java
  6. 81
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java

@ -110,6 +110,13 @@
<version>3.17</version> <version>3.17</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.belerweb/pinyin4j -->
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.1</version>
</dependency>
<dependency> <dependency>
<groupId>org.jeecgframework.boot</groupId> <groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-module-cms</artifactId> <artifactId>jeecg-boot-module-cms</artifactId>

@ -52,11 +52,6 @@ public class FunctionxTest implements Serializable {
*/ */
private String pmDescribe; private String pmDescribe;
/**
* 分析图
*/
private String diagrams;
/** /**
* 用户角色 * 用户角色
*/ */

@ -101,19 +101,18 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
fun.setFunctionCode(list.get(3)); // 功能编码 fun.setFunctionCode(list.get(3)); // 功能编码
fun.setFunctionType(list.get(4)); // 功能类型 fun.setFunctionType(list.get(4)); // 功能类型
fun.setPmDescribe(list.get(5)); // 功能描述 fun.setPmDescribe(list.get(5)); // 功能描述
fun.setDiagrams(list.get(6)); // 分析图 fun.setUserRole(list.get(6)); // 用户角色
fun.setUserRole(list.get(7)); // 用户角色 fun.setManagerUsers(list.get(7)); // 责任人
fun.setManagerUsers(list.get(8)); // 责任人 fun.setWorkLevel(list.get(8)); // 任务等级
fun.setWorkLevel(list.get(9)); // 任务等级 fun.setWorkStatus(list.get(9)); // 任务状态
fun.setWorkStatus(list.get(10)); // 任务状态 fun.setPublishTime(list.get(10)); // 发布时间
fun.setPublishTime(list.get(11)); // 发布时间 fun.setStartTime(list.get(11)); // 开始时间
fun.setStartTime(list.get(12)); // 开始时间 fun.setDuration(list.get(12)); // 任务时长
fun.setDuration(list.get(13)); // 任务时长 fun.setSubmitTime(list.get(13)); // 提交时间
fun.setSubmitTime(list.get(14)); // 提交时间 fun.setRealDuration(list.get(14)); // 实际时长
fun.setRealDuration(list.get(15)); // 实际时长 fun.setStatus(list.get(15)); // 功能状态
fun.setStatus(list.get(16)); // 功能状态 fun.setVerisonStatus(list.get(16)); // 版本状态
fun.setVerisonStatus(list.get(17)); // 版本状态 fun.setVerison(list.get(17)); // 版本号
fun.setVerison(list.get(18)); // 版本号
fun.setCreatName(username); fun.setCreatName(username);
listVo.add(fun); listVo.add(fun);
@ -150,7 +149,6 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
String functionCode = function.getFunctionCode(); String functionCode = function.getFunctionCode();
String functionType = function.getFunctionType(); String functionType = function.getFunctionType();
String pmDescribe = function.getPmDescribe(); String pmDescribe = function.getPmDescribe();
String diagrams = function.getDiagrams();
String userRole = function.getUserRole(); String userRole = function.getUserRole();
String managerUsers = function.getManagerUsers(); String managerUsers = function.getManagerUsers();
String workLevel = function.getWorkLevel(); String workLevel = function.getWorkLevel();
@ -237,9 +235,6 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
if(StringUtils.isNotBlank(pmDescribe)){ // 功能描述 if(StringUtils.isNotBlank(pmDescribe)){ // 功能描述
functionx.setPmDescribe(pmDescribe); functionx.setPmDescribe(pmDescribe);
} }
if(StringUtils.isNotBlank(diagrams)){ // 分析图
functionx.setDiagrams(diagrams);
}
if(StringUtils.isNotBlank(userRole)){ // 用户角色 if(StringUtils.isNotBlank(userRole)){ // 用户角色
LambdaQueryWrapper<ProjectUserRole> queryWrapperUser = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ProjectUserRole> queryWrapperUser = new LambdaQueryWrapper<>();
queryWrapperUser.eq(ProjectUserRole::getUserRole,userRole); // 是否匹配项目id? queryWrapperUser.eq(ProjectUserRole::getUserRole,userRole); // 是否匹配项目id?

@ -171,18 +171,7 @@ public class ModulexTemplate implements Serializable {
@ApiModelProperty(value = "关联实体") @ApiModelProperty(value = "关联实体")
@Dict(dictTable = "tablex", dicText = "table_name", dicCode = "id") @Dict(dictTable = "tablex", dicText = "table_name", dicCode = "id")
private String relatedBean; private String relatedBean;
/**
* 原型图
*/
@Excel(name = "原型图", width = 15)
@ApiModelProperty(value = "原型图")
private String prototypes;
/**
* 分析图
*/
@Excel(name = "分析图", width = 15)
@ApiModelProperty(value = "分析图")
private String diagrams;
/** /**
* 模块状态 * 模块状态
* 正常1停用0废弃9默认1 * 正常1停用0废弃9默认1

@ -42,4 +42,5 @@ public interface IModulexService extends IService<Modulex> {
List<ModuleFunctionRule> exportXlslist(HttpServletRequest request, String selections,Modulex modulex); List<ModuleFunctionRule> exportXlslist(HttpServletRequest request, String selections,Modulex modulex);
Result<?> importExcel(MultipartFile file) throws Exception; Result<?> importExcel(MultipartFile file) throws Exception;
} }

@ -4,6 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.api.R; import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
@ -479,12 +484,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
modulexVo.setRelatedBean(value); modulexVo.setRelatedBean(value);
break; break;
case 16: case 16:
modulexVo.setPrototypes(value);
break;
case 17:
modulexVo.setDiagrams(value);
break;
case 18:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false"); message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
@ -492,7 +491,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
} }
modulexVo.setStatus(value); modulexVo.setStatus(value);
break; break;
case 19: case 17:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false"); message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
@ -500,7 +499,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
} }
modulexVo.setVerisonStatus(value); modulexVo.setVerisonStatus(value);
break; break;
case 20: case 18:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false"); message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
@ -621,6 +620,23 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块编码不能为空或者模块编码过长"); return Result.error("导入失败,模块编码不能为空或者模块编码过长");
} }
String modulecode = null;
LambdaQueryWrapper<Projectx> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Projectx::getProjectName,projectId);
Projectx projectx = projectxService.getOne(queryWrapper);
String firstChar = this.toFirstChar(moduleName);
String projectCode = projectx.getProjectCode();
if(projectCode==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("项目编码不存在,请重新填写");
}
modulecode = projectCode + firstChar;
if(!modulecode.equals(moduleCode)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("模块编码不规范,导入失败");
}
modulex.setModuleCode(moduleCode); modulex.setModuleCode(moduleCode);
String pmDescribe = modulexTemplate.getPmDescribe(); String pmDescribe = modulexTemplate.getPmDescribe();
if(StringUtils.isBlank(pmDescribe)){ if(StringUtils.isBlank(pmDescribe)){
@ -631,20 +647,23 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
modulex.setManagerUsers(null); modulex.setManagerUsers(null);
}else { }else {
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sysUserLambdaQueryWrapper.eq(SysUser::getUsername,managerUsers); String[] split = managerUsers.split(",");
SysUser iSysUserServiceOne = iSysUserService.getOne(sysUserLambdaQueryWrapper); // sysUserLambdaQueryWrapper.eq(SysUser::getUsername,managerUsers);
sysUserLambdaQueryWrapper.in(SysUser::getUsername,split);
List<SysUser> iSysUserServiceOne = iSysUserService.list(sysUserLambdaQueryWrapper);
if(iSysUserServiceOne==null){ if(iSysUserServiceOne==null){
message.put("isVisible", "false"); message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,责任人信息查询不到"); return Result.error("导入失败,责任人信息查询不到");
}else { }else {
String id = iSysUserServiceOne.getId(); List<String> list = iSysUserServiceOne.stream().map(SysUser::getId).collect(Collectors.toList());
if (id == null) { // String id = iSysUserServiceOne.getId();
if (list == null) {
message.put("isVisible", "false"); message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,责任人信息查询不到"); return Result.error("导入失败,责任人信息查询不到");
} }
modulex.setManagerUsers(id); modulex.setManagerUsers(String.valueOf(list));
} }
} }
String workLevel = modulexTemplate.getWorkLevel(); String workLevel = modulexTemplate.getWorkLevel();
@ -784,14 +803,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
return Result.error("关联实体不存在"); return Result.error("关联实体不存在");
} }
} }
String prototypes = modulexTemplate.getPrototypes();
if(StringUtils.isBlank(prototypes)){
modulex.setPrototypes(null);
}modulex.setPrototypes(prototypes);
String diagrams = modulexTemplate.getDiagrams();
if(StringUtils.isBlank(diagrams)){
modulex.setDiagrams(null);
}modulex.setDiagrams(diagrams);
String status = modulexTemplate.getStatus(); String status = modulexTemplate.getStatus();
if(StringUtils.isBlank(status)){ if(StringUtils.isBlank(status)){
message.put("isVisible", "false"); message.put("isVisible", "false");
@ -1179,4 +1190,32 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
moduleFunctionRule.setVerison(x.getVerison()); moduleFunctionRule.setVerison(x.getVerison());
return moduleFunctionRule; return moduleFunctionRule;
} }
/**
* 获取字符串拼音的第一个字母
* @param chinese
* @return
*/
public static String toFirstChar(String chinese){
String pinyinStr = "";
char[] newChar = chinese.toCharArray(); //转为单个字符
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
for (int i = 0; i < newChar.length; i++) {
if (newChar[i] > 128) {
try {
pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0].charAt(0);
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
}else{
pinyinStr += newChar[i];
}
}
return pinyinStr;
}
} }

Loading…
Cancel
Save