associate handbook and project ID

jzq 2024-07-14 23:41:55 +08:00
parent a2fb920480
commit f64500b99f
25 changed files with 4689 additions and 6 deletions

View File

@ -352,6 +352,13 @@
<version>${ruoyi-flowable-plus.version}</version> <version>${ruoyi-flowable-plus.version}</version>
</dependency> </dependency>
<!-- scientific模块 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>scientific</artifactId>
<version>${ruoyi-flowable-plus.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -367,6 +374,7 @@
<module>ruoyi-oss</module> <module>ruoyi-oss</module>
<module>ruoyi-sms</module> <module>ruoyi-sms</module>
<module>ruoyi-system</module> <module>ruoyi-system</module>
<module>scientific</module>
</modules> </modules>
<packaging>pom</packaging> <packaging>pom</packaging>

View File

@ -78,6 +78,12 @@
<artifactId>ruoyi-demo</artifactId> <artifactId>ruoyi-demo</artifactId>
</dependency> </dependency>
<!-- scientific模块 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>scientific</artifactId>
</dependency>
<!-- flowable模块--> <!-- flowable模块-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>

View File

@ -227,6 +227,13 @@ public class WfProcessController extends BaseController {
return R.ok("流程启动成功"); return R.ok("流程启动成功");
} }
@SaCheckPermission("workflow:process:start")
@PostMapping("/startId/{processDefId}")
public R<Void> start_(@PathVariable(value = "processDefId") String processDefId, @RequestBody Map<String, Object> variables) {
String processInstanceId = processService.startProcessByDefId_(processDefId, variables);
return R.ok(processInstanceId);
}
/** /**
* *
* *

View File

@ -123,4 +123,6 @@ public interface IWfProcessService {
TableDataInfo<WfTaskInfoVo> selectPageOwnProcessInfoList(ProcessQuery processQuery, PageQuery pageQuery); TableDataInfo<WfTaskInfoVo> selectPageOwnProcessInfoList(ProcessQuery processQuery, PageQuery pageQuery);
String startProcessByDefId_(String processDefId, Map<String, Object> variables);
} }

View File

@ -664,6 +664,18 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
} }
} }
@Transactional(rollbackFor = Exception.class)
public String startProcessByDefId_(String procDefId, Map<String, Object> variables) {
try {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.processDefinitionId(procDefId).singleResult();
return startProcess_(processDefinition, variables);
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException("流程启动错误");
}
}
/** /**
* DefinitionKey * DefinitionKey
* @param procDefKey Key * @param procDefKey Key
@ -777,6 +789,23 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
wfTaskService.startFirstTask(processInstance, variables); wfTaskService.startFirstTask(processInstance, variables);
} }
private String startProcess_(ProcessDefinition procDef, Map<String, Object> variables) {
if (ObjectUtil.isNotNull(procDef) && procDef.isSuspended()) {
throw new ServiceException("流程已被挂起,请先激活流程");
}
// 设置流程发起人Id到流程中
String userIdStr = TaskUtils.getUserId();
identityService.setAuthenticatedUserId(userIdStr);
variables.put(BpmnXMLConstants.ATTRIBUTE_EVENT_START_INITIATOR, userIdStr);
// 设置流程状态为进行中
variables.put(ProcessConstants.PROCESS_STATUS_KEY, ProcessStatus.RUNNING.getStatus());
// 发起流程实例
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDef.getId(), variables);
// 第一个用户任务为发起人,则自动完成任务
wfTaskService.startFirstTask(processInstance, variables);
return processInstance.getProcessInstanceId();
}
/** /**
* *

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询科研管理列表
export function listProject(query) {
return request({
url: '/scientific/project/list',
method: 'get',
params: query
})
}
// 查询科研管理详细
export function getProject(id) {
return request({
url: '/scientific/project/' + id,
method: 'get'
})
}
// 新增科研管理
export function addProject(data) {
return request({
url: '/scientific/project',
method: 'post',
data: data
})
}
// 修改科研管理
export function updateProject(data) {
return request({
url: '/scientific/project',
method: 'put',
data: data
})
}
// 删除科研管理
export function delProject(id) {
return request({
url: '/scientific/project/' + id,
method: 'delete'
})
}

View File

@ -27,6 +27,14 @@ export function startProcess(processDefId, data) {
}) })
} }
export function startProcess_(processDefId, data) {
return request({
url: '/workflow/process/startId/' + processDefId,
method: 'post',
data: data
})
}
// 删除流程实例 // 删除流程实例
export function delProcess(ids) { export function delProcess(ids) {
return request({ return request({

View File

@ -195,6 +195,26 @@ export const dynamicRoutes = [
} }
] ]
}, },
{
path: '/scientific',
component: Layout,
hidden: true,
permissions: ['scientific:start'],
children: [
{
path: 'start/:deployId([\\w|\\-]+)',
component: () => import('@/views/scientific/start'),
name: 'ProjectApplyStart',
meta: { title: '项目申报', icon: '' }
},
// {
// path: 'detail/:procInsId([\\w|\\-]+)',
// component: () => import('@/views/scientific/detail'),
// name: 'WorkDetail',
// meta: { title: '流程详情', activeMenu: '/work/own' }
// }
]
},
] ]
// 防止连续点击多次路由报错 // 防止连续点击多次路由报错

View File

@ -210,10 +210,11 @@ export default {
const apply = response.rows[0]; const apply = response.rows[0];
if(apply) { if(apply) {
this.$router.push({ this.$router.push({
path: '/workflow/process/start/' + apply.deploymentId, path: '/scientific/start/' + apply.deploymentId,
query: { query: {
definitionId: apply.definitionId, definitionId: apply.definitionId,
processName: apply.processName, processName: row.handbookname,
handbookId: row.procInsId,
} }
}) })
} }
@ -250,7 +251,7 @@ export default {
let processForm = row.processFormList[0]; let processForm = row.processFormList[0];
let formData = []; let formData = [];
this.initFormData(processForm.fields, formData); this.initFormData(processForm.fields, formData);
formData["procDefId"] = row.procInsId; formData["procInsId"] = row.procInsId;
this.showList.push(formData); this.showList.push(formData);
}) })

View File

@ -0,0 +1,339 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="项目id" prop="projectId">
<el-input
v-model="queryParams.projectId"
placeholder="请输入项目id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="指南id" prop="handbookId">
<el-input
v-model="queryParams.handbookId"
placeholder="请输入指南id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="项目类别" prop="category">
<el-input
v-model="queryParams.category"
placeholder="请输入项目类别"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="项目名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入项目名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="项目创建时间" prop="createTime">
<el-date-picker clearable
v-model="queryParams.createTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择项目创建时间">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['scientific:project:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['scientific:project:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['scientific:project:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['scientific:project:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="projectList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="" align="center" prop="id" v-if="true"/>
<el-table-column label="项目id" align="center" prop="projectId" />
<el-table-column label="指南id" align="center" prop="handbookId" />
<el-table-column label="项目类别" align="center" prop="category" />
<el-table-column label="项目名称" align="center" prop="name" />
<el-table-column label="项目创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['scientific:project:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['scientific:project:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改科研管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="项目id" prop="projectId">
<el-input v-model="form.projectId" placeholder="请输入项目id" />
</el-form-item>
<el-form-item label="指南id" prop="handbookId">
<el-input v-model="form.handbookId" placeholder="请输入指南id" />
</el-form-item>
<el-form-item label="项目类别" prop="category">
<el-input v-model="form.category" placeholder="请输入项目类别" />
</el-form-item>
<el-form-item label="项目名称" prop="name">
<el-input v-model="form.name" placeholder="请输入项目名称" />
</el-form-item>
<el-form-item label="项目创建时间" prop="createTime">
<el-date-picker clearable
v-model="form.createTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择项目创建时间">
</el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listProject, getProject, delProject, addProject, updateProject } from "@/api/scientific/project";
export default {
name: "Project",
data() {
return {
// loading
buttonLoading: false,
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
projectList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
projectId: undefined,
handbookId: undefined,
category: undefined,
name: undefined,
createTime: undefined
},
//
form: {},
//
rules: {
id: [
{ required: true, message: "不能为空", trigger: "blur" }
],
projectId: [
{ required: true, message: "项目id不能为空", trigger: "blur" }
],
handbookId: [
{ required: true, message: "指南id不能为空", trigger: "blur" }
],
category: [
{ required: true, message: "项目类别不能为空", trigger: "blur" }
],
name: [
{ required: true, message: "项目名称不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询科研管理列表 */
getList() {
this.loading = true;
listProject(this.queryParams).then(response => {
this.projectList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: undefined,
projectId: undefined,
handbookId: undefined,
category: undefined,
name: undefined,
createTime: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加科研管理";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const id = row.id || this.ids
getProject(id).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改科研管理";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.id != null) {
updateProject(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addProject(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除科研管理编号为"' + ids + '"的数据项?').then(() => {
this.loading = true;
return delProject(ids);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('scientific/project/export', {
...this.queryParams
}, `project_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@ -0,0 +1,114 @@
<template>
<div class="app-container">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>{{ processName }}</span>
</div>
<el-col :span="18" :offset="3">
<div class="form-conf" v-if="formOpen">
<parser :key="new Date().getTime()" :form-conf="formData" @submit="submit" ref="parser" @getData="getData"/>
</div>
</el-col>
</el-card>
</div>
</template>
<script>
import { getProcessForm, startProcess_ } from '@/api/workflow/process'
import Parser from '@/utils/generator/parser'
import {addProject} from "@/api/scientific/project";
export default {
name: 'WorkStart',
components: {
Parser
},
data() {
return {
definitionId: null,
deployId: null,
procInsId: null,
formOpen: false,
formData: {},
processName: null,
}
},
created() {
this.initData();
},
methods: {
initData() {
this.deployId = this.$route.params && this.$route.params.deployId;
this.definitionId = this.$route.query && this.$route.query.definitionId;
this.procInsId = this.$route.query && this.$route.query.procInsId;
this.processName = this.$route.query && this.$route.query.processName;
this.handbookId = this.$route.query && this.$route.query.handbookId;
getProcessForm({
definitionId: this.definitionId,
deployId: this.deployId,
procInsId: this.procInsId
}).then(res => {
if (res.data) {
this.formData = res.data;
this.formOpen = true
}
})
},
/** 接收子组件传的值 */
getData(data) {
if (data) {
const variables = [];
data.fields.forEach(item => {
let variableData = {};
variableData.label = item.__config__.label
//
if (item.__config__.defaultValue instanceof Array) {
const array = [];
item.__config__.defaultValue.forEach(val => {
array.push(val)
})
variableData.val = array;
} else {
variableData.val = item.__config__.defaultValue
}
variables.push(variableData)
})
this.variables = variables;
}
},
submit(data) {
if (data && this.definitionId) {
//
startProcess_(this.definitionId, JSON.stringify(data.valData)).then(res => {
let projectData = {};
projectData.handbookId = this.handbookId;
projectData.projectId = res.msg;
projectData.category = 1;
projectData.name = "测试项目";
projectData.createTime = "2024-07-14 23:28:17";
projectData.id = undefined;
console.log(projectData);
addProject(projectData).then(response => {
this.$modal.msgSuccess("申报完成");
})
this.$tab.closeOpenPage({
path: '/work/own'
})
})
}
}
}
}
</script>
<style lang="scss" scoped>
.form-conf {
margin: 15px auto;
width: 80%;
padding: 15px;
}
</style>

View File

@ -42,7 +42,12 @@ export default {
this.deployId = this.$route.params && this.$route.params.deployId; this.deployId = this.$route.params && this.$route.params.deployId;
this.definitionId = this.$route.query && this.$route.query.definitionId; this.definitionId = this.$route.query && this.$route.query.definitionId;
this.procInsId = this.$route.query && this.$route.query.procInsId; this.procInsId = this.$route.query && this.$route.query.procInsId;
this.processName = this.$route.query && this.$route.query.processName; if(this.$route.query && this.$route.query.processName) {
this.processName = this.$route.query && this.$route.query.processName;
}
else {
this.processName = "发起流程";
}
getProcessForm({ getProcessForm({
definitionId: this.definitionId, definitionId: this.definitionId,

44
scientific/pom.xml Normal file
View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ruoyi-flowable-plus</artifactId>
<groupId>com.ruoyi</groupId>
<version>0.8.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>scientific</artifactId>
<description>
scientific模块
</description>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-sms</artifactId>
</dependency>
<!-- 短信 用哪个导入哪个依赖 -->
<!-- <dependency>-->
<!-- <groupId>com.aliyun</groupId>-->
<!-- <artifactId>dysmsapi20170525</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.tencentcloudapi</groupId>-->
<!-- <artifactId>tencentcloud-sdk-java-sms</artifactId>-->
<!-- </dependency>-->
</dependencies>
</project>

View File

@ -0,0 +1,108 @@
package com.ruoyi.scientific.controller;
import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.scientific.domain.vo.ActProjectVo;
import com.ruoyi.scientific.domain.bo.ActProjectBo;
import com.ruoyi.scientific.service.IActProjectService;
import com.ruoyi.common.core.page.TableDataInfo;
/**
*
*
* @author zqjia
* @date 2024-07-14
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/scientific/project")
public class ActProjectController extends BaseController {
private final IActProjectService iActProjectService;
/**
*
*/
@SaCheckPermission("scientific:project:list")
@GetMapping("/list")
public TableDataInfo<ActProjectVo> list(ActProjectBo bo, PageQuery pageQuery) {
return iActProjectService.queryPageList(bo, pageQuery);
}
/**
*
*/
@SaCheckPermission("scientific:project:export")
@Log(title = "科研管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(ActProjectBo bo, HttpServletResponse response) {
List<ActProjectVo> list = iActProjectService.queryList(bo);
ExcelUtil.exportExcel(list, "科研管理", ActProjectVo.class, response);
}
/**
*
*
* @param id
*/
@SaCheckPermission("scientific:project:query")
@GetMapping("/{id}")
public R<ActProjectVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable String id) {
return R.ok(iActProjectService.queryById(id));
}
/**
*
*/
@SaCheckPermission("scientific:project:add")
@Log(title = "科研管理", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody ActProjectBo bo) {
return toAjax(iActProjectService.insertByBo(bo));
}
/**
*
*/
@SaCheckPermission("scientific:project:edit")
@Log(title = "科研管理", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ActProjectBo bo) {
return toAjax(iActProjectService.updateByBo(bo));
}
/**
*
*
* @param ids
*/
@SaCheckPermission("scientific:project:remove")
@Log(title = "科研管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable String[] ids) {
return toAjax(iActProjectService.deleteWithValidByIds(Arrays.asList(ids), true));
}
}

View File

@ -0,0 +1,49 @@
package com.ruoyi.scientific.domain;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* act_project
*
* @author zqjia
* @date 2024-07-14
*/
@Data
//@EqualsAndHashCode(callSuper = true)
@TableName("act_project")
public class ActProject implements Serializable {
private static final long serialVersionUID=1L;
/**
*
*/
@TableId(value = "id")
private String id;
/**
* id
*/
private String projectId;
/**
* id
*/
private String handbookId;
/**
*
*/
private Long category;
/**
*
*/
private String name;
private Date createTime;
}

View File

@ -0,0 +1,68 @@
package com.ruoyi.scientific.domain.bo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* act_project
*
* @author zqjia
* @date 2024-07-14
*/
@Data
//@EqualsAndHashCode(callSuper = true)
public class ActProjectBo implements Serializable {
/**
*
*/
@NotBlank(message = "不能为空", groups = { EditGroup.class })
private String id;
/**
* id
*/
@NotBlank(message = "项目id不能为空", groups = { AddGroup.class, EditGroup.class })
private String projectId;
/**
* id
*/
@NotBlank(message = "指南id不能为空", groups = { AddGroup.class, EditGroup.class })
private String handbookId;
/**
*
*/
@NotNull(message = "项目类别不能为空", groups = { AddGroup.class, EditGroup.class })
private Long category;
/**
*
*/
@NotBlank(message = "项目名称不能为空", groups = { AddGroup.class, EditGroup.class })
private String name;
@NotNull(message = "创建时间不能为空", groups = { AddGroup.class, EditGroup.class })
private Date createTime;
/**
*
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@TableField(exist = false)
private Map<String, Object> params = new HashMap<>();
}

View File

@ -0,0 +1,71 @@
package com.ruoyi.scientific.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.annotation.ExcelDictFormat;
import com.ruoyi.common.convert.ExcelDictConvert;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* act_project
*
* @author zqjia
* @date 2024-07-14
*/
@Data
@ExcelIgnoreUnannotated
public class ActProjectVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@ExcelProperty(value = "")
private String id;
/**
* id
*/
@ExcelProperty(value = "项目id")
private String projectId;
/**
* id
*/
@ExcelProperty(value = "指南id")
private String handbookId;
/**
*
*/
@ExcelProperty(value = "项目类别")
private Long category;
/**
*
*/
@ExcelProperty(value = "项目名称")
private String name;
/**
*
*/
@ExcelProperty(value = "项目创建时间")
private Date createTime;
/**
*
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@TableField(exist = false)
private Map<String, Object> params = new HashMap<>();
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.scientific.mapper;
import com.ruoyi.scientific.domain.ActProject;
import com.ruoyi.scientific.domain.vo.ActProjectVo;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
/**
* Mapper
*
* @author zqjia
* @date 2024-07-14
*/
public interface ActProjectMapper extends BaseMapperPlus<ActProjectMapper, ActProject, ActProjectVo> {
}

View File

@ -0,0 +1,49 @@
package com.ruoyi.scientific.service;
import com.ruoyi.scientific.domain.ActProject;
import com.ruoyi.scientific.domain.vo.ActProjectVo;
import com.ruoyi.scientific.domain.bo.ActProjectBo;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import java.util.Collection;
import java.util.List;
/**
* Service
*
* @author zqjia
* @date 2024-07-14
*/
public interface IActProjectService {
/**
*
*/
ActProjectVo queryById(String id);
/**
*
*/
TableDataInfo<ActProjectVo> queryPageList(ActProjectBo bo, PageQuery pageQuery);
/**
*
*/
List<ActProjectVo> queryList(ActProjectBo bo);
/**
*
*/
Boolean insertByBo(ActProjectBo bo);
/**
*
*/
Boolean updateByBo(ActProjectBo bo);
/**
*
*/
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
}

View File

@ -0,0 +1,113 @@
package com.ruoyi.scientific.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.ruoyi.scientific.domain.bo.ActProjectBo;
import com.ruoyi.scientific.domain.vo.ActProjectVo;
import com.ruoyi.scientific.domain.ActProject;
import com.ruoyi.scientific.mapper.ActProjectMapper;
import com.ruoyi.scientific.service.IActProjectService;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/**
* Service
*
* @author zqjia
* @date 2024-07-14
*/
@RequiredArgsConstructor
@Service
public class ActProjectServiceImpl implements IActProjectService {
private final ActProjectMapper baseMapper;
/**
*
*/
@Override
public ActProjectVo queryById(String id){
return baseMapper.selectVoById(id);
}
/**
*
*/
@Override
public TableDataInfo<ActProjectVo> queryPageList(ActProjectBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<ActProject> lqw = buildQueryWrapper(bo);
Page<ActProjectVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
*
*/
@Override
public List<ActProjectVo> queryList(ActProjectBo bo) {
LambdaQueryWrapper<ActProject> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<ActProject> buildQueryWrapper(ActProjectBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<ActProject> lqw = Wrappers.lambdaQuery();
lqw.eq(StringUtils.isNotBlank(bo.getProjectId()), ActProject::getProjectId, bo.getProjectId());
lqw.eq(StringUtils.isNotBlank(bo.getHandbookId()), ActProject::getHandbookId, bo.getHandbookId());
lqw.eq(bo.getCategory() != null, ActProject::getCategory, bo.getCategory());
lqw.like(StringUtils.isNotBlank(bo.getName()), ActProject::getName, bo.getName());
lqw.eq(bo.getCreateTime() != null, ActProject::getCreateTime, bo.getCreateTime());
return lqw;
}
/**
*
*/
@Override
public Boolean insertByBo(ActProjectBo bo) {
ActProject add = BeanUtil.toBean(bo, ActProject.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
}
/**
*
*/
@Override
public Boolean updateByBo(ActProjectBo bo) {
ActProject update = BeanUtil.toBean(bo, ActProject.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
*
*/
private void validEntityBeforeSave(ActProject entity){
//TODO 做一些数据校验,如唯一约束
}
/**
*
*/
@Override
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
}
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
java包使用 `.` 分割 resource 目录使用 `/` 分割
<br>
此文件目的 防止文件夹粘连找不到 `xml` 文件

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.scientific.mapper.ActProjectMapper">
<resultMap type="com.ruoyi.scientific.domain.ActProject" id="ActProjectResult">
<result property="id" column="id"/>
<result property="projectId" column="project_id"/>
<result property="handbookId" column="handbook_id"/>
<result property="category" column="category"/>
<result property="name" column="name"/>
<result property="createTime" column="create_time"/>
</resultMap>
</mapper>

File diff suppressed because one or more lines are too long