修改导入规则

dev^2
zjh 1 year ago
parent 40fdcab2eb
commit bede9162cc
  1. 62
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 108
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java

@ -98,29 +98,11 @@
:action="functionImportExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入功能</a-button>
</a-upload>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader"
:action="ruleImportExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import" @click="showProcess">导入规则</a-button>
<a-modal
title="正在上传..."
:visible="ModalData.isVisible==='true'"
:confirm-loading="false"
:mask="true"
:maskClosable="false"
:keyboard="false"
:closable="false"
:footer="false"
>
<p>当前状态{{ ModalData.status }}</p>
<p>总记录数{{ ModalData.records }}</p>
<p>已上传{{ ModalData.uploaded }}</p>
<a-progress
:percent="parseInt(String(ModalData.uploaded/ModalData.records*100))"
title="上传进度:"
status="active" :steps="ModalData.records"/>
</a-modal>
</a-upload>
<a-button type="primary" icon="import" @click="showProcess( ruleData)">导入规则</a-button>
<a-button type="primary" icon="import"
@click="showProcess( tablexData)">导入实体
@ -466,6 +448,7 @@ export default {
tablexImportExcelUrl: "tablex/tablex/importExcel",
tablexDownExcelUrl: "tablex/tablex/templateExcel",
ruleImportExcelUrl: "rulex/rulex/importExcel",
ruleDownExcelUrl: "rulex/rulex/downExcel",
exportxsxl: "modulex/modulex/exportxsxl"
},
dictOptions: {},
@ -508,6 +491,9 @@ export default {
ruleImportExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.ruleImportExcelUrl}`
},
ruleDownExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.ruleDownExcelUrl}`
},
tablexData: function () {
return {
note: ['对应模块id(必填):填写正确的模块名称',
@ -522,6 +508,33 @@ export default {
uploadUrl: this.tablexImportExcelUrl,
downUrl: this.tablexDownExcelUrl
}
},
ruleData: function () {
return {
note: ['对应模块(必填):填写正确的模块名称',
'对应功能(必填):填写正确的功能名称',
'对应实体(必填):填写正确的实体名称',
'对应字段(必填):填写正确的字段名称',
'顺序号(必填);同功能下不重复',
'规则编码(必填):功能编码+顺序号(格式001)',
'规则描述(非必填)',
'分析图(非必填)',
'责任人(非必填)',
'任务等级(必填):值:1、2、3、4、5个等级',
'任务状态(必填):值:未发布、已发布、开发中、已完成、已撤回、已取消',
'版本状态(必填): 可填入值为[当前、历史]',
'规则状态(必填): 值:正常、停用、废弃',
'开始时间(必填) ',
'任务时长(必填)',
'提交时间(必填)',
'实际时长(必填)',
'规则状态(必填): 值:正常、停用、废弃',
'版本号:请填写小与五位数的正整数'
],
title: '导入规则',
uploadUrl: this.ruleImportExcelUrl,
downUrl: this.ruleDownExcelUrl
}
}
},
methods: {
@ -751,9 +764,10 @@ export default {
this.loadData()
},
},
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';

@ -33,8 +33,12 @@ import org.jeecg.modules.tablex.entity.Tablex;
import org.jeecg.modules.tablex.service.ITablexService;
import org.jeecg.modules.tablex.ws.WebSocketUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.TemplateExcelConstants;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.entity.TemplateExportParams;
import org.jeecgframework.poi.excel.view.JeecgTemplateExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.*;
@ -42,6 +46,8 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -82,6 +88,8 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
@Autowired
private WebSocketUtils webSocketUtils;
@Value("${jeecg.wordPath}")
private String wordPath;
/**
* 分页列表查询
@ -244,8 +252,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
if (StringUtils.isBlank(originalFilename) ||
(!originalFilename.endsWith("xls") &&
!originalFilename.endsWith("xlsx"))) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件格式不正确");
}
//校验时间
@ -263,8 +270,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
webSocketUtils.sendMessage(loginUser.getId(), message);
List<RuleVo> list = ExcelImportUtil.importExcel(file.getInputStream(), RuleVo.class, params);
if (list == null || list.size() <= 0) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败:模板中暂无数据");
}
int num = 0;
@ -294,8 +300,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
}
num++;
if (num == 0) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败:导入模板不匹配");
// } else if (num!=list.size()) {
// return Result.error("文件导入失败:请检查填写文字");
@ -308,12 +313,10 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
log.error(msg, e);
//if(msg!=null && msg.contains("Duplicate entry"))
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败:有重复数据!");
} else {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败:" + e.getMessage());
}
//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
@ -327,8 +330,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
List<RuleVo> ruleVoList = iRuleVoService.list();
if (ruleVoList.size() <= 0 || ruleVoList == null) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败,模板不匹配有空值");
}
// 将总的记录数传递给前端
@ -345,8 +347,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
Fieldx byId = iFieldxService.getOne(rulexLambdaQueryWrapper);
if (byId == null) {
iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("字段输入错误,请核对");
}
rulex.setFieldId(byId.getId());
@ -357,8 +358,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
Functionx byId1 = functionxService.getOne(functionxLambdaQueryWrapper);
if (byId1 == null) {
iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("功能输入错误,请核对");
}
rulex.setFunctionId(byId1.getId());
@ -368,8 +368,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
modulexLambdaQueryWrapper.eq(Modulex::getModuleName, moduleName);
Modulex byId2 = iModulexService.getOne(modulexLambdaQueryWrapper);
if (byId2 == null) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
iRuleVoService.remove(null);
return Result.error("模块输入错误,请核对");
@ -381,8 +380,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId);
Tablex byId3 = iTablexService.getOne(tableLambdaQueryWrapper);
if (byId3 == null) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
iRuleVoService.remove(null);
return Result.error("实体输入错误,请核对");
@ -395,8 +393,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
rulex.setDuration(aDouble);
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("任务时长输入错误,请核对");
}
@ -405,8 +402,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
d = Double.valueOf(ruleVo.getRealDuration());
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("实际时长输入错误,请核对");
}
rulex.setRealDuration(d);
@ -415,8 +411,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
integer = Integer.valueOf(ruleVo.getWorkLevel());
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("任务等级输入错误,请核对");
}
rulex.setWorkLevel(integer);
@ -431,16 +426,15 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
rulex.setWorkStatus(1);
else if (workStatus.equals("开发中"))
rulex.setWorkStatus(2);
else if(workStatus.equals("已完成"))
else if (workStatus.equals("已完成"))
rulex.setWorkStatus(3);
else if(workStatus.equals("已撤回"))
else if (workStatus.equals("已撤回"))
rulex.setWorkStatus(4);
else if(workStatus.equals("DEBUG"))
else if (workStatus.equals("DEBUG"))
rulex.setWorkStatus(9);
else {
iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("任务状态输入错误,请核对");
}
String status = ruleVo.getStatus();
@ -455,8 +449,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
rulex.setStatus(9);
else {
iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("规则状态输入错误,请核对");
}
String verisonStatus = ruleVo.getVerisonStatus();
@ -465,8 +458,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
SysDictItem sysDictItem3 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper3);
if (sysDictItem3 == null) {
iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("版本状态输入错误,请核对");
}
@ -480,8 +472,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
if (startTime != null)
if (!validator.isValid(startTime)) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("开始时间输入错误");
} else {
Date date = simpleDateFormat.parse(startTime);
@ -491,8 +482,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
if (submitTime != null)
if (!validator.isValid(submitTime)) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("提交时间输入错误");
} else {
Date date1 = simpleDateFormat.parse(submitTime);
@ -507,8 +497,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
List<String> list = rulexMapper.checkRuleNo(byId1.getId());
if (list.contains(ruleNo)) {
iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("规则序号已存在");
}
rulex.setRuleNo(ruleNo);
@ -533,8 +522,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
integer1 = Integer.valueOf(ruleVo.getVerison());
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("版本号输入错误,请核对");
}
rulex.setVerison(String.valueOf(integer1));
@ -545,11 +533,12 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
message.put("status", "正在读取数据");
webSocketUtils.sendMessage(loginUser.getId(), message);
//存入真实表
rulexService.saveRule(rulex,loginUser,message,i+1);
rulexService.saveRule(rulex, loginUser, message, i + 1);
message.put("status", "导入成功");
webSocketUtils.sendMessage(loginUser.getId(), message);
iRuleVoService.remove(null);
}
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.ok("文件导入成功!");
}
@ -558,4 +547,31 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
return rulexService.sort(id);
}
//导出实体标准模板
@RequestMapping(value = "/downExcel")
public ModelAndView wbsExcelTemplate(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> map = new HashMap<String, Object>();
//设置导出文件名称
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date(System.currentTimeMillis());
String currTime = formatter.format(date);
String fileName = currTime + "-" + "模板.xlsx";
try {
String url = getClass().getClassLoader().getResource("static").getPath();
// 模板存放地址 这里写的地址根本拿不到 在其他人的电脑上
String templateUrl = wordPath + File.separator + "规则表模板.xls";
TemplateExportParams params = new TemplateExportParams(
templateUrl);
ModelAndView mv = new ModelAndView(new JeecgTemplateExcelView());
mv.addObject(TemplateExcelConstants.FILE_NAME, fileName);
mv.addObject(TemplateExcelConstants.PARAMS, params);
// 添加模板参数
mv.addObject(TemplateExcelConstants.MAP_DATA, map); //data
return mv;
} catch (Exception e) {
log.error("下载模板异常--》{}", e);
}
return null;
}
}

Loading…
Cancel
Save