diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/EquipmentMapper.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/EquipmentMapper.java new file mode 100644 index 0000000..8bb453c --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/EquipmentMapper.java @@ -0,0 +1,11 @@ +package jnpf.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import jnpf.model.equipment.EquipmentEntity; + +/** + * 设备主数据 Mapper + */ +public interface EquipmentMapper extends BaseMapper { + +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/EquipmentService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/EquipmentService.java new file mode 100644 index 0000000..ba5eba0 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/EquipmentService.java @@ -0,0 +1,65 @@ +package jnpf.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import jnpf.model.equipment.EquipmentEntity; +import jnpf.model.equipment.EquipmentForm; +import jnpf.model.equipment.EquipmentPagination; + +import java.util.List; + +/** + * 设备主数据 Service + */ +public interface EquipmentService extends IService { + + /** + * 列表查询 + * @param equipmentPagination 分页参数 + * @return 列表数据 + */ + List getList(EquipmentPagination equipmentPagination); + + /** + * 详情查询 + * @param id 主键 + * @return 实体对象 + */ + EquipmentEntity getInfo(String id); + + /** + * 新增 + * @param entity 实体对象 + */ + void create(EquipmentEntity entity); + + /** + * 修改 + * @param id 主键 + * @param entity 实体对象 + * @return 是否成功 + */ + boolean update(String id, EquipmentEntity entity); + + /** + * 删除 + * @param entity 实体对象 + */ + void delete(EquipmentEntity entity); + + /** + * 验证表单 + * @param form 表单对象 + * @param i 0新增-1修改 + * @return 错误信息 + */ + String checkForm(EquipmentForm form, int i); + + /** + * 保存或更新 + * @param equipmentForm 表单对象 + * @param id 主键 + * @param isSave 是否新增 + * @throws Exception 异常 + */ + void saveOrUpdate(EquipmentForm equipmentForm, String id, boolean isSave) throws Exception; +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ProLineService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ProLineService.java index 4738811..31f5b62 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ProLineService.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ProLineService.java @@ -28,5 +28,6 @@ public interface ProLineService extends IService { boolean update(String id, ProLineEntity entity); String checkForm(ProLineForm form, int i); void saveOrUpdate(ProLineForm proLineForm, String id, boolean isSave) throws Exception; + List getSelectList(); } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/EquipmentServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/EquipmentServiceImpl.java new file mode 100644 index 0000000..eeb8c62 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/EquipmentServiceImpl.java @@ -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.mapper.EquipmentMapper; +import jnpf.model.equipment.EquipmentEntity; +import jnpf.model.equipment.EquipmentForm; +import jnpf.model.equipment.EquipmentPagination; +import jnpf.service.EquipmentService; +import jnpf.util.StringUtil; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 设备主数据 ServiceImpl + */ +@Service +public class EquipmentServiceImpl extends ServiceImpl implements EquipmentService { + + @Override + public List getList(EquipmentPagination equipmentPagination) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (ObjectUtil.isNotEmpty(equipmentPagination.getEqCode())) { + wrapper.like(EquipmentEntity::getEqCode, equipmentPagination.getEqCode()); + } + if (ObjectUtil.isNotEmpty(equipmentPagination.getEqName())) { + wrapper.like(EquipmentEntity::getEqName, equipmentPagination.getEqName()); + } + if (ObjectUtil.isNotEmpty(equipmentPagination.getEqType())) { + wrapper.eq(EquipmentEntity::getEqType, equipmentPagination.getEqType()); + } + if (ObjectUtil.isNotEmpty(equipmentPagination.getMode())) { + wrapper.like(EquipmentEntity::getMode, equipmentPagination.getMode()); + } + if (ObjectUtil.isNotEmpty(equipmentPagination.getManufacturer())) { + wrapper.like(EquipmentEntity::getManufacturer, equipmentPagination.getManufacturer()); + } + if (ObjectUtil.isNotEmpty(equipmentPagination.getEqStatus())) { + wrapper.eq(EquipmentEntity::getEqStatus, equipmentPagination.getEqStatus()); + } + if (ObjectUtil.isNotEmpty(equipmentPagination.getDeptId())) { + wrapper.eq(EquipmentEntity::getDeptId, equipmentPagination.getDeptId()); + } + if (ObjectUtil.isNotEmpty(equipmentPagination.getLineId())) { + wrapper.eq(EquipmentEntity::getLineId, equipmentPagination.getLineId()); + } + if (ObjectUtil.isNotEmpty(equipmentPagination.getEnabledStatus())) { + wrapper.eq(EquipmentEntity::getEnabledStatus, equipmentPagination.getEnabledStatus()); + } + if (ObjectUtil.isNotEmpty(equipmentPagination.getKeyword())) { + String keyword = equipmentPagination.getKeyword(); + wrapper.and(w -> w.like(EquipmentEntity::getEqCode, keyword) + .or() + .like(EquipmentEntity::getEqName, keyword) + .or() + .like(EquipmentEntity::getMode, keyword)); + } + + wrapper.eq(EquipmentEntity::getDeleteMark, 0); + wrapper.orderByDesc(EquipmentEntity::getId); + + if ("0".equals(equipmentPagination.getDataType())) { + Page page = new Page<>(equipmentPagination.getCurrentPage(), equipmentPagination.getPageSize()); + IPage equipmentIPage = this.page(page, wrapper); + equipmentPagination.setData(equipmentIPage.getRecords(), equipmentIPage.getTotal()); + return equipmentIPage.getRecords(); + } else { + return this.list(wrapper); + } + } + + @Override + public EquipmentEntity getInfo(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(EquipmentEntity::getId, id); + return this.getOne(queryWrapper); + } + + @Override + public void create(EquipmentEntity entity) { + this.save(entity); + } + + @Override + public boolean update(String id, EquipmentEntity entity) { + return this.updateById(entity); + } + + @Override + public void delete(EquipmentEntity entity) { + if (entity != null) { + this.removeById(entity.getId()); + } + } + + @Override + public String checkForm(EquipmentForm 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.getEqCode())) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(EquipmentEntity::getEqCode, form.getEqCode()); + if (isUp) { + wrapper.ne(EquipmentEntity::getId, id); + } + long count = this.count(wrapper); + if (count > 0) { + countRecover += "设备编码已存在,请重新输入!"; + } + } + + return countRecover; + } + + @Override + public void saveOrUpdate(EquipmentForm equipmentForm, String id, boolean isSave) throws Exception { + EquipmentEntity entity = getInfo(id); + if (entity == null) { + entity = new EquipmentEntity(); + } + BeanUtils.copyProperties(equipmentForm, entity); + this.saveOrUpdate(entity); + } +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ProLineServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ProLineServiceImpl.java index 4fe899b..61d9558 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ProLineServiceImpl.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ProLineServiceImpl.java @@ -128,4 +128,15 @@ public class ProLineServiceImpl extends ServiceImpl getSelectList() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ProLineEntity::getDeleteMark, 0); + wrapper.eq(ProLineEntity::getEnabledStatus, 1); + wrapper.select(ProLineEntity::getId, ProLineEntity::getProLineName); + wrapper.orderByAsc(ProLineEntity::getProLineName); + return this.list(wrapper); + } + + } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/EquipmentController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/EquipmentController.java new file mode 100644 index 0000000..9e7cab2 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/EquipmentController.java @@ -0,0 +1,104 @@ +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.model.equipment.EquipmentEntity; +import jnpf.model.equipment.EquipmentForm; +import jnpf.model.equipment.EquipmentPagination; +import jnpf.service.EquipmentService; +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 = "Equipment") +@RestController +@RequestMapping("/api/example/equipment") +public class EquipmentController { + + @Autowired + private EquipmentService equipmentService; + + @Operation(summary = "获取设备列表") + @PostMapping("/getList") + public ActionResult getList(@RequestBody EquipmentPagination equipmentPagination) { + List list = equipmentService.getList(equipmentPagination); + List> realList = list.stream() + .map(JsonUtil::entityToMap) + .collect(Collectors.toList()); + + PageListVO vo = new PageListVO(); + vo.setList(realList); + PaginationVO page = JsonUtil.getJsonToBean(equipmentPagination, PaginationVO.class); + vo.setPagination(page); + return ActionResult.success(vo); + } + + @Operation(summary = "获取设备详情") + @GetMapping("/{id}") + public ActionResult info(@PathVariable("id") String id) { + EquipmentEntity entity = equipmentService.getInfo(id); + if (entity != null) { + return ActionResult.success(JsonUtil.entityToMap(entity)); + } + return ActionResult.fail("数据不存在"); + } + + @Operation(summary = "新建设备") + @PostMapping + public ActionResult create(@RequestBody @Valid EquipmentForm equipmentForm) { + String b = equipmentService.checkForm(equipmentForm, 0); + if (StringUtil.isNotEmpty(b)) { + return ActionResult.fail(b); + } + try { + equipmentService.saveOrUpdate(equipmentForm, "", true); + return ActionResult.success("新建成功"); + } catch (Exception e) { + return ActionResult.fail("新建数据失败:" + e.getMessage()); + } + } + + @Operation(summary = "更新设备") + @PutMapping("/{id}") + public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid EquipmentForm equipmentForm) { + equipmentForm.setId(id); + String b = equipmentService.checkForm(equipmentForm, 1); + if (StringUtil.isNotEmpty(b)) { + return ActionResult.fail(b); + } + EquipmentEntity entity = equipmentService.getInfo(id); + if (entity != null) { + try { + equipmentService.saveOrUpdate(equipmentForm, id, false); + return ActionResult.success("更新成功"); + } catch (Exception e) { + return ActionResult.fail("更新数据失败:" + e.getMessage()); + } + } else { + return ActionResult.fail("更新失败,数据不存在"); + } + } + + @Operation(summary = "删除设备") + @DeleteMapping("/{id}") + public ActionResult delete(@PathVariable("id") String id) { + EquipmentEntity entity = equipmentService.getInfo(id); + if (entity != null) { + equipmentService.delete(entity); + return ActionResult.success("删除成功"); + } + return ActionResult.fail("删除失败,数据不存在"); + } +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ProLineController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ProLineController.java index eebcee1..ac939b7 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ProLineController.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ProLineController.java @@ -116,5 +116,20 @@ public class ProLineController { return ActionResult.fail("更新失败,数据不存在"); } } + @Operation(summary = "获取产线下拉列表") + @GetMapping("/getSelectList") + public ActionResult getSelectList() { + List list = proLineService.getSelectList(); + List> result = list.stream() + .map(entity -> { + Map map = JsonUtil.entityToMap(entity); + map.put("id", entity.getId()); + map.put("name", entity.getProLineName()); + return map; + }) + .collect(Collectors.toList()); + return ActionResult.success(result); + } + } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/equipment/EquipmentEntity.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/equipment/EquipmentEntity.java new file mode 100644 index 0000000..ced4d67 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/equipment/EquipmentEntity.java @@ -0,0 +1,96 @@ +package jnpf.model.equipment; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.time.LocalDate; +import java.util.Date; + +/** + * 设备主数据 + */ +@Data +@TableName("tba_equipment") +public class EquipmentEntity { + + @TableId(value = "id", type = IdType.AUTO) + private Integer 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(value = "enabled_status", updateStrategy = FieldStrategy.IGNORED) + private Integer enabledStatus; + + @TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED) + private String remark; + + @TableField("eq_code") + private String eqCode; + + @TableField("eq_name") + private String eqName; + + @TableField("eq_type") + private String eqType; + + @TableField("mode") + private String mode; + + @TableField("manufacturer") + private String manufacturer; + + @TableField("factory_no") + private String factoryNo; + + @TableField("supplier") + private String supplier; + + @TableField("buy_date") + private LocalDate buyDate; + + @TableField("eq_status") + private String eqStatus; + + @TableField("dept_id") + private String deptId; + + @TableField("dept_name") + private String deptName; + + @TableField("user_id") + private String userId; + + @TableField("user_name") + private String userName; + + @TableField("line_id") + private String lineId; + + @TableField("line_name") + private String lineName; +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/equipment/EquipmentForm.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/equipment/EquipmentForm.java new file mode 100644 index 0000000..0ff4a35 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/equipment/EquipmentForm.java @@ -0,0 +1,78 @@ +package jnpf.model.equipment; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotBlank; +import java.time.LocalDate; + +/** + * 设备主数据 Form + */ +@Data +public class EquipmentForm { + + @Schema(description = "主键") + private String id; + + @NotBlank(message = "设备编码不能为空") + @Schema(description = "设备编码") + private String eqCode; + + @NotBlank(message = "设备名称不能为空") + @Schema(description = "设备名称") + private String eqName; + + @Schema(description = "设备类型(1生产设备 2动力设备 3特种设备)") + private String eqType; + + @Schema(description = "型号") + private String mode; + + @Schema(description = "制造商") + private String manufacturer; + + @Schema(description = "出厂编号") + private String factoryNo; + + @Schema(description = "供应商") + private String supplier; + + @DateTimeFormat(pattern = "yyyy-MM-dd") + @Schema(description = "购置日期") + private LocalDate buyDate; + + @Schema(description = "设备状态(1在用 2备用 3维修 4封存 5报废)") + private String eqStatus; + + @Schema(description = "责任部门id") + private String deptId; + + @Schema(description = "责任部门") + private String deptName; + + @Schema(description = "责任人id") + private String userId; + + @Schema(description = "责任人") + private String userName; + + @Schema(description = "产线id") + private String lineId; + + @Schema(description = "产线名称") + private String lineName; + + @Schema(description = "状态(1启用 2未启用)") + private Integer enabledStatus; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "流程ID") + private String flowId; + + @Schema(description = "流程任务ID") + private String flowTaskId; +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/equipment/EquipmentPagination.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/equipment/EquipmentPagination.java new file mode 100644 index 0000000..cd5904e --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/equipment/EquipmentPagination.java @@ -0,0 +1,45 @@ +package jnpf.model.equipment; + +import io.swagger.v3.oas.annotations.media.Schema; +import jnpf.base.Pagination; +import lombok.Data; + +/** + * 设备主数据 Pagination + */ +@Data +public class EquipmentPagination extends Pagination { + + @Schema(description = "数据类型") + private String dataType; + + @Schema(description = "设备编码") + private String eqCode; + + @Schema(description = "设备名称") + private String eqName; + + @Schema(description = "设备类型(1生产设备 2动力设备 3特种设备)") + private String eqType; + + @Schema(description = "型号") + private String mode; + + @Schema(description = "制造商") + private String manufacturer; + + @Schema(description = "设备状态(1在用 2备用 3维修 4封存 5报废)") + private String eqStatus; + + @Schema(description = "责任部门id") + private Integer deptId; + + @Schema(description = "产线id") + private Integer lineId; + + @Schema(description = "状态(1启用 2未启用)") + private Integer enabledStatus; + + @Schema(description = "关键词") + private String keyword; +} diff --git a/jnpf-java-boot/jnpf-web/src/views/example/equipment/equipment.js b/jnpf-java-boot/jnpf-web/src/views/example/equipment/equipment.js new file mode 100644 index 0000000..4884bac --- /dev/null +++ b/jnpf-java-boot/jnpf-web/src/views/example/equipment/equipment.js @@ -0,0 +1,89 @@ +import request from '@/utils/request' + +// 获取设备列表 +export function getEquipmentList(data) { + return request({ + url: '/api/example/equipment/getList', + method: 'post', + data + }) +} + +// 获取设备详情 +export function getEquipmentInfo(id) { + return request({ + url: `/api/example/equipment/${id}`, + method: 'get' + }) +} + +// 新建设备 +export function createEquipment(data) { + return request({ + url: '/api/example/equipment', + method: 'post', + data + }) +} + +// 更新设备 +export function updateEquipment(id, data) { + return request({ + url: `/api/example/equipment/${id}`, + method: 'put', + data + }) +} + +// 删除设备 +export function deleteEquipment(id) { + return request({ + url: `/api/example/equipment/${id}`, + method: 'delete' + }) +} + +// 获取部门列表 +export function getDeptList() { + return request({ + url: '/api/example/equipment/getDeptList', + method: 'get' + }) +} + +// 获取人员列表 +export function getUserList(deptId) { + return request({ + url: `/api/example/equipment/getUserList/${deptId || ''}`, + method: 'get' + }) +} + +// 获取产线列表 +export function getLineList() { + return request({ + url: '/api/example/proLine/getSelectList', + method: 'get' + }) +} + + +// 客户管理字典映射配置(id -> 名称) +export const equipmentMaps = { + eqType: {'1': ' 生产设备', '2': '动力设备', '3': '特种设备'}, + eqStatus: {'1': ' 在用', '2': '备用', '3': '维修', '4': '封存', '5': '报废'}, +} + +// 根据映射自动生成下拉选项 +export const customerOptions = {} +for (const key in equipmentMaps) { + const map = equipmentMaps[key] + customerOptions[key] = Object.entries(map).map(([id, fullName]) => ({id, fullName})) +} + +// 获取显示名称 +export function getLabel(type, value) { + const map = equipmentMaps[type] + return map ? (map[value] || value) : value +} + diff --git a/jnpf-java-boot/jnpf-web/src/views/example/equipment/form.vue b/jnpf-java-boot/jnpf-web/src/views/example/equipment/form.vue new file mode 100644 index 0000000..302a95d --- /dev/null +++ b/jnpf-java-boot/jnpf-web/src/views/example/equipment/form.vue @@ -0,0 +1,354 @@ + + + diff --git a/jnpf-java-boot/jnpf-web/src/views/example/equipment/index.vue b/jnpf-java-boot/jnpf-web/src/views/example/equipment/index.vue new file mode 100644 index 0000000..7ecbe8b --- /dev/null +++ b/jnpf-java-boot/jnpf-web/src/views/example/equipment/index.vue @@ -0,0 +1,290 @@ + + +