feat(example): 完善工艺流程管理功能

This commit is contained in:
zxy 2026-04-14 14:46:46 +08:00
parent 40be57b9fb
commit ba7f7b1de1
13 changed files with 177 additions and 50 deletions

View File

@ -120,12 +120,19 @@ public class ProLineServiceImpl extends ServiceImpl<ProLineMapper, ProLineEntity
@Override
@Transactional
public void saveOrUpdate(ProLineForm proLineForm, String id, boolean isSave) throws Exception {
if (isSave){
ProLineEntity entity = new ProLineEntity();
BeanUtils.copyProperties(proLineForm, entity);
entity.setId(null);
this.save(entity);
}else {
ProLineEntity entity = getInfo(id);
if (entity == null) {
entity = new ProLineEntity();
throw new Exception("数据不存在");
}
BeanUtils.copyProperties(proLineForm, entity);
this.saveOrUpdate(entity);
this.updateById(entity);
}
}
@Override

View File

@ -123,12 +123,20 @@ public class ProcServiceImpl extends ServiceImpl<ProcMapper, ProcEntity> impleme
@Override
@Transactional
public void saveOrUpdate(ProcForm procForm, String id, boolean isSave) throws Exception {
if (isSave) {
ProcEntity entity = new ProcEntity();
BeanUtils.copyProperties(procForm, entity);
entity.setId(null);
this.save(entity);
} else {
ProcEntity entity = getInfo(id);
if (entity == null) {
entity = new ProcEntity();
}
throw new Exception("数据不存在");
} else {
BeanUtils.copyProperties(procForm, entity);
this.saveOrUpdate(entity);
this.updateById(entity);
}
}
}
}

View File

@ -99,7 +99,7 @@ public class TechProcServiceImpl extends ServiceImpl<TechProcMapper, TechProcEnt
}
long count = this.count(wrapper);
if (count > 0) {
countRecover += "工艺流程已存在,请重新输入";
countRecover += "工艺流程已存在,请重新选择";
}
}

View File

@ -7,13 +7,13 @@ import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.model.machine.MachineEntity;
import jnpf.model.proc.ProcEntity;
import jnpf.model.proline.ProLineEntity;
import jnpf.model.machine.MachineForm;
import jnpf.model.machine.MachinePagination;
import jnpf.model.proline.ProLineEntity;
import jnpf.permission.service.UserService;
import jnpf.service.MachineService;
import jnpf.service.ProcService;
import jnpf.service.ProLineService;
import jnpf.service.ProcService;
import jnpf.util.JsonUtil;
import jnpf.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -39,8 +39,6 @@ public class MachineController {
@Autowired
private ProLineService proLineService;
@Autowired
private ProcService procService;
/**
* 列表
@ -141,20 +139,6 @@ public class MachineController {
return ActionResult.success(realList);
}
/**
* 获取工序列表
* @return 工序列表
*/
@Operation(summary = "获取工序列表")
@GetMapping("/getProcList")
public ActionResult getProcList() {
LambdaQueryWrapper<ProcEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ProcEntity::getEnabledStatus, 1);
List<ProcEntity> list = procService.list(wrapper);
List<Map<String, Object>> realList = list.stream()
.map(JsonUtil::entityToMap)
.collect(Collectors.toList());
return ActionResult.success(realList);
}
}

View File

@ -1,5 +1,6 @@
package jnpf.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;
@ -8,6 +9,8 @@ import jnpf.base.vo.PaginationVO;
import jnpf.model.proc.ProcEntity;
import jnpf.model.proc.ProcForm;
import jnpf.model.proc.ProcPagination;
import jnpf.permission.entity.UserEntity;
import jnpf.permission.service.UserService;
import jnpf.service.ProcService;
import jnpf.util.JsonUtil;
import jnpf.util.StringUtil;
@ -31,6 +34,9 @@ public class ProcController {
@Autowired
private ProcService procService;
@Autowired
private UserService userService;
/**
* 列表
* @param procPagination 分页查询对象
@ -114,4 +120,28 @@ public class ProcController {
}
}
/**
* 获取工序列表
* @return 工序列表
*/
@Operation(summary = "获取工序列表")
@GetMapping("/getProcList")
public ActionResult getProcList() {
LambdaQueryWrapper<ProcEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ProcEntity::getEnabledStatus, 1);
wrapper.orderByAsc(ProcEntity::getProcCd);
List<ProcEntity> list = procService.list(wrapper);
// 查询创建人
list.forEach(item -> {
UserEntity userEntity = userService.getById(item.getCreatorUserId());
if (userEntity != null) {
item.setCreateUserName(userEntity.getRealName());
}
});
List<Map<String, Object>> realList = list.stream()
.map(JsonUtil::entityToMap)
.collect(Collectors.toList());
return ActionResult.success(realList);
}
}

View File

@ -41,4 +41,7 @@ public class ProcEntity {
@TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED)
private String remark;
@TableField(exist = false)
private String createUserName;
}

View File

@ -46,6 +46,9 @@ public class TechProcEntity {
@TableField("tech_proc")
private String techProc;
@TableField(exist = false)
private String techProcName;
@TableField(value = "enabled_status", updateStrategy = FieldStrategy.IGNORED)
private Integer enabledStatus;

View File

@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* 工艺流程主数据 Form
@ -29,4 +30,6 @@ public class TechProcForm {
@Schema(description = "流程任务ID")
private String flowTaskId;
private List<String> procList;
}

View File

@ -9,14 +9,14 @@ export const customerMaps = {
enabledStatus: { '1': '启用', '2': '未启用' },
storeType: { '1': '原料库', '2': '在制品库', '3': '成品库' },
storeType: { 1: '原料库', 2: '在制品库', 3: '成品库' },
}
// 根据映射自动生成下拉选项
export const customerOptions = {}
for (const key in customerMaps) {
const map = customerMaps[key]
customerOptions[key] = Object.entries(map).map(([id, fullName]) => ({ id, fullName }))
customerOptions[key] = Object.entries(map).map(([id, fullName]) => ({ id: Number(id), fullName }))
}
// 获取显示名称

View File

@ -347,7 +347,7 @@ export default {
handleClose() {
this.dialogVisible = false;
this.$emit('refresh', false)
this.$emit('refresh', true)
},
}
}

View File

@ -190,7 +190,7 @@ export default {
//
getProcList() {
request({
url: `/api/example/machine/getProcList`,
url: `/api/example/proc/getProcList`,
method: 'get'
}).then(res => {
this.procList = res.data || [];

View File

@ -1,18 +1,18 @@
NEW_FILE_CODE
<template>
<el-dialog
:title="!dataForm.id ? '新建' : '编辑'"
:visible.sync="dialogVisible"
width="600px"
width="800px"
:close-on-click-modal="false"
@close="handleClose"
>
<el-form ref="formRef" :model="dataForm" :rules="dataRule" size="small" label-width="100px" label-position="right">
<template v-if="!loading">
<el-form-item label="工艺流程" prop="techProc">
<JnpfInput v-model="dataForm.techProc" placeholder="请输入工艺流程" clearable :style="{ width: '100%' }">
<JnpfInput v-model="techProcDisplay" placeholder="请选择工序生成工艺流程" clearable :style="{ width: '100%' }" :disabled="true">
</JnpfInput>
</el-form-item>
<input type="hidden" v-model="dataForm.techProc" />
<el-form-item label="状态" prop="enabledStatus">
<JnpfSelect v-model="dataForm.enabledStatus" placeholder="请选择状态" :options="enabledStatusOptions" :props="enabledStatusProps" clearable :style="{ width: '100%' }">
</JnpfSelect>
@ -21,10 +21,30 @@ NEW_FILE_CODE
<JnpfTextarea v-model="dataForm.remark" placeholder="请输入备注" :style="{ width: '100%' }" :autoSize="{ minRows: 4, maxRows: 4 }" type="textarea">
</JnpfTextarea>
</el-form-item>
<!-- 分割线 -->
<div style="border-top: 1px solid #e8e8e8; margin: 20px 0;"></div>
<!-- 工序列表 -->
<div style="padding: 0 10px;">
<div style="font-weight: bold; margin-bottom: 12px; color: #606266;">工序信息</div>
<el-table
:data="procList"
:border="true"
:style="{ width: '100%', maxHeight: '300px', overflow: 'auto' }"
@selection-change="handleProcSelectionChange">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column prop="procCd" label="工序编码" align="center"></el-table-column>
<el-table-column prop="procName" label="工序名称" align="center"></el-table-column>
<el-table-column prop="remark" label="备注" align="center"></el-table-column>
<el-table-column prop="createUserName" label="创建人" align="center"></el-table-column>
<el-table-column prop="creatorTime" label="创建时间" align="center" :formatter="jnpf.tableDateFormat1"></el-table-column>
</el-table>
</div>
</template>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading"> </el-button>
<el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading" :disabled="!hasSelectedProcs"> </el-button>
<el-button @click="handleClose"> </el-button>
</div>
</el-dialog>
@ -44,20 +64,16 @@ export default {
btnLoading: false,
formRef: 'formRef',
eventType: '',
techProcDisplay: '',
dataForm: {
id: '',
techProc: undefined,
enabledStatus: 1,
remark: undefined,
procList: []
},
dataRule: {
techProc: [
{
required: true,
message: '请输入工艺流程',
trigger: 'blur',
},
],
enabledStatus: [
{
required: true,
@ -71,10 +87,19 @@ export default {
{ fullName: "未启用", id: 2 },
],
enabledStatusProps: { label: "fullName", value: "id" },
procList: [],
selectedProcs: [],
}
},
computed: {
...mapGetters(['userInfo']),
//
hasSelectedProcs() {
return this.selectedProcs && this.selectedProcs.length > 0;
},
},
created() {
this.getProcList();
},
methods: {
init(id) {
@ -89,6 +114,8 @@ export default {
method: 'get'
}).then(res => {
this.dataForm = res.data
//
this.convertCodeToName(res.data.techProc)
this.loading = false
})
} else {
@ -96,6 +123,42 @@ export default {
}
});
},
//
getProcList() {
request({
url: `/api/example/proc/getProcList`,
method: 'get'
}).then(res => {
this.procList = res.data || [];
});
},
//
convertCodeToName(codeStr) {
if (!codeStr) {
this.techProcDisplay = ''
return
}
const codes = codeStr.split('_')
const names = codes.map(code => {
const proc = this.procList.find(item => item.procCd === code)
return proc ? proc.procName : code
})
this.techProcDisplay = names.join('_')
},
// -
handleProcSelectionChange(val) {
this.selectedProcs = val;
//
const selectedCodes = new Set(val.map(item => item.procCd));
//
const sortedSelected = this.procList.filter(item => selectedCodes.has(item.procCd));
//
this.techProcDisplay = sortedSelected.map(item => item.procName).join('_');
//
this.dataForm.techProc = sortedSelected.map(item => item.procCd).join('_');
//
this.dataForm.procList = sortedSelected.map(item => item.procCd);
},
dataFormSubmit() {
this.$refs.formRef.validate((valid) => {
if (valid) {

View File

@ -1,4 +1,3 @@
NEW_FILE_CODE
<template>
<div class="JNPF-common-layout techproc_data">
<div class="JNPF-common-layout-center">
@ -32,7 +31,11 @@ NEW_FILE_CODE
<div class="JNPF-common-head-right"></div>
</div>
<JNPF-table v-loading="listLoading" :data="list">
<el-table-column prop="techProc" label="工艺流程" align="center"/>
<el-table-column label="工艺流程" align="center">
<template slot-scope="scope">
{{ scope.row.techProcDisplay || scope.row.techProc }}
</template>
</el-table-column>
<el-table-column prop="enabledStatus" label="状态" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.enabledStatus == 1 ? 'success' : 'info'" size="small">
@ -94,6 +97,7 @@ export default {
{ fullName: "未启用", id: 2 },
],
enabledStatusProps: { label: "fullName", value: "id" },
procList: [],
};
},
computed: {
@ -106,9 +110,29 @@ export default {
},
},
created() {
this.getProcList();
this.initData();
},
methods: {
//
getProcList() {
request({
url: `/api/example/proc/getProcList`,
method: 'get'
}).then(res => {
this.procList = res.data || [];
});
},
//
convertCodeToName(codeStr) {
if (!codeStr) return '';
const codes = codeStr.split('_');
const names = codes.map(code => {
const proc = this.procList.find(item => item.procCd === code);
return proc ? proc.procName : code;
});
return names.join('_');
},
initData() {
this.listLoading = true;
let _query = {
@ -124,6 +148,8 @@ export default {
var _list = [];
for (let i = 0; i < res.data.list.length; i++) {
let _data = res.data.list[i];
//
_data.techProcDisplay = this.convertCodeToName(_data.techProc);
_list.push(_data);
}
this.list = _list;