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

# Conflicts:
#	ant-design-vue-jeecg/src/views/modulex/modules/ModulexImport.vue
dev^2
mqh 1 year ago
commit 6c3d0c6836
  1. 179
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 6
      ant-design-vue-jeecg/src/views/task/modules/TaskForm.vue
  3. 108
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java
  4. 29
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java
  5. 64
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/controller/ModulexController.java
  6. 109
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java

@ -71,56 +71,38 @@
<div class="table-operator"> <div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<!-- <a-button type="primary" @click="showModal1()"></a-button> --> <!-- <a-button type="primary" @click="showModal1()"></a-button> -->
<a-button type="primary" icon="import" @click="showModalImport()">导入模块</a-button> <!-- <a-button type="primary" icon="import" @click="showModalImport()">导入模块</a-button>-->
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" <!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"-->
@change="handleImportExcel"> <!-- @change="handleImportExcel">-->
<a-modal <!-- <a-modal-->
title="正在上传..." <!-- title="正在上传..."-->
:visible="ModalData.isVisible==='true'" <!-- :visible="ModalData.isVisible==='true'"-->
:confirm-loading="false" <!-- :confirm-loading="false"-->
:mask="true" <!-- :mask="true"-->
:maskClosable="false" <!-- :maskClosable="false"-->
:keyboard="false" <!-- :keyboard="false"-->
:closable="false" <!-- :closable="false"-->
:footer="false" <!-- :footer="false"-->
> <!-- >-->
<p>当前状态{{ ModalData.status }}</p> <!-- <p>当前状态{{ ModalData.status }}</p>-->
<p>总记录数{{ ModalData.records }}</p> <!-- <p>总记录数{{ ModalData.records }}</p>-->
<p>已上传{{ ModalData.uploaded }}</p> <!-- <p>已上传{{ ModalData.uploaded }}</p>-->
<a-progress <!-- <a-progress-->
:percent="parseInt(String(ModalData.uploaded/ModalData.records*100))" <!-- :percent="parseInt(String(ModalData.uploaded/ModalData.records*100))"-->
title="上传进度:" <!-- title="上传进度:"-->
status="active" :steps="ModalData.records"/> <!-- status="active" :steps="ModalData.records"/>-->
</a-modal> <!-- </a-modal>-->
<a-button type="primary" icon="import" @click="showProcess">导入模块</a-button> <a-button type="primary" icon="import" @click="showProcess(modelData)">导入模块</a-button>
</a-upload> <!-- </a-upload>-->
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader"
:action="functionImportExcelUrl" @change="handleImportExcel"> :action="functionImportExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入功能</a-button> <a-button type="primary" icon="import">导入功能</a-button>
</a-upload> </a-upload>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader"
:action="ruleImportExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import" @click="showProcess( ruleData)">导入规则</a-button>
<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" <a-button type="primary" icon="import"
@click="showProcess(tablexData)">导入实体 @click="showProcess(tablexData)">导入实体
@ -129,10 +111,9 @@
<a-button @click="fanhui" type="primary" icon="rollback">返回</a-button> <a-button @click="fanhui" type="primary" icon="rollback">返回</a-button>
<a-button type="primary" icon="download" @click="exportxsxl('模块,功能,规则表')">导出综合表</a-button> <a-button type="primary" icon="download" @click="exportxsxl('模块,功能,规则表')">导出综合表</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrlf"
@change="handleImportExcel"> <a-button type="primary" icon="import" @click="showProcess( fieldData)">导入字段</a-button>
<a-button type="primary" icon="import">导入字段</a-button>
</a-upload>
</div> </div>
<!-- table区域-begin --> <!-- table区域-begin -->
@ -463,11 +444,15 @@ export default {
deleteBatch: "/modulex/modulex/deleteBatch", deleteBatch: "/modulex/modulex/deleteBatch",
exportXlsUrl: "/modulex/modulex/exportXls", exportXlsUrl: "/modulex/modulex/exportXls",
importExcelUrlf: "fieldx/fieldx/importExcel", importExcelUrlf: "fieldx/fieldx/importExcel",
exportExcelUrlf: "fieldx/fieldx/exportXls",
modelImportExcelUrl: "modulex/modulex/importExcel",
modelDownExcelUrl: "modulex/modulex/templateExcel",
importExcelUrl: "modulex/modulex/importExcel", importExcelUrl: "modulex/modulex/importExcel",
functionImportExcelUrl: "/functionx/functionx/importExcel", functionImportExcelUrl: "/functionx/functionx/importExcel",
tablexImportExcelUrl: "tablex/tablex/importExcel", tablexImportExcelUrl: "tablex/tablex/importExcel",
tablexDownExcelUrl: "tablex/tablex/templateExcel", tablexDownExcelUrl: "tablex/tablex/templateExcel",
ruleImportExcelUrl: "rulex/rulex/importExcel", ruleImportExcelUrl: "rulex/rulex/importExcel",
ruleDownExcelUrl: "rulex/rulex/downExcel",
exportxsxl: "modulex/modulex/exportxsxl" exportxsxl: "modulex/modulex/exportxsxl"
}, },
dictOptions: {}, dictOptions: {},
@ -488,12 +473,18 @@ export default {
this.getSuperFieldList() this.getSuperFieldList()
}, },
computed: { computed: {
importExcelUrl: function () { modelImportExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}` return `${window._CONFIG['domianURL']}/${this.url.modelImportExcelUrl}`
},
modelDownExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.modelDownExcelUrl}`
}, },
importExcelUrlf: function () { importExcelUrlf: function () {
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrlf}` return `${window._CONFIG['domianURL']}/${this.url.importExcelUrlf}`
}, },
exportExcelUrlf: function () {
return `${window._CONFIG['domianURL']}/${this.url.exportExcelUrlf}`
},
// columnsdataIndex // columnsdataIndex
checkColumn: function () { checkColumn: function () {
return this.columns.map(item => item.title) return this.columns.map(item => item.title)
@ -510,6 +501,9 @@ export default {
ruleImportExcelUrl: function () { ruleImportExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.ruleImportExcelUrl}` return `${window._CONFIG['domianURL']}/${this.url.ruleImportExcelUrl}`
}, },
ruleDownExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.ruleDownExcelUrl}`
},
tablexData: function () { tablexData: function () {
return { return {
note: ['对应模块id(必填):填写正确的模块名称', note: ['对应模块id(必填):填写正确的模块名称',
@ -523,6 +517,82 @@ export default {
uploadUrl: this.tablexImportExcelUrl, uploadUrl: this.tablexImportExcelUrl,
downUrl: this.tablexDownExcelUrl downUrl: this.tablexDownExcelUrl
} }
},
modelData: function () {
return {
note: ['上级模块名称(非必填): 添加一级模块不用填,添加二级模块要填',
'项目名称(必填): 从已存在的项目中选',
'中文名称(必填): 相同上级的模块不能重名',
'英文名称(必填): 中文名称的英文名称',
'模块编码(必填): 项目编码+模块缩写',
'责任人(非必填): 模块的开发任务可以分配给1个或多个人员',
'任务等级(必填): 值: 1、2、3、4、5',
'开发状态(必填):值: 未发布、已发布、开发中、已完成、已撤回、已取消',
'任务时长(必填): 单位小时: 等于下级模块时长的和;默认1(小时)',
'实际时长(必填): 单位小时;最小0.1小时;默认16',
'关联实体(非必填): 关联实体表;关联的是该模块管理的实体',
'模块状态(必填): 可填入值为正常、停用、废弃',
'版本状态(必填): 可填入值为当前、历史',
'版本号: 请填写小与五位数的正整数'
],
title: '导入模块',
uploadUrl: this.modelImportExcelUrl,
downUrl: "temp/2.xls",
downName: "mokua.xls"
}
},
fieldData: function () {
return {
note: ['序号: 请按顺序填入每行数据的序号,比如第一行就写1',
'表名(非空): 请填写实体表的名称',
'中文名称(非空): 请填写字段名称',
'英文名称(非空): 请填写字段名称的英语名称',
'数据类型(非空): 请填写数据类型,{char,varchar,int}这些等等,具体可以查看数据字典',
'数据长度(非空): 请填写该字段对应的长度',
'浮点精度: 请填写浮点精度',
'显示形式: 请填写该字段显示的形式',
'是否主键(非空): 请填写该字段是否为主键,填:是或否',
'是否外键(非空): 请填写该字段是否为外键,填:是或否',
'关联实体: 请填写该字段关联的其它实体表',
'关联字段: 请填写该字段关联实体表中对应的字段',
'是否为空(非空): 请填写该字段是否为空,填:是或否',
'是否重复(非空): 请填写该字段是否重复,填:是或否',
'字段规则: 请填写该字段的字段规则',
'字段状态(非空): 请填写该字段状态,填:正常、停用、废弃',
'版本状态(非空): 请填写该字段版本状态,填:当前,历史'
],
title: '导入字段',
uploadUrl: this.importExcelUrlf,
downUrl: this. exportExcelUrlf
}
},
ruleData: function () {
return {
note: ['对应模块(必填):填写正确的模块名称',
'对应功能(必填):填写正确的功能名称',
'对应实体(必填):填写正确的实体名称',
'对应字段(必填):填写正确的字段名称',
'顺序号(必填);同功能下不重复',
'规则编码(必填):功能编码+顺序号(格式001)',
'规则描述(非必填)',
'分析图(非必填)',
'责任人(非必填)',
'任务等级(必填):值:1、2、3、4、5个等级',
'任务状态(必填):值:未发布、已发布、开发中、已完成、已撤回、已取消',
'版本状态(必填): 可填入值为[当前、历史]',
'规则状态(必填): 值:正常、停用、废弃',
'开始时间(必填) ',
'任务时长(必填)',
'提交时间(必填)',
'实际时长(必填)',
'规则状态(必填): 值:正常、停用、废弃',
'版本号:请填写小与五位数的正整数'
],
title: '导入规则',
uploadUrl: this.ruleImportExcelUrl,
downUrl: this.ruleDownExcelUrl
}
} }
}, },
methods: { methods: {
@ -770,9 +840,10 @@ export default {
this.loadData() this.loadData()
}, },
}, }
} }
</script> </script>
<style scoped> <style scoped>
@import '~@assets/less/common.less'; @import '~@assets/less/common.less';

@ -175,6 +175,12 @@
<j-image-upload bizPath="scott/pic" v-model="model.taskPic"></j-image-upload> <j-image-upload bizPath="scott/pic" v-model="model.taskPic"></j-image-upload>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
<a-col :span="24">
<a-form-model-item label="1" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="taskPic">
<!-- <a-input v-model="model.taskPic" placeholder="请输入项目图片"></a-input>-->
<j-upload bizPath="temp/" v-model="model.taskPic"></j-upload>
</a-form-model-item>
</a-col>
</a-row> </a-row>
</a-form-model> </a-form-model>
</j-form-container> </j-form-container>

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

@ -18,8 +18,10 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.fieldx.dto.ExcelInfo; import org.jeecg.modules.fieldx.dto.ExcelInfo;
import org.jeecg.modules.fieldx.entity.Fieldx; import org.jeecg.modules.fieldx.entity.Fieldx;
import org.jeecg.modules.fieldx.entity.Fieldx222; import org.jeecg.modules.fieldx.entity.Fieldx222;
@ -34,6 +36,7 @@ import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.tablex.entity.Tablex; import org.jeecg.modules.tablex.entity.Tablex;
import org.jeecg.modules.tablex.service.ITablexService; import org.jeecg.modules.tablex.service.ITablexService;
import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.tablex.ws.WebSocketUtils;
import org.jsoup.helper.StringUtil; import org.jsoup.helper.StringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -60,6 +63,8 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
private ITablexService tablexService; private ITablexService tablexService;
@Autowired @Autowired
private IFieldx222Service fieldx222Service; private IFieldx222Service fieldx222Service;
@Autowired
private WebSocketUtils webSocketUtils;
/** /**
* 分页列表查询 * 分页列表查询
@ -290,12 +295,18 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
/** /**
* 通过excel导入数据 * 通过excel导入数据
* *
* @param request
* @param response
* @return * @return
*/ */
@PostMapping("/importExcel") @PostMapping("/importExcel")
public Result<?> importExcel(@RequestPart MultipartFile file) throws Exception { public Result<?> importExcel(@RequestPart MultipartFile file) throws Exception {
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
Map<String, String> message = new HashMap<>();
message.put("isVisible", "true");
message.put("uploaded", "0");
message.put("status", "判断文件结构");
webSocketUtils.sendMessage(loginUser.getId(), message);
if (file == null) { if (file == null) {
return Result.error("文件上传失败"); return Result.error("文件上传失败");
} }
@ -314,6 +325,8 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
workbook = new XSSFWorkbook(inputStream); workbook = new XSSFWorkbook(inputStream);
} }
//读取表 //读取表
message.put("status", "数据预读入");
webSocketUtils.sendMessage(loginUser.getId(), message);
List<Fieldx222> list = new ArrayList<>(); List<Fieldx222> list = new ArrayList<>();
//获取excel的所有页 //获取excel的所有页
int numberofSheets= workbook.getNumberOfSheets(); int numberofSheets= workbook.getNumberOfSheets();
@ -393,11 +406,19 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
} }
} }
message.put("status", "数据预读入成功");
webSocketUtils.sendMessage(loginUser.getId(), message);
message.put("status", "正在上传");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.saveBatch(list); fieldx222Service.saveBatch(list);
List<Fieldx222> list222 = fieldx222Service.list(); List<Fieldx222> list222 = fieldx222Service.list();
message.put("records", String.valueOf(list222.size()));
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null); fieldx222Service.remove(null);
if(list222==null) if(list222==null)
return Result.error("文件上传失败"); return Result.error("文件上传失败");
List<Fieldx> list1= list222.stream().map((item)->{ List<Fieldx> list1= list222.stream().map((item)->{
Fieldx fieldx=new Fieldx(); Fieldx fieldx=new Fieldx();
String id=item.getId(); String id=item.getId();
@ -424,7 +445,11 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
fieldx.setRule(item.getRull()); fieldx.setRule(item.getRull());
return fieldx; return fieldx;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
//将中间表数据导入数据库
fieldxService.saveBatch(list1); fieldxService.saveBatch(list1);
message.put("status", "上传成功");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.OK("文件上传成功"); return Result.OK("文件上传成功");
} }

@ -28,10 +28,14 @@ import org.jeecg.modules.modulex.mapper.ModulexMapper;
import org.jeecg.modules.modulex.service.IModulexService; import org.jeecg.modules.modulex.service.IModulexService;
import org.jeecg.modules.modulex.vo.ModuleFunctionRule; import org.jeecg.modules.modulex.vo.ModuleFunctionRule;
import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.def.TemplateExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.TemplateExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.modules.modulex.service.ModulexTemplateService; import org.jeecg.modules.modulex.service.ModulexTemplateService;
import org.jeecgframework.poi.excel.view.JeecgTemplateExcelView;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -40,8 +44,10 @@ import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -67,6 +73,9 @@ public class ModulexController extends JeecgController<Modulex, IModulexService>
@Autowired @Autowired
private ModulexTemplateService modulexTemplateService; private ModulexTemplateService modulexTemplateService;
@Value("${jeecg.wordPath}")
private String wordPath;
/** /**
* 分页列表查询 * 分页列表查询
* *
@ -398,4 +407,59 @@ public class ModulexController extends JeecgController<Modulex, IModulexService>
return mv; return mv;
} }
@AutoLog(value = "模块管理-新增下级")
@ApiOperation(value = "模块管理-添加下级", notes = "模块管理-添加下级")
@PutMapping("/addAddSubordinates")
public Result<?> addAddSubordinates(@RequestBody Modulex modulex){
if (StringUtils.hasText(modulex.getPid())){
List<String> collect = modulexService.list(
new LambdaQueryWrapper<Modulex>()
.eq(StringUtils.hasText(modulex.getPid()), Modulex::getPid, modulex.getPid()))
.stream().map(Modulex::getModuleName).collect(Collectors.toList());
collect.add(modulex.getModuleName());
HashSet<String> setList = new HashSet<>(collect);
if (collect.size() != setList.size()){
return Result.error("相同上级的模块不能重名");
}
}
Integer newVersion = modulexService.getMaxVersion(modulex.getVerison());
modulex.setVerison(newVersion + 1);
modulex.setRelatedBean(null);
boolean isTure = modulexService.save(modulex);
if(!isTure){
return Result.OK("新增下级失败");
}
return Result.OK("新增下级成功");
}
@RequestMapping(value = "/templateExcel")
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;
}
} }

@ -342,15 +342,11 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
String username = loginUser.getUsername(); String username = loginUser.getUsername();
if (file.isEmpty()) { if (file.isEmpty()) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("上传为空"); return Result.error("上传为空");
} }
String filename = file.getOriginalFilename(); String filename = file.getOriginalFilename();
String fileSuffix = filename.substring(filename.lastIndexOf(".")); String fileSuffix = filename.substring(filename.lastIndexOf("."));
if (!fileSuffix.equals(".xls") && !fileSuffix.equals(".xlsx")) { if (!fileSuffix.equals(".xls") && !fileSuffix.equals(".xlsx")) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件类型不对"); return Result.error("文件类型不对");
} }
List<ModulexTemplate> modulexVoList = new ArrayList<>(); List<ModulexTemplate> modulexVoList = new ArrayList<>();
@ -400,32 +396,24 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break; break;
case 1: case 1:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "项目名称为空"); return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "项目名称为空");
} }
modulexVo.setProjectId(value); modulexVo.setProjectId(value);
break; break;
case 2: case 2:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "中文名称为空"); return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "中文名称为空");
} }
modulexVo.setModuleName(value); modulexVo.setModuleName(value);
break; break;
case 3: case 3:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "英文名称为空"); return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "英文名称为空");
} }
modulexVo.setModuleEnName(value); modulexVo.setModuleEnName(value);
break; break;
case 4: case 4:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "模块编码为空"); return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "模块编码为空");
} }
modulexVo.setModuleCode(value); modulexVo.setModuleCode(value);
@ -438,16 +426,12 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break; break;
case 7: case 7:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "任务等级为空"); return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "任务等级为空");
} }
modulexVo.setWorkLevel(value); modulexVo.setWorkLevel(value);
break; break;
case 8: case 8:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "开发状态为空"); return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "开发状态为空");
} }
modulexVo.setWorkStatus(value); modulexVo.setWorkStatus(value);
@ -457,8 +441,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break; break;
case 10: case 10:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "任务时长为空"); return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "任务时长为空");
} }
modulexVo.setDuration(value); modulexVo.setDuration(value);
@ -471,8 +453,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break; break;
case 13: case 13:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "实际时长为空"); return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "实际时长为空");
} }
modulexVo.setRealDuration(value); modulexVo.setRealDuration(value);
@ -485,36 +465,26 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break; break;
case 16: case 16:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "模块状态为空"); return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "模块状态为空");
} }
modulexVo.setStatus(value); modulexVo.setStatus(value);
break; break;
case 17: case 17:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "版本状态为空"); return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "版本状态为空");
} }
modulexVo.setVerisonStatus(value); modulexVo.setVerisonStatus(value);
break; break;
case 18: case 18:
if (value == null || value == "") { if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "版本号为空"); return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "版本号为空");
}else if(value.length()<=0||value.length()>50){ }else if(value.length()<=0||value.length()>50){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("版本号不符合规范"); return Result.error("版本号不符合规范");
}else { }else {
modulexVo.setVerison(value); modulexVo.setVerison(value);
} }
break; break;
default: default:
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("未知错误"); return Result.error("未知错误");
} }
modulexVo.setUploadPerson(username); modulexVo.setUploadPerson(username);
@ -528,10 +498,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
List<Modulex> modulexList = new ArrayList<>(); List<Modulex> modulexList = new ArrayList<>();
List<ModulexTemplate> modulexTemplates = this.SelectModulex(); List<ModulexTemplate> modulexTemplates = this.SelectModulex();
message.put("records", String.valueOf(modulexTemplates.size()));
webSocketUtils.sendMessage(loginUser.getId(), message);
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
if(modulexTemplates==null||modulexTemplates.size()==0){ if(modulexTemplates==null||modulexTemplates.size()==0){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,预读数据失败,获取不到表格中的数据,请重新导入"); return Result.error("导入失败,预读数据失败,获取不到表格中的数据,请重新导入");
} }
else { else {
@ -541,8 +511,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
} }
boolean isTure = modulexTemplateService.removeByIds(ids); boolean isTure = modulexTemplateService.removeByIds(ids);
if(!isTure){ if(!isTure){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("预读数据删除失败,请重新导入"); return Result.error("预读数据删除失败,请重新导入");
} }
message.put("status", "导入数据中"); message.put("status", "导入数据中");
@ -556,35 +524,25 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
queryWrapper.eq(Modulex::getModuleName,pid); queryWrapper.eq(Modulex::getModuleName,pid);
List<Modulex> list = this.list(queryWrapper); List<Modulex> list = this.list(queryWrapper);
if(list==null ||list.size()==0){ if(list==null ||list.size()==0){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,此模块不存在上级"); return Result.error("导入失败,此模块不存在上级");
} }
Modulex one =list.get(0); Modulex one =list.get(0);
if(one==null){ if(one==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,此模块不存在上级"); return Result.error("导入失败,此模块不存在上级");
}String pid1 = one.getId(); }String pid1 = one.getId();
if(pid1==null){ if(pid1==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,此模块不存在上级"); return Result.error("导入失败,此模块不存在上级");
} }
modulex.setPid(pid1); modulex.setPid(pid1);
} }
String projectId = modulexTemplate.getProjectId(); String projectId = modulexTemplate.getProjectId();
if(projectId==null){ if(projectId==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,项目名称不能为空"); return Result.error("导入失败,项目名称不能为空");
}else { }else {
LambdaQueryWrapper<Projectx> projectxLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Projectx> projectxLambdaQueryWrapper = new LambdaQueryWrapper<>();
projectxLambdaQueryWrapper.eq(Projectx::getProjectName,projectId); projectxLambdaQueryWrapper.eq(Projectx::getProjectName,projectId);
Projectx projectx = projectxService.getOne(projectxLambdaQueryWrapper); Projectx projectx = projectxService.getOne(projectxLambdaQueryWrapper);
if(projectx==null){ if(projectx==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,项目名称不存在"); return Result.error("导入失败,项目名称不存在");
} else { } else {
String projectxId = projectx.getId(); String projectxId = projectx.getId();
@ -594,8 +552,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String moduleName = modulexTemplate.getModuleName(); String moduleName = modulexTemplate.getModuleName();
String pid1 = modulex.getPid(); String pid1 = modulex.getPid();
if(moduleName==null){ if(moduleName==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,中文名称不能为空"); return Result.error("导入失败,中文名称不能为空");
}else if(pid1==null){ }else if(pid1==null){
modulex.setModuleName(moduleName); modulex.setModuleName(moduleName);
@ -604,20 +560,14 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
modulexLambdaQueryWrapper.eq(Modulex::getPid,pid1).eq(Modulex::getModuleName,moduleName); modulexLambdaQueryWrapper.eq(Modulex::getPid,pid1).eq(Modulex::getModuleName,moduleName);
Modulex modulex1 = this.getOne(modulexLambdaQueryWrapper); Modulex modulex1 = this.getOne(modulexLambdaQueryWrapper);
if(modulex1!=null){ if(modulex1!=null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,相同的上级模块不能重名"); return Result.error("导入失败,相同的上级模块不能重名");
}modulex.setModuleName(moduleName); }modulex.setModuleName(moduleName);
String moduleEnName = modulexTemplate.getModuleEnName(); String moduleEnName = modulexTemplate.getModuleEnName();
if(moduleEnName==null){ if(moduleEnName==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,英文名称不能为空"); return Result.error("导入失败,英文名称不能为空");
}modulex.setModuleEnName(moduleEnName); }modulex.setModuleEnName(moduleEnName);
String moduleCode = modulexTemplate.getModuleCode(); String moduleCode = modulexTemplate.getModuleCode();
if(moduleCode==null||moduleCode.length()>30){ if(moduleCode==null||moduleCode.length()>30){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块编码不能为空或者模块编码过长"); return Result.error("导入失败,模块编码不能为空或者模块编码过长");
} }
String modulecode = null; String modulecode = null;
@ -627,14 +577,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String firstChar = this.toFirstChar(moduleName); String firstChar = this.toFirstChar(moduleName);
String projectCode = projectx.getProjectCode(); String projectCode = projectx.getProjectCode();
if(projectCode==null){ if(projectCode==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("项目编码不存在,请重新填写"); return Result.error("项目编码不存在,请重新填写");
} }
modulecode = projectCode + firstChar; modulecode = projectCode + firstChar;
if(!modulecode.equals(moduleCode)){ if(!modulecode.equals(moduleCode)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("模块编码不规范,导入失败"); return Result.error("模块编码不规范,导入失败");
} }
modulex.setModuleCode(moduleCode); modulex.setModuleCode(moduleCode);
@ -648,19 +594,13 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else { }else {
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
String[] split = managerUsers.split(","); String[] split = managerUsers.split(",");
// sysUserLambdaQueryWrapper.eq(SysUser::getUsername,managerUsers);
sysUserLambdaQueryWrapper.in(SysUser::getUsername,split); sysUserLambdaQueryWrapper.in(SysUser::getUsername,split);
List<SysUser> iSysUserServiceOne = iSysUserService.list(sysUserLambdaQueryWrapper); List<SysUser> iSysUserServiceOne = iSysUserService.list(sysUserLambdaQueryWrapper);
if(iSysUserServiceOne==null){ if(iSysUserServiceOne==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,责任人信息查询不到"); return Result.error("导入失败,责任人信息查询不到");
}else { }else {
List<String> list = iSysUserServiceOne.stream().map(SysUser::getId).collect(Collectors.toList()); List<String> list = iSysUserServiceOne.stream().map(SysUser::getId).collect(Collectors.toList());
// String id = iSysUserServiceOne.getId();
if (list == null) { if (list == null) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,责任人信息查询不到"); return Result.error("导入失败,责任人信息查询不到");
} }
modulex.setManagerUsers(String.valueOf(list)); modulex.setManagerUsers(String.valueOf(list));
@ -668,23 +608,17 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
} }
String workLevel = modulexTemplate.getWorkLevel(); String workLevel = modulexTemplate.getWorkLevel();
if(StringUtils.isBlank(workLevel)){ if(StringUtils.isBlank(workLevel)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务等级不能为空"); return Result.error("导入失败,任务等级不能为空");
} }
else { else {
Integer integer = Integer.valueOf(workLevel); Integer integer = Integer.valueOf(workLevel);
if(integer<=0&&integer>=6){ if(integer<=0&&integer>=6){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务等级不规范"); return Result.error("导入失败,任务等级不规范");
} }
modulex.setWorkLevel(integer); modulex.setWorkLevel(integer);
} }
String workStatus = modulexTemplate.getWorkStatus(); String workStatus = modulexTemplate.getWorkStatus();
if(StringUtils.isBlank(workStatus)){ if(StringUtils.isBlank(workStatus)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,工作状态不能为空"); return Result.error("导入失败,工作状态不能为空");
}else { }else {
Integer integer = 100; Integer integer = 100;
@ -702,8 +636,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
case "已取出": integer = 9; case "已取出": integer = 9;
break; break;
default: default:
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,开发状态不规范"); return Result.error("导入失败,开发状态不规范");
} }
modulex.setWorkStatus(integer); modulex.setWorkStatus(integer);
@ -714,8 +646,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else { }else {
Boolean result = this.checkTime(publishTime); Boolean result = this.checkTime(publishTime);
if(!result){ if(!result){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,日期格式不规范"); return Result.error("导入失败,日期格式不规范");
}else { }else {
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(publishTime); Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(publishTime);
@ -724,8 +654,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
} }
String duration = modulexTemplate.getDuration(); String duration = modulexTemplate.getDuration();
if(StringUtils.isBlank(duration)){ if(StringUtils.isBlank(duration)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务时长不能为空"); return Result.error("导入失败,任务时长不能为空");
}else { }else {
double parseDouble = Double.parseDouble(duration); double parseDouble = Double.parseDouble(duration);
@ -737,8 +665,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else { }else {
Boolean result = this.checkTime(startTime); Boolean result = this.checkTime(startTime);
if(!result){ if(!result){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,开始时间不规范"); return Result.error("导入失败,开始时间不规范");
}else { }else {
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(startTime); Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(startTime);
@ -751,8 +677,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else { }else {
Boolean result = this.checkTime(submitTime); Boolean result = this.checkTime(submitTime);
if(!result){ if(!result){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,提交时间不规范"); return Result.error("导入失败,提交时间不规范");
}else { }else {
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(submitTime); Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(submitTime);
@ -761,14 +685,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
} }
String realDuration = modulexTemplate.getRealDuration(); String realDuration = modulexTemplate.getRealDuration();
if(StringUtils.isBlank(realDuration)){ if(StringUtils.isBlank(realDuration)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,实际时长不能为空"); return Result.error("导入失败,实际时长不能为空");
}else { }else {
double parseDouble = Double.parseDouble(realDuration); double parseDouble = Double.parseDouble(realDuration);
if(parseDouble<0.1){ if(parseDouble<0.1){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,最小时间0.1小时"); return Result.error("导入失败,最小时间0.1小时");
} }
modulex.setRealDuration(parseDouble); modulex.setRealDuration(parseDouble);
@ -781,14 +701,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
sysRoleLambdaQueryWrapper.eq(SysRole::getRoleName,userRole); sysRoleLambdaQueryWrapper.eq(SysRole::getRoleName,userRole);
SysRole one = iSysRoleService.getOne(sysRoleLambdaQueryWrapper); SysRole one = iSysRoleService.getOne(sysRoleLambdaQueryWrapper);
if(one==null){ if(one==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,用户角色不存在"); return Result.error("导入失败,用户角色不存在");
} }
String useRole = one.getId(); String useRole = one.getId();
if(useRole==null){ if(useRole==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,用户角色不存在"); return Result.error("导入失败,用户角色不存在");
} modulex.setUserRole(useRole); } modulex.setUserRole(useRole);
} }
@ -798,15 +714,11 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else { }else {
Boolean extracted = extracted(modulex, relatedBean); Boolean extracted = extracted(modulex, relatedBean);
if(!extracted){ if(!extracted){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("关联实体不存在"); return Result.error("关联实体不存在");
} }
} }
String status = modulexTemplate.getStatus(); String status = modulexTemplate.getStatus();
if(StringUtils.isBlank(status)){ if(StringUtils.isBlank(status)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块状态不能为空"); return Result.error("导入失败,模块状态不能为空");
}else { }else {
Integer integer = 100; Integer integer = 100;
@ -818,16 +730,12 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
case "废弃": integer = 9; case "废弃": integer = 9;
break; break;
default: default:
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块状态不规范匹配不到"); return Result.error("导入失败,模块状态不规范匹配不到");
} }
modulex.setStatus(integer); modulex.setStatus(integer);
} }
String verisonStatus = modulexTemplate.getVerisonStatus(); String verisonStatus = modulexTemplate.getVerisonStatus();
if(StringUtils.isBlank(verisonStatus)){ if(StringUtils.isBlank(verisonStatus)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,版本状态不能为空"); return Result.error("导入失败,版本状态不能为空");
}else { }else {
Integer integer = 100; Integer integer = 100;
@ -837,16 +745,12 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
case "历史": integer = 0; case "历史": integer = 0;
break; break;
default: default:
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
Result.error("导入失败,版本状态不规范,匹配失败"); Result.error("导入失败,版本状态不规范,匹配失败");
} }
modulex.setVerisonStatus(integer); modulex.setVerisonStatus(integer);
} }
String verison = modulexTemplate.getVerison(); String verison = modulexTemplate.getVerison();
if(StringUtils.isBlank(verison)){ if(StringUtils.isBlank(verison)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,版本号不能为空"); return Result.error("导入失败,版本号不能为空");
}else { }else {
int parseInt = Integer.parseInt(verison); int parseInt = Integer.parseInt(verison);
@ -856,12 +760,8 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
} }
boolean result = this.saveSingleBatch(modulexList, loginUser, message); boolean result = this.saveSingleBatch(modulexList, loginUser, message);
if(!result){ if(!result){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("未知错误导入失败,请重新导入"); return Result.error("未知错误导入失败,请重新导入");
} }
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.OK("导入成功"); return Result.OK("导入成功");
} }
} }
@ -927,12 +827,11 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
message.put("uploaded", String.valueOf(i + 1)); message.put("uploaded", String.valueOf(i + 1));
isTrue = this.save(modulexList.get(i)); isTrue = this.save(modulexList.get(i));
if(!isTrue){ if(!isTrue){
webSocketUtils.sendMessage(loginUser.getId(), message);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return false; return false;
} }
webSocketUtils.sendMessage(loginUser.getId(), message);
} }
return true; return true;
} }

Loading…
Cancel
Save