“linengliang”
2023-08-29 14b1e801322db00b6b0d8dd059b9720adeb21bd8
设备分类
已添加1个文件
已修改7个文件
201 ■■■■■ 文件已修改
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentCategoryController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EquipmentCategory.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EquipmentCategoryMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EquipmentCategoryMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEquipmentCategoryService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EquipmentCategoryServiceImpl.java 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/vo/EquipCategoryOutPortVo.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;
}