| | |
| | | |
| | | package org.springblade.mdm.program.controller; |
| | | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.enums.ParameterIn; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.mdm.program.service.NcNodeService; |
| | | import org.springblade.mdm.program.vo.NcNodeVO; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 程序节点 |
| | |
| | | * 新增 |
| | | */ |
| | | @PostMapping("/save") |
| | | @Operation(summary = "新增节点", description = "节点信息") |
| | | @Operation(summary = "新增节点", description = "节点信息,id保持空") |
| | | public R<Boolean> save(@RequestBody NcNodeVO vo) { |
| | | |
| | | ncNodeService.saveNcCode(vo); |
| | | return R.<Boolean>status(true); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/update") |
| | | @Operation(summary = "修改节点") |
| | | @Operation(summary = "修改节点", description = "节点信息,必须传入ID") |
| | | public R<Boolean> update(@RequestBody NcNodeVO vo) { |
| | | |
| | | ncNodeService.updateNcCode(vo); |
| | | return R.<Boolean>status(true); |
| | | } |
| | |
| | | ncNodeService.removeById(id); |
| | | return R.<Boolean>status(true); |
| | | } |
| | | |
| | | @GetMapping("/lazy-list") |
| | | @Parameters({ |
| | | @Parameter(name = "deptName", description = "部门名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")), |
| | | @Parameter(name = "fullName", description = "部门全称", in = ParameterIn.QUERY, schema = @Schema(type = "string")) |
| | | }) |
| | | |
| | | @Operation(summary = "懒加载列表", description = "程序目录树形结构") |
| | | public R<List<NcNodeVO>> lazyList(Long parentId) { |
| | | List<NcNodeVO> list = ncNodeService.lazyList(parentId); |
| | | return R.data(list); |
| | | } |
| | | } |
| | |
| | | import org.springblade.core.mp.mapper.BladeMapper; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.entity.NcProgram; |
| | | import org.springblade.mdm.program.vo.NcNodeVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface NcNodeMapper extends BladeMapper<NcNode> { |
| | | List<NcNodeVO> lazyList(Long parentId); |
| | | |
| | | /** |
| | | * 获取最新固化程序 |
| | |
| | | <!-- <select id="parentTree" resultMap="treeNodeResultMap">--> |
| | | <!-- select id, parent_id, dict_value as title, id as "value", id as "key" from blade_dict where is_deleted = 0 and parent_id = 0--> |
| | | <!-- </select>--> |
| | | <sql id="all_columns">id,tenant_id,nc_node_id,code,name,package_name,machine_code,part_no,is_cured, |
| | | <sql id="prog_all_columns">id,tenant_id,nc_node_id,code,name,package_name,machine_code,part_no,is_cured, |
| | | expire_date,process_edition,is_last_edition,is_locked,task_assign_time,status,create_dept,is_deleted,create_time,create_user,update_time,update_user</sql> |
| | | <select id="getCuredNcProgram" resultMap="BaseResultMap"> |
| | | select <include refid="all_columns"/> from mdm_nc_program |
| | | select <include refid="prog_all_columns"/> from mdm_nc_program |
| | | where is_deleted=0 and is_cured=1 and part_no=#{partNo} and is_last_edition=1 |
| | | and machine_code in (select code from mdm_machine where machine_group_code=#{machineGroupCode}) |
| | | order by create_time desc |
| | | limit 1 |
| | | </select> |
| | | |
| | | <sql id="all_columns">id,tenant_id,name,parent_id,node_type,status,create_dept,is_deleted,create_time,create_user,update_time,update_user</sql> |
| | | <select id="lazyList" resultType="org.springblade.mdm.program.vo.NcNodeVO"> |
| | | select <include refid="all_columns"/>,( |
| | | SELECT |
| | | CASE WHEN count(1) > 0 THEN 1 ELSE 0 END |
| | | FROM |
| | | mdm_nc_node |
| | | WHERE |
| | | parent_id = n.id and is_deleted = 0 |
| | | ) AS "has_children" from mdm_nc_node n where is_deleted=0 and parent_id=#{parentId} |
| | | </select> |
| | | </mapper> |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.flowable.engine.*; |
| | | import org.springblade.core.mp.base.BizServiceImpl; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.basesetting.machine.MachineService; |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | |
| | | import org.springblade.mdm.program.vo.NcNodeVO; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 程序节点 |
| | |
| | | |
| | | this.updateById(ncNode); |
| | | } |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * @param parentId 父节点ID |
| | | * @return |
| | | */ |
| | | public List<NcNodeVO> lazyList(Long parentId) { |
| | | // 判断点击搜索但是没有查询条件的情况 |
| | | if (Func.isEmpty(parentId)) { |
| | | parentId = 0L; |
| | | } |
| | | |
| | | return baseMapper.lazyList(parentId); |
| | | } |
| | | } |
| | |
| | | public class NcNodeVO extends BaseVO { |
| | | @Schema(description = "节点名称") |
| | | private String name; |
| | | @Schema(description = "父ID") |
| | | @Schema(description = "父ID,根节点父id=0") |
| | | private Long parentId; |
| | | @Schema(description = "节点类型,字典(程序节点类型nc_node_type)") |
| | | private String nodeType; |
| | | |
| | | @Schema(description = "是否有子节点") |
| | | private Boolean hasChildren; |
| | | } |