模块管理导入功能交互

dev^2
lijinyu 1 year ago
parent 757a9971c0
commit d453ec37c5
  1. 80
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 28
      ant-design-vue-jeecg/src/views/modulex/modules/ModulexImport.vue
  3. 6
      ant-design-vue-jeecg/src/views/task/modules/TaskForm.vue
  4. 64
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/controller/ModulexController.java
  5. 109
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java
  6. 4
      jeecg-boot/jeecg-boot-module-system/src/main/resources/application-dev.yml

@ -71,29 +71,29 @@
<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>
@ -443,7 +443,8 @@ 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",
importExcelUrl: "modulex/modulex/importExcel", modelImportExcelUrl: "modulex/modulex/importExcel",
modelDownExcelUrl: "modulex/modulex/templateExcel",
functionImportExcelUrl: "/functionx/functionx/importExcel", functionImportExcelUrl: "/functionx/functionx/importExcel",
tablexImportExcelUrl: "tablex/tablex/importExcel", tablexImportExcelUrl: "tablex/tablex/importExcel",
tablexDownExcelUrl: "tablex/tablex/templateExcel", tablexDownExcelUrl: "tablex/tablex/templateExcel",
@ -469,8 +470,11 @@ export default {
/* this.showProcess()*/ /* this.showProcess()*/
}, },
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}`
@ -509,6 +513,30 @@ export default {
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"
}
},
ruleData: function () { ruleData: function () {
return { return {
note: ['对应模块(必填):填写正确的模块名称', note: ['对应模块(必填):填写正确的模块名称',

@ -56,7 +56,7 @@
</template> </template>
<script> <script>
import {getAction} from "@api/manage" import {downloadFile, getAction} from "@api/manage"
import store from '@/store' import store from '@/store'
import {JeecgListMixin} from '@/mixins/JeecgListMixin' import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {mixinDevice} from '@/utils/mixin' import {mixinDevice} from '@/utils/mixin'
@ -80,6 +80,7 @@ export default {
}, },
confirmLoading: false, confirmLoading: false,
form: this.$form.createForm(this), form: this.$form.createForm(this),
downName:'',
url: url:
{ {
downfile: '', downfile: '',
@ -129,18 +130,20 @@ export default {
}, },
// //
handleDownload() { handleDownload() {
downloadFile( this.url.downfile,this.downName)
// getAction(this.url.list, params).then((res) => // getAction(this.url.list, params).then((res) =>
getAction(this.url.downfile).then((response) => { // getAction(this.url.downfile)
const url = window.URL.createObjectURL(new Blob([response.data])) // downloadFile( window._CONFIG['downloadUrl'],'temp/ (1).xls').then((response) => {
const link = document.createElement('a') // const url = window.URL.createObjectURL(new Blob([response.data]))
link.href = url // const link = document.createElement('a')
link.setAttribute('download', 'your-document.pdf') // link.href = url
document.body.appendChild(link) // link.setAttribute('download', 'your-document.pdf')
link.click() // document.body.appendChild(link)
}) // link.click()
.catch(error => { // })
console.error(error) // .catch(error => {
}) // console.error(error)
// })
}, },
add() { add() {
@ -148,6 +151,7 @@ export default {
show(data) { show(data) {
this.url.uploadUrl = data.uploadUrl this.url.uploadUrl = data.uploadUrl
this.url.downfile = data.downUrl this.url.downfile = data.downUrl
this.downName = data.downName
this.datas=data.note this.datas=data.note
this.title=data.title this.title=data.title
this.ModalData = {} this.ModalData = {}

@ -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>

@ -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;
} }

@ -137,9 +137,9 @@ spring:
# driver-class-name: com.mysql.cj.jdbc.Driver # driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置 # 多数据源配置
#multi-datasource1: #multi-datasource1:
url: jdbc:mysql://127.0.0.1:3306/project_management?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai url: jdbc:mysql://182.92.169.222:3306/project_management?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root username: root
password: root password: ycwl2022.
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
#redis 配置 #redis 配置
redis: redis:

Loading…
Cancel
Save