feat(example): 新增机台、工序和产线管理功能

This commit is contained in:
zxy 2026-04-08 17:17:14 +08:00
parent 90f2b72822
commit 59c9c75298
27 changed files with 2523 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package jnpf.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jnpf.entity.MachineEntity;
/**
* 机台主数据 Mapper
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
public interface MachineMapper extends BaseMapper<MachineEntity> {
}

View File

@ -0,0 +1,16 @@
package jnpf.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jnpf.entity.ProLineEntity;
/**
* 产线主数据 Mapper
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
public interface ProLineMapper extends BaseMapper<ProLineEntity> {
}

View File

@ -0,0 +1,16 @@
package jnpf.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jnpf.entity.ProcEntity;
/**
* 工序主数据 Mapper
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
public interface ProcMapper extends BaseMapper<ProcEntity> {
}

View File

@ -0,0 +1,32 @@
package jnpf.service;
import com.baomidou.mybatisplus.extension.service.IService;
import jnpf.entity.MachineEntity;
import jnpf.model.machine.MachineForm;
import jnpf.model.machine.MachinePagination;
import java.util.List;
/**
* 机台主数据 Service
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
public interface MachineService extends IService<MachineEntity> {
List<MachineEntity> getList(MachinePagination machinePagination);
MachineEntity getInfo(String id);
void delete(MachineEntity entity);
void create(MachineEntity entity);
boolean update(String id, MachineEntity entity);
String checkForm(MachineForm form, int i);
void saveOrUpdate(MachineForm machineForm, String id, boolean isSave) throws Exception;
}

View File

@ -0,0 +1,32 @@
package jnpf.service;
import com.baomidou.mybatisplus.extension.service.IService;
import jnpf.entity.ProLineEntity;
import jnpf.model.proline.ProLineForm;
import jnpf.model.proline.ProLinePagination;
import java.util.List;
/**
* 产线主数据 Service
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
public interface ProLineService extends IService<ProLineEntity> {
List<ProLineEntity> getList(ProLinePagination proLinePagination);
ProLineEntity getInfo(String id);
void delete(ProLineEntity entity);
void create(ProLineEntity entity);
boolean update(String id, ProLineEntity entity);
String checkForm(ProLineForm form, int i);
void saveOrUpdate(ProLineForm proLineForm, String id, boolean isSave) throws Exception;
}

View File

@ -0,0 +1,32 @@
package jnpf.service;
import com.baomidou.mybatisplus.extension.service.IService;
import jnpf.entity.ProcEntity;
import jnpf.model.proc.ProcForm;
import jnpf.model.proc.ProcPagination;
import java.util.List;
/**
* 工序主数据 Service
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
public interface ProcService extends IService<ProcEntity> {
List<ProcEntity> getList(ProcPagination procPagination);
ProcEntity getInfo(String id);
void delete(ProcEntity entity);
void create(ProcEntity entity);
boolean update(String id, ProcEntity entity);
String checkForm(ProcForm form, int i);
void saveOrUpdate(ProcForm procForm, String id, boolean isSave) throws Exception;
}

View File

@ -0,0 +1,176 @@
package jnpf.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.base.UserInfo;
import jnpf.entity.MachineEntity;
import jnpf.entity.ProLineEntity;
import jnpf.entity.ProcEntity;
import jnpf.mapper.MachineMapper;
import jnpf.model.machine.MachineForm;
import jnpf.model.machine.MachinePagination;
import jnpf.service.MachineService;
import jnpf.service.ProLineService;
import jnpf.service.ProcService;
import jnpf.util.JsonUtil;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 机台主数据 ServiceImpl
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
@Service
public class MachineServiceImpl extends ServiceImpl<MachineMapper, MachineEntity> implements MachineService {
@Resource
private UserProvider userProvider;
@Resource
private ProLineService proLineService;
@Resource
private ProcService procService;
@Override
public List<MachineEntity> getList(MachinePagination machinePagination) {
LambdaQueryWrapper<MachineEntity> machineWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotEmpty(machinePagination.getMachineCd())) {
machineWrapper.like(MachineEntity::getMachineCd, machinePagination.getMachineCd());
}
if (ObjectUtil.isNotEmpty(machinePagination.getMachineName())) {
machineWrapper.like(MachineEntity::getMachineName, machinePagination.getMachineName());
}
if (ObjectUtil.isNotEmpty(machinePagination.getEnabledStatus())) {
machineWrapper.eq(MachineEntity::getEnabledStatus, machinePagination.getEnabledStatus());
}
if (ObjectUtil.isNotEmpty(machinePagination.getBelgLineId())) {
machineWrapper.eq(MachineEntity::getBelgLineId, machinePagination.getBelgLineId());
}
if (ObjectUtil.isNotEmpty(machinePagination.getBelgProcId())) {
machineWrapper.eq(MachineEntity::getBelgProcId, machinePagination.getBelgProcId());
}
// machineWrapper.isNull(MachineEntity::getDeleteMark);
machineWrapper.orderByDesc(MachineEntity::getCreatorTime);
if ("0".equals(machinePagination.getDataType())) {
Page<MachineEntity> page = new Page<>(machinePagination.getCurrentPage(), machinePagination.getPageSize());
IPage<MachineEntity> userIPage = this.page(page, machineWrapper);
List<MachineEntity> records = userIPage.getRecords();
// 获取所有产线和工序数据
List<ProLineEntity> proLineList = proLineService.list();
List<ProcEntity> procList = procService.list();
Map<Long, String> proLineMap = proLineList.stream()
.collect(Collectors.toMap(ProLineEntity::getId, ProLineEntity::getProLineName));
Map<Long, String> procMap = procList.stream()
.collect(Collectors.toMap(ProcEntity::getId, ProcEntity::getProcName));
// 设置产线和工序名称
for (MachineEntity machine : records) {
if (machine.getBelgLineId() != null) {
machine.setBelgLineName(proLineMap.get(machine.getBelgLineId()));
}
if (machine.getBelgProcId() != null) {
machine.setBelgProcName(procMap.get(machine.getBelgProcId()));
}
}
return machinePagination.setData(records, userIPage.getTotal());
} else {
return this.list(machineWrapper);
}
}
@Override
public MachineEntity getInfo(String id) {
QueryWrapper<MachineEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(MachineEntity::getId, id);
return this.getOne(queryWrapper);
}
@Override
public void create(MachineEntity entity) {
this.save(entity);
}
@Override
public boolean update(String id, MachineEntity entity) {
return this.updateById(entity);
}
@Override
public void delete(MachineEntity entity) {
if (entity != null) {
this.removeById(entity.getId());
}
}
/**
* 验证表单唯一字段正则非空 i-0新增-1修改
*/
@Override
public String checkForm(MachineForm form, int i) {
boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
String id = "";
String countRecover = "";
if (isUp) {
id = form.getId();
}
//主表字段验证
//机台编码唯一性验证
if (ObjectUtil.isNotEmpty(form.getMachineCd())) {
LambdaQueryWrapper<MachineEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MachineEntity::getMachineCd, form.getMachineCd());
if (isUp) {
wrapper.ne(MachineEntity::getId, id);
}
long count = this.count(wrapper);
if (count > 0) {
countRecover += "机台编码已存在,请重新输入!";
}
}
return countRecover;
}
/**
* 新增修改数据(事务回滚)
*
* @param id
* @param machineForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(MachineForm machineForm, String id, boolean isSave) throws Exception {
UserInfo userInfo = userProvider.get();
MachineEntity entity = JsonUtil.getJsonToBean(machineForm, MachineEntity.class);
if (!isSave) {
// 更新时设置ID
if (StringUtil.isNotEmpty(id)) {
entity.setId(Long.valueOf(id));
}
}
// 新增时ID由数据库自动生成不需要设置
this.saveOrUpdate(entity);
}
}

View File

@ -0,0 +1,136 @@
package jnpf.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.base.UserInfo;
import jnpf.entity.ProLineEntity;
import jnpf.mapper.ProLineMapper;
import jnpf.model.proline.ProLineForm;
import jnpf.model.proline.ProLinePagination;
import jnpf.service.ProLineService;
import jnpf.util.JsonUtil;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/**
* 产线主数据 ServiceImpl
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
@Service
public class ProLineServiceImpl extends ServiceImpl<ProLineMapper, ProLineEntity> implements ProLineService {
@Resource
private UserProvider userProvider;
@Override
public List<ProLineEntity> getList(ProLinePagination proLinePagination) {
LambdaQueryWrapper<ProLineEntity> proLineWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotEmpty(proLinePagination.getProLineCd())) {
proLineWrapper.like(ProLineEntity::getProLineCd, proLinePagination.getProLineCd());
}
if (ObjectUtil.isNotEmpty(proLinePagination.getProLineName())) {
proLineWrapper.like(ProLineEntity::getProLineName, proLinePagination.getProLineName());
}
if (ObjectUtil.isNotEmpty(proLinePagination.getEnabledStatus())) {
proLineWrapper.eq(ProLineEntity::getEnabledStatus, proLinePagination.getEnabledStatus());
}
proLineWrapper.orderByDesc(ProLineEntity::getCreatorTime);
if ("0".equals(proLinePagination.getDataType())) {
Page<ProLineEntity> page = new Page<>(proLinePagination.getCurrentPage(), proLinePagination.getPageSize());
IPage<ProLineEntity> userIPage = this.page(page, proLineWrapper);
return proLinePagination.setData(userIPage.getRecords(), userIPage.getTotal());
} else {
return this.list(proLineWrapper);
}
}
@Override
public ProLineEntity getInfo(String id) {
QueryWrapper<ProLineEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(ProLineEntity::getId, id);
return this.getOne(queryWrapper);
}
@Override
public void create(ProLineEntity entity) {
this.save(entity);
}
@Override
public boolean update(String id, ProLineEntity entity) {
return this.updateById(entity);
}
@Override
public void delete(ProLineEntity entity) {
if (entity != null) {
this.removeById(entity.getId());
}
}
/**
* 验证表单唯一字段正则非空 i-0新增-1修改
*/
@Override
public String checkForm(ProLineForm form, int i) {
boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
String id = "";
String countRecover = "";
if (isUp) {
id = form.getId();
}
//主表字段验证
//产线编码唯一性验证
if (ObjectUtil.isNotEmpty(form.getProLineCd())) {
LambdaQueryWrapper<ProLineEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ProLineEntity::getProLineCd, form.getProLineCd());
if (isUp) {
wrapper.ne(ProLineEntity::getId, id);
}
long count = this.count(wrapper);
if (count > 0) {
countRecover += "产线编码已存在,请重新输入!";
}
}
return countRecover;
}
/**
* 新增修改数据(事务回滚)
*
* @param id
* @param proLineForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(ProLineForm proLineForm, String id, boolean isSave) throws Exception {
UserInfo userInfo = userProvider.get();
ProLineEntity entity = JsonUtil.getJsonToBean(proLineForm, ProLineEntity.class);
if (!isSave) {
// 更新时设置ID
if (StringUtil.isNotEmpty(id)) {
entity.setId(Long.valueOf(id));
}
}
// 新增时ID由数据库自动生成不需要设置
this.saveOrUpdate(entity);
}
}

View File

@ -0,0 +1,139 @@
package jnpf.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.base.UserInfo;
import jnpf.entity.ProcEntity;
import jnpf.mapper.ProcMapper;
import jnpf.model.proc.ProcForm;
import jnpf.model.proc.ProcPagination;
import jnpf.service.ProcService;
import jnpf.util.GeneraterSwapUtil;
import jnpf.util.JsonUtil;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/**
* 工序主数据 ServiceImpl
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
@Service
public class ProcServiceImpl extends ServiceImpl<ProcMapper, ProcEntity> implements ProcService {
@Resource
private GeneraterSwapUtil generaterSwapUtil;
@Resource
private UserProvider userProvider;
@Override
public List<ProcEntity> getList(ProcPagination procPagination) {
LambdaQueryWrapper<ProcEntity> procWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotEmpty(procPagination.getProcCd())) {
procWrapper.like(ProcEntity::getProcCd, procPagination.getProcCd());
}
if (ObjectUtil.isNotEmpty(procPagination.getProcName())) {
procWrapper.like(ProcEntity::getProcName, procPagination.getProcName());
}
if (ObjectUtil.isNotEmpty(procPagination.getEnabledStatus())) {
procWrapper.eq(ProcEntity::getEnabledStatus, procPagination.getEnabledStatus());
}
procWrapper.orderByDesc(ProcEntity::getCreatorTime);
if ("0".equals(procPagination.getDataType())) {
Page<ProcEntity> page = new Page<>(procPagination.getCurrentPage(), procPagination.getPageSize());
IPage<ProcEntity> userIPage = this.page(page, procWrapper);
return procPagination.setData(userIPage.getRecords(), userIPage.getTotal());
} else {
return this.list(procWrapper);
}
}
@Override
public ProcEntity getInfo(String id) {
QueryWrapper<ProcEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(ProcEntity::getId, id);
return this.getOne(queryWrapper);
}
@Override
public void create(ProcEntity entity) {
this.save(entity);
}
@Override
public boolean update(String id, ProcEntity entity) {
return this.updateById(entity);
}
@Override
public void delete(ProcEntity entity) {
if (entity != null) {
this.removeById(entity.getId());
}
}
/**
* 验证表单唯一字段正则非空 i-0新增-1修改
*/
@Override
public String checkForm(ProcForm form, int i) {
boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
String id = "";
String countRecover = "";
if (isUp) {
id = form.getId();
}
//主表字段验证
//工序编码唯一性验证
if (ObjectUtil.isNotEmpty(form.getProcCd())) {
LambdaQueryWrapper<ProcEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ProcEntity::getProcCd, form.getProcCd());
if (isUp) {
wrapper.ne(ProcEntity::getId, id);
}
long count = this.count(wrapper);
if (count > 0) {
countRecover += "工序编码已存在,请重新输入!";
}
}
return countRecover;
}
/**
* 新增修改数据(事务回滚)
*
* @param id
* @param procForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(ProcForm procForm, String id, boolean isSave) throws Exception {
UserInfo userInfo = userProvider.get();
ProcEntity entity = JsonUtil.getJsonToBean(procForm, ProcEntity.class);
if (!isSave) {
// 更新时设置ID
if (StringUtil.isNotEmpty(id)) {
entity.setId(Long.valueOf(id));
}
}
// 新增时ID由数据库自动生成不需要设置
this.saveOrUpdate(entity);
}
}

View File

@ -0,0 +1,160 @@
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;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.entity.MachineEntity;
import jnpf.entity.ProcEntity;
import jnpf.entity.ProLineEntity;
import jnpf.model.machine.MachineForm;
import jnpf.model.machine.MachinePagination;
import jnpf.service.MachineService;
import jnpf.service.ProcService;
import jnpf.service.ProLineService;
import jnpf.util.JsonUtil;
import jnpf.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 机台主数据 控制类
*
*/
@Tag(name = "机台主数据", description = "Machine")
@RestController
@RequestMapping("/api/example/machine")
public class MachineController {
@Autowired
private MachineService machineService;
@Autowired
private ProLineService proLineService;
@Autowired
private ProcService procService;
/**
* 列表
* @param machinePagination 分页查询对象
* @return 列表结果集
*/
@Operation(summary = "获取机台列表")
@PostMapping("/getList")
public ActionResult getList(@RequestBody MachinePagination machinePagination) {
List<MachineEntity> list = machineService.getList(machinePagination);
List<Map<String, Object>> realList = list.stream()
.map(JsonUtil::entityToMap)
.collect(Collectors.toList());
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(machinePagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 详情
* @param id 主键
* @return 详情结果集
*/
@Operation(summary = "获取机台详情")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id) {
MachineEntity entity = machineService.getInfo(id);
if (entity != null) {
return ActionResult.success(JsonUtil.entityToMap(entity));
}
return ActionResult.fail("数据不存在");
}
/**
* 新建
* @param machineForm 表单对象
* @return 新建结果
*/
@Operation(summary = "新建机台")
@PostMapping
public ActionResult create(@RequestBody @Valid MachineForm machineForm) {
String b = machineService.checkForm(machineForm, 0);
if (StringUtil.isNotEmpty(b)) {
return ActionResult.fail(b);
}
try {
machineService.saveOrUpdate(machineForm, "", true);
return ActionResult.success("新建成功");
} catch (Exception e) {
return ActionResult.fail("新建数据失败:" + e.getMessage());
}
}
/**
* 编辑
* @param id 主键
* @param machineForm 表单对象
* @return 编辑结果
*/
@Operation(summary = "更新机台")
@PutMapping("/{id}")
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid MachineForm machineForm) {
machineForm.setId(id);
String b = machineService.checkForm(machineForm, 1);
if (StringUtil.isNotEmpty(b)) {
return ActionResult.fail(b);
}
MachineEntity entity = machineService.getInfo(id);
if (entity != null) {
try {
machineService.saveOrUpdate(machineForm, id, false);
return ActionResult.success("更新成功");
} catch (Exception e) {
return ActionResult.fail("更新数据失败:" + e.getMessage());
}
} else {
return ActionResult.fail("更新失败,数据不存在");
}
}
/**
* 获取产线下拉列表
* @return 产线列表
*/
@Operation(summary = "获取产线下拉列表")
@GetMapping("/getProLineList")
public ActionResult getProLineList() {
LambdaQueryWrapper<ProLineEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ProLineEntity::getEnabledStatus, 1);
List<ProLineEntity> list = proLineService.list(wrapper);
List<Map<String, Object>> realList = list.stream()
.map(JsonUtil::entityToMap)
.collect(Collectors.toList());
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

@ -0,0 +1,120 @@
package jnpf.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.entity.ProLineEntity;
import jnpf.model.proline.ProLineForm;
import jnpf.model.proline.ProLinePagination;
import jnpf.service.ProLineService;
import jnpf.util.JsonUtil;
import jnpf.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 产线主数据 控制类
*/
@Tag(name = "产线主数据", description = "ProLine")
@RestController
@RequestMapping("/api/example/proLine")
public class ProLineController {
@Autowired
private ProLineService proLineService;
/**
* 列表
*
* @param proLinePagination 分页查询对象
* @return 列表结果集
*/
@Operation(summary = "获取产线列表")
@PostMapping("/getList")
public ActionResult getList(@RequestBody ProLinePagination proLinePagination) {
List<ProLineEntity> list = proLineService.getList(proLinePagination);
List<Map<String, Object>> realList = list.stream()
.map(JsonUtil::entityToMap)
.collect(Collectors.toList());
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(proLinePagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 详情
*
* @param id 主键
* @return 详情结果集
*/
@Operation(summary = "获取产线详情")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id) {
ProLineEntity entity = proLineService.getInfo(id);
if (entity != null) {
return ActionResult.success(JsonUtil.entityToMap(entity));
}
return ActionResult.fail("数据不存在");
}
/**
* 新建
*
* @param proLineForm 表单对象
* @return 新建结果
*/
@Operation(summary = "新建产线")
@PostMapping
public ActionResult create(@RequestBody @Valid ProLineForm proLineForm) {
String b = proLineService.checkForm(proLineForm, 0);
if (StringUtil.isNotEmpty(b)) {
return ActionResult.fail(b);
}
try {
proLineService.saveOrUpdate(proLineForm, "", true);
return ActionResult.success("新建成功");
} catch (Exception e) {
return ActionResult.fail("新建数据失败:" + e.getMessage());
}
}
/**
* 编辑
*
* @param id 主键
* @param proLineForm 表单对象
* @return 编辑结果
*/
@Operation(summary = "更新产线")
@PutMapping("/{id}")
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid ProLineForm proLineForm) {
proLineForm.setId(id);
String b = proLineService.checkForm(proLineForm, 1);
if (StringUtil.isNotEmpty(b)) {
return ActionResult.fail(b);
}
ProLineEntity entity = proLineService.getInfo(id);
if (entity != null) {
try {
proLineService.saveOrUpdate(proLineForm, id, false);
return ActionResult.success("更新成功");
} catch (Exception e) {
return ActionResult.fail("更新数据失败:" + e.getMessage());
}
} else {
return ActionResult.fail("更新失败,数据不存在");
}
}
}

View File

@ -0,0 +1,117 @@
package jnpf.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.entity.ProcEntity;
import jnpf.model.proc.ProcForm;
import jnpf.model.proc.ProcPagination;
import jnpf.service.ProcService;
import jnpf.util.JsonUtil;
import jnpf.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 工序主数据 控制类
*
*/
@Tag(name = "工序主数据", description = "Proc")
@RestController
@RequestMapping("/api/example/proc")
public class ProcController {
@Autowired
private ProcService procService;
/**
* 列表
* @param procPagination 分页查询对象
* @return 列表结果集
*/
@Operation(summary = "获取工序列表")
@PostMapping("/getList")
public ActionResult getList(@RequestBody ProcPagination procPagination) {
List<ProcEntity> list = procService.getList(procPagination);
List<Map<String, Object>> realList = list.stream()
.map(JsonUtil::entityToMap)
.collect(Collectors.toList());
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(procPagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
* 详情
* @param id 主键
* @return 详情结果集
*/
@Operation(summary = "获取工序详情")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id) {
ProcEntity entity = procService.getInfo(id);
if (entity != null) {
return ActionResult.success(JsonUtil.entityToMap(entity));
}
return ActionResult.fail("数据不存在");
}
/**
* 新建
* @param procForm 表单对象
* @return 新建结果
*/
@Operation(summary = "新建工序")
@PostMapping
public ActionResult create(@RequestBody @Valid ProcForm procForm) {
String b = procService.checkForm(procForm, 0);
if (StringUtil.isNotEmpty(b)) {
return ActionResult.fail(b);
}
try {
procService.saveOrUpdate(procForm, "", true);
return ActionResult.success("新建成功");
} catch (Exception e) {
return ActionResult.fail("新建数据失败:" + e.getMessage());
}
}
/**
* 编辑
* @param id 主键
* @param procForm 表单对象
* @return 编辑结果
*/
@Operation(summary = "更新工序")
@PutMapping("/{id}")
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid ProcForm procForm) {
procForm.setId(id);
String b = procService.checkForm(procForm, 1);
if (StringUtil.isNotEmpty(b)) {
return ActionResult.fail(b);
}
ProcEntity entity = procService.getInfo(id);
if (entity != null) {
try {
procService.saveOrUpdate(procForm, id, false);
return ActionResult.success("更新成功");
} catch (Exception e) {
return ActionResult.fail("更新数据失败:" + e.getMessage());
}
} else {
return ActionResult.fail("更新失败,数据不存在");
}
}
}

View File

@ -0,0 +1,54 @@
package jnpf.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
/**
* 机台主数据表
*
*/
@Data
@TableName("tba_machine")
public class MachineEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@TableField(value = "f_creator_user_id", fill = FieldFill.INSERT)
private String creatorUserId;
@TableField(value = "f_creator_time", fill = FieldFill.INSERT)
private Date creatorTime;
@TableField(value = "f_last_modify_user_id", fill = FieldFill.INSERT_UPDATE)
private String lastModifyUserId;
@TableField(value = "f_last_modify_time", fill = FieldFill.INSERT_UPDATE)
private Date lastModifyTime;
@TableField(value = "f_delete_user_id", fill = FieldFill.UPDATE)
private String deleteUserId;
@TableField(value = "f_delete_time", fill = FieldFill.UPDATE)
private Date deleteTime;
@TableField(value = "f_delete_mark", updateStrategy = FieldStrategy.IGNORED)
private Integer deleteMark;
@TableField(value = "f_flow_id")
private String flowId;
@TableField(value = "f_flow_task_id")
private String flowTaskId;
@TableField("machine_cd")
private String machineCd;
@TableField("machine_name")
private String machineName;
@TableField(value = "enabled_status", updateStrategy = FieldStrategy.IGNORED)
private Integer enabledStatus;
@TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED)
private String remark;
@TableField(value = "belg_line_id", updateStrategy = FieldStrategy.IGNORED)
private Long belgLineId;
@TableField(value = "belg_proc_id", updateStrategy = FieldStrategy.IGNORED)
private Long belgProcId;
@TableField(exist = false)
private String belgLineName;
@TableField(exist = false)
private String belgProcName;
}

View File

@ -0,0 +1,44 @@
package jnpf.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
/**
* 产线主数据表
*
*/
@Data
@TableName("tba_pro_line")
public class ProLineEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@TableField(value = "f_creator_user_id", fill = FieldFill.INSERT)
private String creatorUserId;
@TableField(value = "f_creator_time", fill = FieldFill.INSERT)
private Date creatorTime;
@TableField(value = "f_last_modify_user_id", fill = FieldFill.INSERT_UPDATE)
private String lastModifyUserId;
@TableField(value = "f_last_modify_time", fill = FieldFill.INSERT_UPDATE)
private Date lastModifyTime;
@TableField(value = "f_delete_user_id", fill = FieldFill.UPDATE)
private String deleteUserId;
@TableField(value = "f_delete_time", fill = FieldFill.UPDATE)
private Date deleteTime;
@TableField(value = "f_delete_mark", updateStrategy = FieldStrategy.IGNORED)
private Integer deleteMark;
@TableField(value = "f_flow_id")
private String flowId;
@TableField(value = "f_flow_task_id")
private String flowTaskId;
@TableField("pro_line_cd")
private String proLineCd;
@TableField("pro_line_name")
private String proLineName;
@TableField(value = "enabled_status", updateStrategy = FieldStrategy.IGNORED)
private Integer enabledStatus;
@TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED)
private String remark;
}

View File

@ -0,0 +1,44 @@
package jnpf.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
/**
* 工序主数据表
*
*/
@Data
@TableName("tba_proc")
public class ProcEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@TableField(value = "f_creator_user_id", fill = FieldFill.INSERT)
private String creatorUserId;
@TableField(value = "f_creator_time", fill = FieldFill.INSERT)
private Date creatorTime;
@TableField(value = "f_last_modify_user_id", fill = FieldFill.INSERT_UPDATE)
private String lastModifyUserId;
@TableField(value = "f_last_modify_time", fill = FieldFill.INSERT_UPDATE)
private Date lastModifyTime;
@TableField(value = "f_delete_user_id", fill = FieldFill.UPDATE)
private String deleteUserId;
@TableField(value = "f_delete_time", fill = FieldFill.UPDATE)
private Date deleteTime;
@TableField(value = "f_delete_mark", updateStrategy = FieldStrategy.IGNORED)
private Integer deleteMark;
@TableField(value = "f_flow_id")
private String flowId;
@TableField(value = "f_flow_task_id")
private String flowTaskId;
@TableField("proc_cd")
private String procCd;
@TableField("proc_name")
private String procName;
@TableField(value = "enabled_status", updateStrategy = FieldStrategy.IGNORED)
private Integer enabledStatus;
@TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED)
private String remark;
}

View File

@ -0,0 +1,67 @@
package jnpf.model.machine;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Date;
/**
* 机台主数据 Form
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
@Data
public class MachineForm {
@Schema(description = "主键")
private String id;
@Schema(description = "机台编码")
private String machineCd;
@Schema(description = "机台名称")
private String machineName;
@Schema(description = "状态(1启用 2 未启用)")
private Integer enabledStatus;
@Schema(description = "备注")
private String remark;
@Schema(description = "创建时间")
private Date creatorTime;
@Schema(description = "创建用户ID")
private String creatorUserId;
@Schema(description = "最后修改时间")
private Date lastModifyTime;
@Schema(description = "最后修改用户ID")
private String lastModifyUserId;
@Schema(description = "删除时间")
private Date deleteTime;
@Schema(description = "删除用户ID")
private String deleteUserId;
@Schema(description = "删除标记")
private Integer deleteMark;
@Schema(description = "流程ID")
private String flowId;
@Schema(description = "流程任务ID")
private String flowTaskId;
@Schema(description = "所属产线id")
private Long belgLineId;
@Schema(description = "所属工序id")
private Long belgProcId;
}

View File

@ -0,0 +1,45 @@
package jnpf.model.machine;
import jnpf.base.Pagination;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 机台主数据分页查询
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
@Data
public class MachinePagination extends Pagination {
/** 查询key */
private String[] selectKey;
/** json */
private String json;
/** 数据类型 0-当前页1-全部数据 */
private String dataType;
/** 高级查询 */
private String superQueryJson;
/** 功能id */
private String moduleId;
/** 菜单id */
private String menuId;
@Schema(description = "机台编码")
private String machineCd;
@Schema(description = "机台名称")
private String machineName;
@Schema(description = "状态(1启用 2 未启用)")
private Integer enabledStatus;
@Schema(description = "所属产线id")
private Long belgLineId;
@Schema(description = "所属工序id")
private Long belgProcId;
}

View File

@ -0,0 +1,38 @@
package jnpf.model.proc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 工序主数据 Form
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
@Data
public class ProcForm {
@Schema(description = "主键")
private String id;
@Schema(description = "工序编码")
private String procCd;
@Schema(description = "工序名称")
private String procName;
@Schema(description = "状态(1启用 2 未启用)")
private Integer enabledStatus;
@Schema(description = "备注")
private String remark;
@Schema(description = "流程ID")
private String flowId;
@Schema(description = "流程任务ID")
private String flowTaskId;
}

View File

@ -0,0 +1,39 @@
package jnpf.model.proc;
import jnpf.base.Pagination;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 工序主数据分页查询
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
@Data
public class ProcPagination extends Pagination {
/** 查询key */
private String[] selectKey;
/** json */
private String json;
/** 数据类型 0-当前页1-全部数据 */
private String dataType;
/** 高级查询 */
private String superQueryJson;
/** 功能id */
private String moduleId;
/** 菜单id */
private String menuId;
@Schema(description = "工序编码")
private String procCd;
@Schema(description = "工序名称")
private String procName;
@Schema(description = "状态(1启用 2 未启用)")
private Integer enabledStatus;
}

View File

@ -0,0 +1,61 @@
package jnpf.model.proline;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Date;
/**
* 产线主数据 Form
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
@Data
public class ProLineForm {
@Schema(description = "主键")
private String id;
@Schema(description = "产线编码")
private String proLineCd;
@Schema(description = "产线名称")
private String proLineName;
@Schema(description = "状态(1启用 2 未启用)")
private Integer enabledStatus;
@Schema(description = "备注")
private String remark;
@Schema(description = "创建时间")
private Date creatorTime;
@Schema(description = "创建用户ID")
private String creatorUserId;
@Schema(description = "最后修改时间")
private Date lastModifyTime;
@Schema(description = "最后修改用户ID")
private String lastModifyUserId;
@Schema(description = "删除时间")
private Date deleteTime;
@Schema(description = "删除用户ID")
private String deleteUserId;
@Schema(description = "删除标记")
private Integer deleteMark;
@Schema(description = "流程ID")
private String flowId;
@Schema(description = "流程任务ID")
private String flowTaskId;
}

View File

@ -0,0 +1,39 @@
package jnpf.model.proline;
import jnpf.base.Pagination;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 产线主数据分页查询
*
* @版本 V3.5
* @版权 引迈信息技术有限公司https://www.jnpfsoft.com
* @作者 JNPF开发平台组
* @日期 2024-02-04
*/
@Data
public class ProLinePagination extends Pagination {
/** 查询key */
private String[] selectKey;
/** json */
private String json;
/** 数据类型 0-当前页1-全部数据 */
private String dataType;
/** 高级查询 */
private String superQueryJson;
/** 功能id */
private String moduleId;
/** 菜单id */
private String menuId;
@Schema(description = "产线编码")
private String proLineCd;
@Schema(description = "产线名称")
private String proLineName;
@Schema(description = "状态(1启用 2 未启用)")
private Integer enabledStatus;
}

View File

@ -0,0 +1,210 @@
<template>
<transition name="el-zoom-in-center">
<div class="JNPF-preview-main">
<div class="JNPF-common-page-header">
<el-page-header @back="goBack" :content="!dataForm.id ? '新建' : '编辑'" />
<div class="options">
<el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading"> </el-button>
<el-button @click="goBack"> </el-button>
</div>
</div>
<el-row :gutter="15" class="main" :style="{ margin: '0 auto', width: '100%' }">
<el-form ref="formRef" :model="dataForm" :rules="dataRule" size="small" label-width="100px"
label-position="right">
<template v-if="!loading">
<el-col :span="12" :sm="24" :md="12" :xl="12" :xs="24">
<jnpf-form-tip-item label="机台编码" prop="machineCd">
<JnpfInput v-model="dataForm.machineCd" @change="changeData('machineCd', -1)" placeholder="请输入机台编码"
clearable :disabled="!!dataForm.id" :style="{ width: '100%' }">
</JnpfInput>
</jnpf-form-tip-item>
</el-col>
<el-col :span="12" :sm="24" :md="12" :xl="12" :xs="24">
<jnpf-form-tip-item label="机台名称" prop="machineName">
<JnpfInput v-model="dataForm.machineName" @change="changeData('machineName', -1)" placeholder="请输入机台名称"
clearable :style="{ width: '100%' }">
</JnpfInput>
</jnpf-form-tip-item>
</el-col>
<el-col :span="12" :sm="24" :md="12" :xl="12" :xs="24">
<jnpf-form-tip-item label="所属产线" prop="belgLineId">
<el-select v-model="dataForm.belgLineId" placeholder="请选择产线" clearable :style="{ width: '100%' }">
<el-option
v-for="item in proLineList"
:key="item.id"
:label="item.proLineName"
:value="item.id">
</el-option>
</el-select>
</jnpf-form-tip-item>
</el-col>
<el-col :span="12" :sm="24" :md="12" :xl="12" :xs="24">
<jnpf-form-tip-item label="所属工序" prop="belgProcId">
<el-select v-model="dataForm.belgProcId" placeholder="请选择工序" clearable :style="{ width: '100%' }">
<el-option
v-for="item in procList"
:key="item.id"
:label="item.procName"
:value="item.id">
</el-option>
</el-select>
</jnpf-form-tip-item>
</el-col>
<el-col :span="12" :sm="24" :md="12" :xl="12" :xs="24">
<jnpf-form-tip-item label="状态" prop="enabledStatus">
<JnpfSelect v-model="dataForm.enabledStatus" @change="changeData('enabledStatus', -1)"
placeholder="请选择状态" :options="enabledStatusOptions" :props="enabledStatusProps" clearable
:style="{ width: '100%' }">
</JnpfSelect>
</jnpf-form-tip-item>
</el-col>
<el-col :span="24" :sm="24" :md="24" :xl="24" :xs="24">
<jnpf-form-tip-item label="备注" prop="remark">
<JnpfTextarea v-model="dataForm.remark" @change="changeData('remark', -1)" placeholder="请输入备注"
:style="{ width: '100%' }" :autoSize="{ minRows: 4, maxRows: 4 }" type="textarea">
</JnpfTextarea>
</jnpf-form-tip-item>
</el-col>
</template>
</el-form>
</el-row>
</div>
</transition>
</template>
<script>
import request from '@/utils/request'
import { mapGetters } from 'vuex'
export default {
components: {},
props: {
proLineList: {
type: Array,
default: () => []
},
procList: {
type: Array,
default: () => []
}
},
data() {
return {
visible: false,
loading: false,
btnLoading: false,
formRef: 'formRef',
eventType: '',
dataForm: {
id: '',
machineCd: undefined,
machineName: undefined,
belgLineId: undefined,
belgProcId: undefined,
enabledStatus: 1,
remark: undefined,
},
dataRule: {
machineCd: [
{
required: true,
message: '请输入机台编码',
trigger: 'blur',
},
],
machineName: [
{
required: true,
message: '请输入机台名称',
trigger: 'blur',
},
],
belgLineId: [
{
required: true,
message: '请选择所属产线',
trigger: 'change',
},
],
belgProcId: [
{
required: true,
message: '请选择所属工序',
trigger: 'change',
},
],
enabledStatus: [
{
required: true,
message: '请选择状态',
trigger: 'change',
},
],
},
enabledStatusOptions: [
{ fullName: "启用", id: 1 },
{ fullName: "未启用", id: 2 },
],
enabledStatusProps: { label: "fullName", value: "id" },
}
},
computed: {
...mapGetters(['userInfo']),
},
methods: {
init(id) {
this.dataForm.id = id || '';
this.visible = true;
this.loading = true;
this.$nextTick(() => {
this.$refs.formRef.resetFields();
if (this.dataForm.id) {
request({
url: `/api/example/machine/${this.dataForm.id}`,
method: 'get'
}).then(res => {
this.dataForm = res.data
this.loading = false
})
} else {
this.loading = false
}
});
},
dataFormSubmit() {
this.$refs.formRef.validate((valid) => {
if (valid) {
this.btnLoading = true;
const isEdit = !!this.dataForm.id;
const url = isEdit ? `/api/example/machine/${this.dataForm.id}` : '/api/example/machine';
const method = isEdit ? 'put' : 'post';
request({
url: url,
method: method,
data: this.dataForm
}).then(res => {
this.$message({
message: res.msg,
type: 'success',
duration: 1500,
onClose: () => {
this.btnLoading = false;
this.$emit('refresh', true)
}
})
}).catch(() => {
this.btnLoading = false
})
}
})
},
goBack() {
this.$emit('refresh')
},
changeData(model, index) {
this.isEdit = true
}
}
}
</script>

View File

@ -0,0 +1,227 @@
<template>
<div class="JNPF-common-layout machine_data">
<div class="JNPF-common-layout-center">
<el-row class="JNPF-common-search-box" :gutter="14">
<el-form @submit.native.prevent>
<!-- <el-col :span="6">-->
<!-- <el-form-item label="机台编码">-->
<!-- <el-input v-model="query.machineCd" placeholder="请输入" clearable></el-input>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col :span="6">-->
<!-- <el-form-item label="机台名称">-->
<!-- <el-input v-model="query.machineName" placeholder="请输入" clearable></el-input>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col :span="6">-->
<!-- <el-form-item label="所属产线">-->
<!-- <el-select v-model="query.belgLineId" placeholder="请选择" clearable>-->
<!-- <el-option-->
<!-- v-for="item in proLineList"-->
<!-- :key="item.id"-->
<!-- :label="item.proLineName"-->
<!-- :value="item.id">-->
<!-- </el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col :span="6">-->
<!-- <el-form-item label="所属工序">-->
<!-- <el-select v-model="query.belgProcId" placeholder="请选择" clearable>-->
<!-- <el-option-->
<!-- v-for="item in procList"-->
<!-- :key="item.id"-->
<!-- :label="item.procName"-->
<!-- :value="item.id">-->
<!-- </el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<el-col :span="6">
<el-form-item label="状态">
<JnpfSelect v-model="query.enabledStatus" placeholder="请选择" clearable :options="enabledStatusOptions"
:props="enabledStatusProps">
</JnpfSelect>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item class="btn">
<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<div class="JNPF-common-layout-main JNPF-flex-main">
<div class="JNPF-common-head">
<div>
<el-button type="primary" icon="icon-ym icon-ym-btn-add" @click="addOrUpdateHandle()">新建</el-button>
</div>
<div class="JNPF-common-head-right"></div>
</div>
<JNPF-table v-loading="listLoading" :data="list">
<el-table-column prop="machineCd" label="机台编码" align="center"/>
<el-table-column prop="machineName" label="机台名称" align="center"/>
<el-table-column prop="belgLineName" label="所属产线" align="center"/>
<el-table-column prop="belgProcName" label="所属工序" align="center"/>
<el-table-column prop="enabledStatus" label="状态" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.enabledStatus == 1 ? 'success' : 'info'" size="small">
{{ scope.row.enabledStatus == 1 ? '启用' : scope.row.enabledStatus == 2 ? '未启用' : scope.row.enabledStatus }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" align="center"/>
<el-table-column prop="creatorTime" label="创建时间" align="center" :formatter="jnpf.tableDateFormat1"/>
<el-table-column label="操作" fixed="right" align="center" width="100">
<template slot-scope="scope">
<el-button type="text" @click="addOrUpdateHandle(scope.row)">编辑</el-button>
</template>
</el-table-column>
</JNPF-table>
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize"
@pagination="initData" />
</div>
</div>
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" :proLineList="proLineList" :procList="procList" />
</div>
</template>
<script>
import request from "@/utils/request";
import { mapGetters } from "vuex";
import JNPFForm from "./form";
import jnpf from "@/utils/jnpf";
export default {
name: "machine_list",
components: {
JNPFForm,
},
data() {
return {
keyword: "",
query: {
machineCd: undefined,
machineName: undefined,
belgLineId: undefined,
belgProcId: undefined,
enabledStatus: undefined,
},
defListQuery: {
sort: "desc",
sidx: "",
},
list: [],
listLoading: false,
multipleSelection: [],
total: 0,
listQuery: {
currentPage: 1,
pageSize: 20,
sort: "",
sidx: "",
},
formVisible: false,
proLineList: [],
procList: [],
enabledStatusOptions: [
{ fullName: "启用", id: 1 },
{ fullName: "未启用", id: 2 },
],
enabledStatusProps: { label: "fullName", value: "id" },
};
},
computed: {
jnpf() {
return jnpf
},
...mapGetters(["userInfo"]),
menuId() {
return this.$route.meta.modelId || "";
},
},
created() {
this.initData();
this.getProLineList();
this.getProcList();
},
methods: {
initData() {
this.listLoading = true;
let _query = {
...this.listQuery,
...this.query,
dataType: 0,
};
//
Object.keys(_query).forEach(key => {
if (_query[key] === undefined || _query[key] === null || _query[key] === '') {
delete _query[key];
}
});
console.log('查询参数:', _query); //
request({
url: `/api/example/machine/getList`,
method: "post",
data: _query,
}).then((res) => {
var _list = [];
for (let i = 0; i < res.data.list.length; i++) {
let _data = res.data.list[i];
_list.push(_data);
}
this.list = _list;
this.total = res.data.pagination.total;
this.listLoading = false;
});
},
// 线
getProLineList() {
request({
url: `/api/example/machine/getProLineList`,
method: 'get'
}).then(res => {
this.proLineList = res.data || [];
});
},
//
getProcList() {
request({
url: `/api/example/machine/getProcList`,
method: 'get'
}).then(res => {
this.procList = res.data || [];
});
},
addOrUpdateHandle(row) {
let id = row ? row.id : "";
this.formVisible = true;
this.$nextTick(() => {
this.$refs.JNPFForm.init(id);
});
},
search() {
this.listQuery.currentPage = 1;
this.listQuery.pageSize = 20;
this.initData();
},
refresh(isrRefresh) {
this.formVisible = false;
if (isrRefresh) this.search();
},
reset() {
this.query = {
machineCd: undefined,
machineName: undefined,
belgLineId: undefined,
belgProcId: undefined,
enabledStatus: undefined,
};
this.search();
},
},
};
</script>

View File

@ -0,0 +1,161 @@
<template>
<transition name="el-zoom-in-center">
<div class="JNPF-preview-main">
<div class="JNPF-common-page-header">
<el-page-header @back="goBack" :content="!dataForm.id ? '新建' : '编辑'" />
<div class="options">
<el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading"> </el-button>
<el-button @click="goBack"> </el-button>
</div>
</div>
<el-row :gutter="15" class="main" :style="{ margin: '0 auto', width: '100%' }">
<el-form ref="formRef" :model="dataForm" :rules="dataRule" size="small" label-width="100px"
label-position="right">
<template v-if="!loading">
<el-col :span="12" :sm="24" :md="12" :xl="12" :xs="24">
<jnpf-form-tip-item label="工序编码" prop="procCd">
<JnpfInput v-model="dataForm.procCd" @change="changeData('procCd', -1)" placeholder="请输入工序编码"
clearable :disabled="!!dataForm.id" :style="{ width: '100%' }">
</JnpfInput>
</jnpf-form-tip-item>
</el-col>
<el-col :span="12" :sm="24" :md="12" :xl="12" :xs="24">
<jnpf-form-tip-item label="工序名称" prop="procName" >
<JnpfInput v-model="dataForm.procName" @change="changeData('procName', -1)" placeholder="请输入工序名称"
clearable :style="{ width: '100%' }">
</JnpfInput>
</jnpf-form-tip-item>
</el-col>
<el-col :span="12" :sm="24" :md="12" :xl="12" :xs="24">
<jnpf-form-tip-item label="状态" prop="enabledStatus">
<JnpfSelect v-model="dataForm.enabledStatus" @change="changeData('enabledStatus', -1)"
placeholder="请选择状态" :options="enabledStatusOptions" :props="enabledStatusProps" clearable
:style="{ width: '100%' }">
</JnpfSelect>
</jnpf-form-tip-item>
</el-col>
<el-col :span="24" :sm="24" :md="24" :xl="24" :xs="24">
<jnpf-form-tip-item label="备注" prop="remark">
<JnpfTextarea v-model="dataForm.remark" @change="changeData('remark', -1)" placeholder="请输入备注"
:style="{ width: '100%' }" :autoSize="{ minRows: 4, maxRows: 4 }" type="textarea">
</JnpfTextarea>
</jnpf-form-tip-item>
</el-col>
</template>
</el-form>
</el-row>
</div>
</transition>
</template>
<script>
import request from '@/utils/request'
import { mapGetters } from 'vuex'
export default {
components: {},
props: [],
data() {
return {
visible: false,
loading: false,
btnLoading: false,
formRef: 'formRef',
eventType: '',
dataForm: {
id: '',
procCd: undefined,
procName: undefined,
enabledStatus: 1,
remark: undefined,
},
dataRule: {
procCd: [
{
required: true,
message: '请输入工序编码',
trigger: 'blur',
},
],
procName: [
{
required: true,
message: '请输入工序名称',
trigger: 'blur',
},
],
enabledStatus: [
{
required: true,
message: '请选择状态',
trigger: 'change',
},
],
},
enabledStatusOptions: [
{ fullName: "启用", id: 1 },
{ fullName: "未启用", id: 2 },
],
enabledStatusProps: { label: "fullName", value: "id" },
}
},
computed: {
...mapGetters(['userInfo']),
},
methods: {
init(id) {
this.dataForm.id = id || '';
this.visible = true;
this.loading = true;
this.$nextTick(() => {
this.$refs.formRef.resetFields();
if (this.dataForm.id) {
request({
url: `/api/example/proc/${this.dataForm.id}`,
method: 'get'
}).then(res => {
this.dataForm = res.data
this.loading = false
})
} else {
this.loading = false
}
});
},
dataFormSubmit() {
this.$refs.formRef.validate((valid) => {
if (valid) {
this.btnLoading = true;
const isEdit = !!this.dataForm.id;
const url = isEdit ? `/api/example/proc/${this.dataForm.id}` : '/api/example/proc';
const method = isEdit ? 'put' : 'post';
request({
url: url,
method: method,
data: this.dataForm
}).then(res => {
this.$message({
message: res.msg,
type: 'success',
duration: 1500,
onClose: () => {
this.btnLoading = false;
this.$emit('refresh', true)
}
})
}).catch(() => {
this.btnLoading = false
})
}
})
},
goBack() {
this.$emit('refresh')
},
changeData(model, index) {
this.isEdit = true
}
}
}
</script>

View File

@ -0,0 +1,166 @@
<template>
<div class="JNPF-common-layout proc_data">
<div class="JNPF-common-layout-center">
<el-row class="JNPF-common-search-box" :gutter="14">
<el-form @submit.native.prevent>
<!-- <el-col :span="6">-->
<!-- <el-form-item label="工序编码">-->
<!-- <el-input v-model="query.procCd" placeholder="请输入" clearable></el-input>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col :span="6">-->
<!-- <el-form-item label="工序名称">-->
<!-- <el-input v-model="query.procName" placeholder="请输入" clearable></el-input>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<el-col :span="6">
<el-form-item label="状态">
<JnpfSelect v-model="query.enabledStatus" placeholder="请选择" clearable :options="enabledStatusOptions"
:props="enabledStatusProps">
</JnpfSelect>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item class="btn">
<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<div class="JNPF-common-layout-main JNPF-flex-main">
<div class="JNPF-common-head">
<div>
<el-button type="primary" icon="icon-ym icon-ym-btn-add" @click="addOrUpdateHandle()">新建</el-button>
</div>
<div class="JNPF-common-head-right"></div>
</div>
<JNPF-table v-loading="listLoading" :data="list">
<el-table-column prop="procCd" label="工序编码" align="center"/>
<el-table-column prop="procName" label="工序名称" align="center"/>
<el-table-column prop="enabledStatus" label="状态" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.enabledStatus == 1 ? 'success' : 'info'" size="small">
{{ scope.row.enabledStatus == 1 ? '启用' : scope.row.enabledStatus == 2 ? '未启用' : scope.row.enabledStatus }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" align="center"/>
<el-table-column prop="creatorTime" label="创建时间" align="center" :formatter="jnpf.tableDateFormat1"/>
<el-table-column label="操作" fixed="right" align="center" width="100">
<template slot-scope="scope">
<el-button type="text" @click="addOrUpdateHandle(scope.row)">编辑</el-button>
</template>
</el-table-column>
</JNPF-table>
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize"
@pagination="initData" />
</div>
</div>
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" />
</div>
</template>
<script>
import request from "@/utils/request";
import { mapGetters } from "vuex";
import JNPFForm from "./form";
import jnpf from "@/utils/jnpf";
export default {
name: "proc_list",
components: {
JNPFForm,
},
data() {
return {
keyword: "",
query: {
procCd: undefined,
procName: undefined,
enabledStatus: undefined,
},
defListQuery: {
sort: "desc",
sidx: "",
},
list: [],
listLoading: false,
multipleSelection: [],
total: 0,
listQuery: {
currentPage: 1,
pageSize: 20,
sort: "",
sidx: "",
},
formVisible: false,
enabledStatusOptions: [
{ fullName: "启用", id: 1 },
{ fullName: "未启用", id: 2 },
],
enabledStatusProps: { label: "fullName", value: "id" },
};
},
computed: {
jnpf() {
return jnpf
},
...mapGetters(["userInfo"]),
menuId() {
return this.$route.meta.modelId || "";
},
},
created() {
this.initData();
},
methods: {
initData() {
this.listLoading = true;
let _query = {
...this.listQuery,
...this.query,
dataType: 0,
};
request({
url: `/api/example/proc/getList`,
method: "post",
data: _query,
}).then((res) => {
var _list = [];
for (let i = 0; i < res.data.list.length; i++) {
let _data = res.data.list[i];
_list.push(_data);
}
this.list = _list;
this.total = res.data.pagination.total;
this.listLoading = false;
});
},
addOrUpdateHandle(row) {
let id = row ? row.id : "";
this.formVisible = true;
this.$nextTick(() => {
this.$refs.JNPFForm.init(id);
});
},
search() {
this.listQuery.currentPage = 1;
this.listQuery.pageSize = 20;
this.initData();
},
refresh(isrRefresh) {
this.formVisible = false;
if (isrRefresh) this.search();
},
reset() {
this.query = {
procCd: undefined,
procName: undefined,
enabledStatus: undefined,
};
this.search();
},
},
};
</script>

View File

@ -0,0 +1,161 @@
<template>
<transition name="el-zoom-in-center">
<div class="JNPF-preview-main">
<div class="JNPF-common-page-header">
<el-page-header @back="goBack" :content="!dataForm.id ? '新建' : '编辑'" />
<div class="options">
<el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading"> </el-button>
<el-button @click="goBack"> </el-button>
</div>
</div>
<el-row :gutter="15" class="main" :style="{ margin: '0 auto', width: '100%' }">
<el-form ref="formRef" :model="dataForm" :rules="dataRule" size="small" label-width="100px"
label-position="right">
<template v-if="!loading">
<el-col :span="12" :sm="24" :md="12" :xl="12" :xs="24">
<jnpf-form-tip-item label="产线编码" prop="proLineCd">
<JnpfInput v-model="dataForm.proLineCd" @change="changeData('proLineCd', -1)" placeholder="请输入产线编码"
clearable :disabled="!!dataForm.id" :style="{ width: '100%' }">
</JnpfInput>
</jnpf-form-tip-item>
</el-col>
<el-col :span="12" :sm="24" :md="12" :xl="12" :xs="24">
<jnpf-form-tip-item label="产线名称" prop="proLineName">
<JnpfInput v-model="dataForm.proLineName" @change="changeData('proLineName', -1)" placeholder="请输入产线名称"
clearable :style="{ width: '100%' }">
</JnpfInput>
</jnpf-form-tip-item>
</el-col>
<el-col :span="12" :sm="24" :md="12" :xl="12" :xs="24">
<jnpf-form-tip-item label="状态" prop="enabledStatus">
<JnpfSelect v-model="dataForm.enabledStatus" @change="changeData('enabledStatus', -1)"
placeholder="请选择状态" :options="enabledStatusOptions" :props="enabledStatusProps" clearable
:style="{ width: '100%' }">
</JnpfSelect>
</jnpf-form-tip-item>
</el-col>
<el-col :span="24" :sm="24" :md="24" :xl="24" :xs="24">
<jnpf-form-tip-item label="备注" prop="remark">
<JnpfTextarea v-model="dataForm.remark" @change="changeData('remark', -1)" placeholder="请输入备注"
:style="{ width: '100%' }" :autoSize="{ minRows: 4, maxRows: 4 }" type="textarea">
</JnpfTextarea>
</jnpf-form-tip-item>
</el-col>
</template>
</el-form>
</el-row>
</div>
</transition>
</template>
<script>
import request from '@/utils/request'
import { mapGetters } from 'vuex'
export default {
components: {},
props: [],
data() {
return {
visible: false,
loading: false,
btnLoading: false,
formRef: 'formRef',
eventType: '',
dataForm: {
id: '',
proLineCd: undefined,
proLineName: undefined,
enabledStatus: 1,
remark: undefined,
},
dataRule: {
proLineCd: [
{
required: true,
message: '请输入产线编码',
trigger: 'blur',
},
],
proLineName: [
{
required: true,
message: '请输入产线名称',
trigger: 'blur',
},
],
enabledStatus: [
{
required: true,
message: '请选择状态',
trigger: 'change',
},
],
},
enabledStatusOptions: [
{ fullName: "启用", id: 1 },
{ fullName: "未启用", id: 2 },
],
enabledStatusProps: { label: "fullName", value: "id" },
}
},
computed: {
...mapGetters(['userInfo']),
},
methods: {
init(id) {
this.dataForm.id = id || '';
this.visible = true;
this.loading = true;
this.$nextTick(() => {
this.$refs.formRef.resetFields();
if (this.dataForm.id) {
request({
url: `/api/example/proLine/${this.dataForm.id}`,
method: 'get'
}).then(res => {
this.dataForm = res.data
this.loading = false
})
} else {
this.loading = false
}
});
},
dataFormSubmit() {
this.$refs.formRef.validate((valid) => {
if (valid) {
this.btnLoading = true;
const isEdit = !!this.dataForm.id;
const url = isEdit ? `/api/example/proLine/${this.dataForm.id}` : '/api/example/proLine';
const method = isEdit ? 'put' : 'post';
request({
url: url,
method: method,
data: this.dataForm
}).then(res => {
this.$message({
message: res.msg,
type: 'success',
duration: 1500,
onClose: () => {
this.btnLoading = false;
this.$emit('refresh', true)
}
})
}).catch(() => {
this.btnLoading = false
})
}
})
},
goBack() {
this.$emit('refresh')
},
changeData(model, index) {
this.isEdit = true
}
}
}
</script>

View File

@ -0,0 +1,175 @@
<template>
<div class="JNPF-common-layout proline_data">
<div class="JNPF-common-layout-center">
<el-row class="JNPF-common-search-box" :gutter="14">
<el-form @submit.native.prevent>
<!-- <el-col :span="6">-->
<!-- <el-form-item label="产线编码">-->
<!-- <el-input v-model="query.proLineCd" placeholder="请输入" clearable></el-input>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col :span="6">-->
<!-- <el-form-item label="产线名称">-->
<!-- <el-input v-model="query.proLineName" placeholder="请输入" clearable></el-input>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<el-col :span="6">
<el-form-item label="状态">
<JnpfSelect v-model="query.enabledStatus" placeholder="请选择" clearable :options="enabledStatusOptions"
:props="enabledStatusProps">
</JnpfSelect>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item class="btn">
<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<div class="JNPF-common-layout-main JNPF-flex-main">
<div class="JNPF-common-head">
<div>
<el-button type="primary" icon="icon-ym icon-ym-btn-add" @click="addOrUpdateHandle()">新建</el-button>
</div>
<div class="JNPF-common-head-right"></div>
</div>
<JNPF-table v-loading="listLoading" :data="list">
<el-table-column prop="proLineCd" label="产线编码" align="center"/>
<el-table-column prop="proLineName" label="产线名称" align="center"/>
<el-table-column prop="enabledStatus" label="状态" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.enabledStatus == 1 ? 'success' : 'info'" size="small">
{{ scope.row.enabledStatus == 1 ? '启用' : scope.row.enabledStatus == 2 ? '未启用' : scope.row.enabledStatus }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" align="center"/>
<el-table-column prop="creatorTime" label="创建时间" align="center" :formatter="jnpf.tableDateFormat1"/>
<el-table-column label="操作" fixed="right" align="center" width="100">
<template slot-scope="scope">
<el-button type="text" @click="addOrUpdateHandle(scope.row)">编辑</el-button>
</template>
</el-table-column>
</JNPF-table>
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize"
@pagination="initData" />
</div>
</div>
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" />
</div>
</template>
<script>
import request from "@/utils/request";
import { mapGetters } from "vuex";
import JNPFForm from "./form";
import jnpf from "@/utils/jnpf";
export default {
name: "proline_list",
components: {
JNPFForm,
},
data() {
return {
keyword: "",
query: {
proLineCd: undefined,
proLineName: undefined,
enabledStatus: undefined,
},
defListQuery: {
sort: "desc",
sidx: "",
},
list: [],
listLoading: false,
multipleSelection: [],
total: 0,
listQuery: {
currentPage: 1,
pageSize: 20,
sort: "",
sidx: "",
},
formVisible: false,
enabledStatusOptions: [
{ fullName: "启用", id: 1 },
{ fullName: "未启用", id: 2 },
],
enabledStatusProps: { label: "fullName", value: "id" },
};
},
computed: {
jnpf() {
return jnpf
},
...mapGetters(["userInfo"]),
menuId() {
return this.$route.meta.modelId || "";
},
},
created() {
this.initData();
},
methods: {
initData() {
this.listLoading = true;
let _query = {
...this.listQuery,
...this.query,
dataType: 0,
};
//
Object.keys(_query).forEach(key => {
if (_query[key] === undefined || _query[key] === null || _query[key] === '') {
delete _query[key];
}
});
console.log('查询参数:', _query); //
request({
url: `/api/example/proLine/getList`,
method: "post",
data: _query,
}).then((res) => {
var _list = [];
for (let i = 0; i < res.data.list.length; i++) {
let _data = res.data.list[i];
_list.push(_data);
}
this.list = _list;
this.total = res.data.pagination.total;
this.listLoading = false;
});
},
addOrUpdateHandle(row) {
let id = row ? row.id : "";
this.formVisible = true;
this.$nextTick(() => {
this.$refs.JNPFForm.init(id);
});
},
search() {
this.listQuery.currentPage = 1;
this.listQuery.pageSize = 20;
this.initData();
},
refresh(isrRefresh) {
this.formVisible = false;
if (isrRefresh) this.search();
},
reset() {
this.query = {
proLineCd: undefined,
proLineName: undefined,
enabledStatus: undefined,
};
this.search();
},
},
};
</script>