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. 100
      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">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<!-- <a-button type="primary" @click="showModal1()"></a-button> -->
<a-button type="primary" icon="import" @click="showModalImport()">导入模块</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="handleImportExcel">
<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-button type="primary" icon="import" @click="showProcess">导入模块</a-button>
</a-upload>
<!-- <a-button type="primary" icon="import" @click="showModalImport()">导入模块</a-button>-->
<!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"-->
<!-- @change="handleImportExcel">-->
<!-- <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-button type="primary" icon="import" @click="showProcess(modelData)">导入模块</a-button>
<!-- </a-upload>-->
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader"
: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)">导入实体
@ -129,10 +111,9 @@
<a-button @click="fanhui" type="primary" icon="rollback">返回</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">导入字段</a-button>
</a-upload>
<a-button type="primary" icon="import" @click="showProcess( fieldData)">导入字段</a-button>
</div>
<!-- table区域-begin -->
@ -463,11 +444,15 @@ export default {
deleteBatch: "/modulex/modulex/deleteBatch",
exportXlsUrl: "/modulex/modulex/exportXls",
importExcelUrlf: "fieldx/fieldx/importExcel",
exportExcelUrlf: "fieldx/fieldx/exportXls",
modelImportExcelUrl: "modulex/modulex/importExcel",
modelDownExcelUrl: "modulex/modulex/templateExcel",
importExcelUrl: "modulex/modulex/importExcel",
functionImportExcelUrl: "/functionx/functionx/importExcel",
tablexImportExcelUrl: "tablex/tablex/importExcel",
tablexDownExcelUrl: "tablex/tablex/templateExcel",
ruleImportExcelUrl: "rulex/rulex/importExcel",
ruleDownExcelUrl: "rulex/rulex/downExcel",
exportxsxl: "modulex/modulex/exportxsxl"
},
dictOptions: {},
@ -488,12 +473,18 @@ export default {
this.getSuperFieldList()
},
computed: {
importExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
modelImportExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.modelImportExcelUrl}`
},
modelDownExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.modelDownExcelUrl}`
},
importExcelUrlf: function () {
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrlf}`
},
exportExcelUrlf: function () {
return `${window._CONFIG['domianURL']}/${this.url.exportExcelUrlf}`
},
// columnsdataIndex
checkColumn: function () {
return this.columns.map(item => item.title)
@ -510,6 +501,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(必填):填写正确的模块名称',
@ -523,6 +517,82 @@ export default {
uploadUrl: this.tablexImportExcelUrl,
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: {
@ -770,9 +840,10 @@ export default {
this.loadData()
},
},
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';

@ -175,6 +175,12 @@
<j-image-upload bizPath="scott/pic" v-model="model.taskPic"></j-image-upload>
</a-form-model-item>
</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-form-model>
</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.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);
@ -439,8 +434,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
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));
@ -546,10 +534,11 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
webSocketUtils.sendMessage(loginUser.getId(), message);
//存入真实表
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;
}
}

@ -18,8 +18,10 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
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.entity.Fieldx;
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.service.ITablexService;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.tablex.ws.WebSocketUtils;
import org.jsoup.helper.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -60,6 +63,8 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
private ITablexService tablexService;
@Autowired
private IFieldx222Service fieldx222Service;
@Autowired
private WebSocketUtils webSocketUtils;
/**
* 分页列表查询
@ -290,12 +295,18 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@PostMapping("/importExcel")
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) {
return Result.error("文件上传失败");
}
@ -314,6 +325,8 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
workbook = new XSSFWorkbook(inputStream);
}
//读取表
message.put("status", "数据预读入");
webSocketUtils.sendMessage(loginUser.getId(), message);
List<Fieldx222> list = new ArrayList<>();
//获取excel的所有页
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);
List<Fieldx222> list222 = fieldx222Service.list();
message.put("records", String.valueOf(list222.size()));
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
if(list222==null)
return Result.error("文件上传失败");
List<Fieldx> list1= list222.stream().map((item)->{
Fieldx fieldx=new Fieldx();
String id=item.getId();
@ -424,7 +445,11 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
fieldx.setRule(item.getRull());
return fieldx;
}).collect(Collectors.toList());
//将中间表数据导入数据库
fieldxService.saveBatch(list1);
message.put("status", "上传成功");
webSocketUtils.sendMessage(loginUser.getId(), message);
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.vo.ModuleFunctionRule;
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.TemplateExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
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.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -40,8 +44,10 @@ import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -67,6 +73,9 @@ public class ModulexController extends JeecgController<Modulex, IModulexService>
@Autowired
private ModulexTemplateService modulexTemplateService;
@Value("${jeecg.wordPath}")
private String wordPath;
/**
* 分页列表查询
*
@ -398,4 +407,59 @@ public class ModulexController extends JeecgController<Modulex, IModulexService>
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);
String username = loginUser.getUsername();
if (file.isEmpty()) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("上传为空");
}
String filename = file.getOriginalFilename();
String fileSuffix = filename.substring(filename.lastIndexOf("."));
if (!fileSuffix.equals(".xls") && !fileSuffix.equals(".xlsx")) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件类型不对");
}
List<ModulexTemplate> modulexVoList = new ArrayList<>();
@ -400,32 +396,24 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break;
case 1:
if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "项目名称为空");
}
modulexVo.setProjectId(value);
break;
case 2:
if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "中文名称为空");
}
modulexVo.setModuleName(value);
break;
case 3:
if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "英文名称为空");
}
modulexVo.setModuleEnName(value);
break;
case 4:
if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "模块编码为空");
}
modulexVo.setModuleCode(value);
@ -438,16 +426,12 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break;
case 7:
if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "任务等级为空");
}
modulexVo.setWorkLevel(value);
break;
case 8:
if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "开发状态为空");
}
modulexVo.setWorkStatus(value);
@ -457,8 +441,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break;
case 10:
if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "任务时长为空");
}
modulexVo.setDuration(value);
@ -471,8 +453,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break;
case 13:
if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "实际时长为空");
}
modulexVo.setRealDuration(value);
@ -485,36 +465,26 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break;
case 16:
if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "模块状态为空");
}
modulexVo.setStatus(value);
break;
case 17:
if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "版本状态为空");
}
modulexVo.setVerisonStatus(value);
break;
case 18:
if (value == null || value == "") {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "版本号为空");
}else if(value.length()<=0||value.length()>50){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("版本号不符合规范");
}else {
modulexVo.setVerison(value);
}
break;
default:
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("未知错误");
}
modulexVo.setUploadPerson(username);
@ -528,10 +498,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
List<Modulex> modulexList = new ArrayList<>();
List<ModulexTemplate> modulexTemplates = this.SelectModulex();
message.put("records", String.valueOf(modulexTemplates.size()));
webSocketUtils.sendMessage(loginUser.getId(), message);
List<String> ids = new ArrayList<>();
if(modulexTemplates==null||modulexTemplates.size()==0){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,预读数据失败,获取不到表格中的数据,请重新导入");
}
else {
@ -541,8 +511,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}
boolean isTure = modulexTemplateService.removeByIds(ids);
if(!isTure){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("预读数据删除失败,请重新导入");
}
message.put("status", "导入数据中");
@ -556,35 +524,25 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
queryWrapper.eq(Modulex::getModuleName,pid);
List<Modulex> list = this.list(queryWrapper);
if(list==null ||list.size()==0){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,此模块不存在上级");
}
Modulex one =list.get(0);
if(one==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,此模块不存在上级");
}String pid1 = one.getId();
if(pid1==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,此模块不存在上级");
}
modulex.setPid(pid1);
}
String projectId = modulexTemplate.getProjectId();
if(projectId==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,项目名称不能为空");
}else {
LambdaQueryWrapper<Projectx> projectxLambdaQueryWrapper = new LambdaQueryWrapper<>();
projectxLambdaQueryWrapper.eq(Projectx::getProjectName,projectId);
Projectx projectx = projectxService.getOne(projectxLambdaQueryWrapper);
if(projectx==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,项目名称不存在");
} else {
String projectxId = projectx.getId();
@ -594,8 +552,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String moduleName = modulexTemplate.getModuleName();
String pid1 = modulex.getPid();
if(moduleName==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,中文名称不能为空");
}else if(pid1==null){
modulex.setModuleName(moduleName);
@ -604,20 +560,14 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
modulexLambdaQueryWrapper.eq(Modulex::getPid,pid1).eq(Modulex::getModuleName,moduleName);
Modulex modulex1 = this.getOne(modulexLambdaQueryWrapper);
if(modulex1!=null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,相同的上级模块不能重名");
}modulex.setModuleName(moduleName);
String moduleEnName = modulexTemplate.getModuleEnName();
if(moduleEnName==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,英文名称不能为空");
}modulex.setModuleEnName(moduleEnName);
String moduleCode = modulexTemplate.getModuleCode();
if(moduleCode==null||moduleCode.length()>30){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块编码不能为空或者模块编码过长");
}
String modulecode = null;
@ -627,14 +577,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
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);
@ -648,19 +594,13 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else {
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
String[] split = managerUsers.split(",");
// sysUserLambdaQueryWrapper.eq(SysUser::getUsername,managerUsers);
sysUserLambdaQueryWrapper.in(SysUser::getUsername,split);
List<SysUser> iSysUserServiceOne = iSysUserService.list(sysUserLambdaQueryWrapper);
if(iSysUserServiceOne==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,责任人信息查询不到");
}else {
List<String> list = iSysUserServiceOne.stream().map(SysUser::getId).collect(Collectors.toList());
// String id = iSysUserServiceOne.getId();
if (list == null) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,责任人信息查询不到");
}
modulex.setManagerUsers(String.valueOf(list));
@ -668,23 +608,17 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}
String workLevel = modulexTemplate.getWorkLevel();
if(StringUtils.isBlank(workLevel)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务等级不能为空");
}
else {
Integer integer = Integer.valueOf(workLevel);
if(integer<=0&&integer>=6){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务等级不规范");
}
modulex.setWorkLevel(integer);
}
String workStatus = modulexTemplate.getWorkStatus();
if(StringUtils.isBlank(workStatus)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,工作状态不能为空");
}else {
Integer integer = 100;
@ -702,8 +636,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
case "已取出": integer = 9;
break;
default:
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,开发状态不规范");
}
modulex.setWorkStatus(integer);
@ -714,8 +646,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else {
Boolean result = this.checkTime(publishTime);
if(!result){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,日期格式不规范");
}else {
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();
if(StringUtils.isBlank(duration)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务时长不能为空");
}else {
double parseDouble = Double.parseDouble(duration);
@ -737,8 +665,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else {
Boolean result = this.checkTime(startTime);
if(!result){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,开始时间不规范");
}else {
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 {
Boolean result = this.checkTime(submitTime);
if(!result){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,提交时间不规范");
}else {
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();
if(StringUtils.isBlank(realDuration)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,实际时长不能为空");
}else {
double parseDouble = Double.parseDouble(realDuration);
if(parseDouble<0.1){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,最小时间0.1小时");
}
modulex.setRealDuration(parseDouble);
@ -781,14 +701,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
sysRoleLambdaQueryWrapper.eq(SysRole::getRoleName,userRole);
SysRole one = iSysRoleService.getOne(sysRoleLambdaQueryWrapper);
if(one==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,用户角色不存在");
}
String useRole = one.getId();
if(useRole==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,用户角色不存在");
} modulex.setUserRole(useRole);
}
@ -798,15 +714,11 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else {
Boolean extracted = extracted(modulex, relatedBean);
if(!extracted){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("关联实体不存在");
}
}
String status = modulexTemplate.getStatus();
if(StringUtils.isBlank(status)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块状态不能为空");
}else {
Integer integer = 100;
@ -818,16 +730,12 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
case "废弃": integer = 9;
break;
default:
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块状态不规范匹配不到");
}
modulex.setStatus(integer);
}
String verisonStatus = modulexTemplate.getVerisonStatus();
if(StringUtils.isBlank(verisonStatus)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,版本状态不能为空");
}else {
Integer integer = 100;
@ -837,16 +745,12 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
case "历史": integer = 0;
break;
default:
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
Result.error("导入失败,版本状态不规范,匹配失败");
}
modulex.setVerisonStatus(integer);
}
String verison = modulexTemplate.getVerison();
if(StringUtils.isBlank(verison)){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,版本号不能为空");
}else {
int parseInt = Integer.parseInt(verison);
@ -856,12 +760,8 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}
boolean result = this.saveSingleBatch(modulexList, loginUser, message);
if(!result){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("未知错误导入失败,请重新导入");
}
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.OK("导入成功");
}
}
@ -927,12 +827,11 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
message.put("uploaded", String.valueOf(i + 1));
isTrue = this.save(modulexList.get(i));
if(!isTrue){
webSocketUtils.sendMessage(loginUser.getId(), message);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return false;
}
webSocketUtils.sendMessage(loginUser.getId(), message);
}
return true;
}

Loading…
Cancel
Save