lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java
@@ -73,8 +73,7 @@ @Autowired private IProcessParametersTemplateService processParametersTemplateService; // @Autowired // private IUploadRelaService uploadRelaService; @Autowired private ISysBaseAPI sysBaseApi; lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentCategoryController.java
@@ -109,6 +109,7 @@ return Result.OK(pageList); } /** * æ·»å * @@ -138,6 +139,12 @@ //@RequiresPermissions("org.jeecg.modules.demo:mom_eam_equipment_category:edit") @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) public Result<String> edit(@RequestBody EquipmentCategory equipmentCategory) { List<EquipmentCategory> equipmentCategories = equipmentCategory.getEquipmentCategoryDtlList(); for(EquipmentCategory equipmentCategoryChild:equipmentCategories){ equipmentCategoryChild.setEquipmentCategoryUda1(equipmentCategory.getEquipmentCategoryUda1()); equipmentCategoryChild.setEquipmentCategoryUda2(equipmentCategory.getEquipmentCategoryUda2()); } equipmentCategoryService.saveOrUpdateBatch(equipmentCategories); equipmentCategoryService.updateById(equipmentCategory); return Result.OK("ç¼è¾æå!"); } @@ -205,7 +212,7 @@ //@RequiresPermissions("org.jeecg.modules.demo:mom_eam_equipment_category:exportXls") @RequestMapping(value = "/exportXls") public ModelAndView exportXls(HttpServletRequest request, EquipmentCategory equipmentCategory) { return super.exportXls(request, equipmentCategory, EquipmentCategory.class, "mom_eam_equipment_category"); return super.exportXls(request, equipmentCategory, EquipmentCategory.class, "设å¤åç±»"); } /** @@ -227,8 +234,18 @@ */ @GetMapping("/loadTree") public Result<?> loadTree(HttpServletRequest httpServletRequest) { List<CommonGenericTree> list = equipmentCategoryService.loadTree(); List<CommonGenericTree> list = equipmentCategoryService.loadTreeByRecurrence(); return Result.ok(list); } @GetMapping(value = "/getAllChildren") public Result<IPage<EquipmentCategory>> getAllChildren(EquipmentCategory equipmentCategory, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req){ QueryWrapper<EquipmentCategory> queryWrapper = Wrappers.query(); Page<EquipmentCategory> page = new Page<EquipmentCategory>(pageNo, pageSize); IPage<EquipmentCategory> pageList = equipmentCategoryService.getAllChildren(page, equipmentCategory); return Result.OK(pageList); } } lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EquipmentCategory.java
@@ -38,7 +38,6 @@ private static final long serialVersionUID = 1L; /**ç¶id*/ @Excel(name = "ç¶id", width = 15) @ApiModelProperty(value = "ç¶id") private String parentId; /**设å¤åç±»ç¼ç */ @@ -51,31 +50,28 @@ private String name; /**ç§æ·id*/ @Excel(name = "ç§æ·id", width = 15) @ApiModelProperty(value = "ç§æ·id") private String tenantId; /**å é¤ç¶æ(0-æ£å¸¸,1-å·²å é¤)*/ @Excel(name = "å é¤ç¶æ(0-æ£å¸¸,1-å·²å é¤)", width = 15) @ApiModelProperty(value = "å é¤ç¶æ(0-æ£å¸¸,1-å·²å é¤)") private Integer delFlag = CommonConstant.DEL_FLAG_0; /**å¤ç¨å段1*/ @Excel(name = "å¤ç¨å段1", width = 15) @ApiModelProperty(value = "å¤ç¨å段1") @Excel(name = "设å¤åç±»æ è¯", width = 15,dicCode = "equipment_category") @ApiModelProperty(value = "设å¤åç±»æ è¯ï¼æ°æ®åå ¸ï¼equipment_categoryï¼") @Dict(dicCode = "equipment_category") private String equipmentCategoryUda1; /**å¤ç¨å段2*/ @Excel(name = "å¤ç¨å段2", width = 15) @ApiModelProperty(value = "å¤ç¨å段2") @Excel(name = "ææ¯ç¶æé´å®å¨æ", width = 15,dicCode = "appraisal_cycle") @ApiModelProperty(value = "ææ¯ç¶æé´å®å¨æ") @Dict(dicCode = "appraisal_cycle") private String equipmentCategoryUda2; /**å¤ç¨å段3*/ @Excel(name = "å¤ç¨å段3", width = 15) @ApiModelProperty(value = "å¤ç¨å段3") private String equipmentCategoryUda3; /**å¤ç¨å段4*/ @Excel(name = "å¤ç¨å段4", width = 15) @ApiModelProperty(value = "å¤ç¨å段4") private String equipmentCategoryUda4; /**å¤ç¨å段5*/ @Excel(name = "å¤ç¨å段5", width = 15) @ApiModelProperty(value = "å¤ç¨å段5") private String equipmentCategoryUda5; /**夿³¨*/ @@ -84,7 +80,6 @@ private String remark; /**ç¶æ 0 ç¦ç¨ 1 å¯ç¨*/ @Excel(name = "ç¶æ 0 ç¦ç¨ 1 å¯ç¨", width = 15) @ApiModelProperty(value = "ç¶æ 0 ç¦ç¨ 1 å¯ç¨") private String status = CommonConstant.STATUS_1; lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EquipmentCategoryMapper.java
@@ -3,6 +3,7 @@ import java.util.List; import org.apache.ibatis.annotations.Param; import org.jeecg.common.api.vo.CommonGenericTree; import org.jeecg.modules.eam.entity.EquipmentCategory; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -13,5 +14,6 @@ * @Version: V1.0 */ public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> { public List<CommonGenericTree> getTreeByParentId(String parentId); } lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EquipmentCategoryMapper.xml
@@ -1,5 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.eam.mapper.EquipmentCategoryMapper"> <select id="getTreeByParentId" resultType="org.jeecg.common.api.vo.CommonGenericTree"> select t1.id as 'key', CONCAT(t1.num,'/',t1.name) title, t1.parent_id parentId, t1.name rField1, t1.num RField2 from mom_eam_equipment_category t1 where t1.del_flag = 0 and t1.parent_id = #{parentId} </select> </mapper> lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEquipmentCategoryService.java
@@ -1,10 +1,13 @@ package org.jeecg.modules.eam.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.jeecg.common.api.vo.CommonGenericTree; import org.jeecg.modules.eam.entity.EquipmentCategory; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; import java.util.Map; /** * @Description: mom_eam_equipment_category @@ -16,4 +19,8 @@ public List<CommonGenericTree> loadTree(); public List<CommonGenericTree> loadTreeByRecurrence(); public Page<EquipmentCategory> getAllChildren(Page<EquipmentCategory> page,EquipmentCategory equipmentCategory); } lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EquipmentCategoryServiceImpl.java
@@ -1,19 +1,31 @@ package org.jeecg.modules.eam.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.checkerframework.checker.units.qual.C; import org.jeecg.common.api.vo.CommonGenericTree; import org.jeecg.modules.eam.entity.EquipmentCategory; import org.jeecg.modules.eam.entity.FaultCause; import org.jeecg.modules.eam.mapper.EquipmentCategoryMapper; import org.jeecg.modules.eam.service.IEquipmentCategoryService; import org.jeecg.modules.system.entity.SysDict; import org.jeecg.modules.system.entity.SysDictItem; import org.jeecg.modules.system.mapper.SysDictItemMapper; import org.jeecg.modules.system.mapper.SysDictMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @Description: mom_eam_equipment_category @@ -23,6 +35,11 @@ */ @Service public class EquipmentCategoryServiceImpl extends ServiceImpl<EquipmentCategoryMapper, EquipmentCategory> implements IEquipmentCategoryService { @Autowired private SysDictItemMapper sysDictItemMapper; @Autowired private SysDictMapper sysDictMapper; @Override public List<CommonGenericTree> loadTree() { @@ -30,6 +47,8 @@ List<CommonGenericTree> commonGenericTrees = loadTree(equipmentCategoryList); return commonGenericTrees; } @SuppressWarnings("unchecked") public List<CommonGenericTree> loadTree(List<EquipmentCategory> EquipmentCategory) { @@ -219,5 +238,98 @@ } return list; } @Transactional(rollbackFor = {Exception.class}) public void initRoot(){ SysDict rootSysDict = sysDictMapper.selectOne(new QueryWrapper<SysDict>().eq("dict_code","equipment_category")); if(ObjectUtils.isNotNull(rootSysDict)){ List<SysDictItem> equipRoots = sysDictItemMapper.selectList(new QueryWrapper<SysDictItem>().eq("dict_id",rootSysDict.getId())); List<EquipmentCategory> roots = new ArrayList<>(); for(SysDictItem rootSysDictItem:equipRoots){ EquipmentCategory root = new EquipmentCategory(); root.setId("root-"+rootSysDictItem.getItemValue()); root.setNum(rootSysDictItem.getItemValue()); root.setName(rootSysDictItem.getItemText()); root.setEquipmentCategoryUda1(rootSysDictItem.getItemValue()); root.setParentId("-1"); root.setDelFlag(0); roots.add(root); } saveOrUpdateBatch(roots); } } @Override public List<CommonGenericTree> loadTreeByRecurrence() { CommonGenericTree commonGenericTree = new CommonGenericTree(); commonGenericTree.setKey("-1"); commonGenericTree.setTitle("设å¤åç±»"); List<CommonGenericTree> children = getChildren(commonGenericTree); if(children.size()==0){ commonGenericTree.setLeaf(true); } else { commonGenericTree.setLeaf(false); } commonGenericTree.setChildren(children); EquipmentCategory equipmentCategory = new EquipmentCategory(); equipmentCategory.setId("-1"); equipmentCategory.setName("设å¤åç±»"); equipmentCategory.setNum("root"); commonGenericTree.setEntity(equipmentCategory); List<CommonGenericTree> list = new ArrayList<>(); list.add(commonGenericTree); return list; } private List<CommonGenericTree> getChildren (CommonGenericTree commonGenericTree){ List<CommonGenericTree> children = baseMapper.getTreeByParentId(commonGenericTree.getKey()); for(CommonGenericTree child:children){ child.setEntity(baseMapper.selectById(child.getKey())); List<CommonGenericTree> superChild = getChildren(child); if(superChild.size()==0){ child.setLeaf(true); } else { child.setLeaf(false); } child.setChildren(superChild); } return children; } @Override public Page<EquipmentCategory> getAllChildren(Page<EquipmentCategory> page,EquipmentCategory equipmentCategory) { QueryWrapper<EquipmentCategory>queryWrapper = new QueryWrapper(); if(StringUtils.isNotBlank(equipmentCategory.getParentId())){ List<String> ids = new ArrayList<>(); ids.add(equipmentCategory.getParentId()); ids = getChildren(equipmentCategory.getParentId(),ids); if(ids.size()>1){ ids.remove(equipmentCategory.getParentId()); queryWrapper.in("id",ids); } else{ queryWrapper.eq("id","-1"); } } return baseMapper.selectPage(page,queryWrapper); } List<String> getChildren(String parentId,List<String> ids){ List<String> sons = new ArrayList<>(); for(String id:ids){ List<String> childrenIds = baseMapper .selectList(new QueryWrapper<EquipmentCategory>() .eq("parent_id",parentId).eq("del_flag",0)).stream() .map(EquipmentCategory::getId) .collect(Collectors.toList()); sons.addAll(getChildren(id,childrenIds)); sons.addAll(childrenIds); } ids.addAll(sons); return ids; } } lxzn-module-eam/src/main/java/org/jeecg/modules/eam/vo/EquipCategoryOutPortVo.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,27 @@ package org.jeecg.modules.eam.vo; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import org.jeecg.common.aspect.annotation.Dict; import org.jeecgframework.poi.excel.annotation.Excel; /** * @author lnl */ @Data @TableName("mom_eam_equipment_category") @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) public class EquipCategoryOutPortVo { @Excel(name = "设å¤åç±»ç¼ç ", width = 15) private String num; @Excel(name = "设å¤åç±»åç§°", width = 15) private String name; @Excel(name = "设å¤åç±»æ è¯", width = 15,dicCode = "equipment_category") private String equipmentCategoryUda1; @Excel(name = "ææ¯ç¶æé´å®å¨æ",dicCode = "appraisal_cycle",width = 15) private String equipmentCategoryUda2; }