qushaowei
2023-11-11 2d20926b12a4fe446d4ede3e9039dc676332573e
中心 工区 修改
已修改5个文件
222 ■■■■■ 文件已修改
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/AreaController.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/Area.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IAreaService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/AreaServiceImpl.java 141 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-start/src/main/java/org/jeecg/JeecgSystemApplication.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/AreaController.java
@@ -7,12 +7,16 @@
import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.poi.hssf.record.DVALRecord;
import org.jeecg.common.api.vo.CommonGenericTree;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.eam.entity.Area;
import org.jeecg.modules.eam.entity.FaultCause;
import org.jeecg.modules.eam.entity.Team;
import org.jeecg.modules.eam.service.IAreaService;
import org.jeecg.modules.eam.service.ITeamService;
@@ -37,7 +41,7 @@
@Api(tags = "车间 前端控制器")
@RestController
@RequestMapping("/base/area")
public class AreaController {
public class AreaController extends JeecgController<Area,IAreaService> {
    @Autowired
    private IAreaService areaService;
@@ -77,6 +81,18 @@
    @ApiOperation(value = "车间-新增", notes = "车间-新增")
    @PostMapping("/add")
    public Result<?> add(@RequestBody Area area) {
        String parentId = area.getParentId();
        if("-1".equals(parentId)){
            area.setType("1");
        }else{
            Area nextArea = areaService.getById(parentId);
            String type = nextArea.getType();
            if("1".equals(type)){
                area.setType("2");
            }else{
                area.setType("3");
            }
        }
        area.setStatus(CommonConstant.STATUS_1);
        areaService.save(area);
        return Result.ok("新增成功");
@@ -120,4 +136,46 @@
        return Result.ok("更新成功!");
    }
    @GetMapping(value = "/getAlllist")
    public Result<?> getAlllist(Area area, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
//        QueryWrapper<Area> queryWrapper = QueryGenerator.initQueryWrapper(area, req.getParameterMap());
        QueryWrapper<Area> queryWrapper = Wrappers.query();
        Page<Area> page = new Page<Area>(pageNo, pageSize);
        String num = area.getNum();
        String name = area.getName();
        String parentId = area.getParentId();
        if(StringUtils.isNotBlank(parentId)){
            queryWrapper.eq("parent_id", parentId);
        }else{
            queryWrapper.eq("parent_id", "-1");
        }
        if(StringUtils.isNotBlank(num)){
            queryWrapper.like("num", num);
        }
        if(StringUtils.isNotBlank(name)){
            queryWrapper.like("name", name);
        }
        IPage<Area> pageList = areaService.page(page, queryWrapper);
        List<Area> records = pageList.getRecords();
        for (Area record : records) {
            String id = record.getId();
            List<Area> areas = areaService.lambdaQuery().eq(Area::getParentId, id).eq(Area::getDelFlag, "0").list();
            record.setNextAreas(areas);
        }
        return Result.OK(pageList);
    }
    /**
     * @MethodName: loadTree
     * @Description: 故障原因 树
     */
    @GetMapping("/loadTree")
    public Result<?> loadTree(HttpServletRequest httpServletRequest) {
        List<CommonGenericTree> list = areaService.loadTree();
        return Result.ok(list);
    }
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/Area.java
@@ -17,6 +17,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
@Data
@EqualsAndHashCode(callSuper = false)
@@ -54,8 +55,20 @@
    @TableLogic
    private Integer delFlag = CommonConstant.DEL_FLAG_0;
    /**父id*/
    @Excel(name = "父id", width = 15)
    @ApiModelProperty(value = "父id")
    private String parentId;
    /**1中心,2工区,3工段*/
    @ApiModelProperty(value = "1中心,2工区,3工段")
    private String type;
    @TableField(exist = false)
    private String teamNames;
    @TableField(exist = false)
    private List<Area> nextAreas;
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IAreaService.java
@@ -1,7 +1,11 @@
package org.jeecg.modules.eam.service;
import org.jeecg.common.api.vo.CommonGenericTree;
import org.jeecg.modules.eam.entity.Area;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
 * 
 * @ClassName: IAreaService
@@ -16,5 +20,7 @@
    boolean removeBySiteIds(String[] siteIds);
    
    boolean activeBySiteId(String siteId, String status);
    public List<CommonGenericTree> loadTree();
    
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/AreaServiceImpl.java
@@ -1,11 +1,13 @@
package org.jeecg.modules.eam.service.impl;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.api.vo.CommonGenericTree;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.eam.entity.Area;
import org.jeecg.modules.eam.entity.FaultCause;
import org.jeecg.modules.eam.mapper.AreaMapper;
import org.jeecg.modules.eam.service.IAreaService;
import org.jeecg.modules.eam.service.IProductionLineService;
@@ -71,5 +73,138 @@
        updateWrapper.set(Area::getStatus, status).eq(Area::getSiteId, siteId);
        return super.update(updateWrapper);
    }
    @Override
    public List<CommonGenericTree> loadTree() {
        List<Area> areaList = this.lambdaQuery().eq(Area::getDelFlag, "0").list();
        List<CommonGenericTree> commonGenericTrees = loadTree(areaList);
        return commonGenericTrees;
    }
    @SuppressWarnings("unchecked")
    public List<CommonGenericTree> loadTree(List<Area> areaList) {
        @SuppressWarnings("unused")
        Area area = new Area();
        List<CommonGenericTree> list = new ArrayList<>();
        Map<String, CommonGenericTree> map = new HashMap<>();
        Map<String, CommonGenericTree> map2 = new HashMap<>();
        Map<String, CommonGenericTree> map3 = new HashMap<>();
//        Map<String, CommonGenericTree> map4 = new HashMap<>();
//        Map<String, CommonGenericTree> map5 = new HashMap<>();
//        Map<String, CommonGenericTree> map6 = new HashMap<>();
//        Map<String, CommonGenericTree> map7 = new HashMap<>();
        CommonGenericTree<Area> node = new CommonGenericTree<>();
        node.setKey("-1");
        node.setValue("-1");
        node.setTitle("中国航发");
        node.setRField1("-1");
        node.setRField2("中国航发");
        node.setDisabled(false);
        node.setEntity(new Area());
        list.add(node);
        if (CollectionUtils.isNotEmpty(list)) {
            CommonGenericTree<Area> pcNode;
            for (Area ar : areaList) {
                if (ar.getParentId().equals("-1")) {
                    pcNode = new CommonGenericTree<>();
                    pcNode.setKey(ar.getId());
//                    pcNode.setTitle(ar.getNum() + "/" + ar.getName());
                    pcNode.setTitle(ar.getName());
                    pcNode.setParentId(node.getKey());
                    pcNode.setIcon("");
                    pcNode.setType(0);
                    pcNode.setValue(ar.getId());
                    pcNode.setDisabled(false);
                    pcNode.setRField1(ar.getNum());
                    pcNode.setRField2(ar.getName());
                    pcNode.setEntity(ar);
                    node.addChildren(pcNode);
                    map.put(ar.getId(), pcNode);
                }
            }
            CommonGenericTree<Area> childNode;
            for (Area ar : areaList) {
                if (map.containsKey(ar.getParentId())) {
                    pcNode = map.get(ar.getParentId());
                    childNode = new CommonGenericTree<>();
                    childNode.setKey(ar.getId());
                    childNode.setTitle(ar.getName());
                    childNode.setParentId(ar.getParentId());
                    childNode.setIcon("");
                    childNode.setType(0);
                    childNode.setValue(ar.getId());
                    childNode.setDisabled(false);
                    childNode.setRField1(ar.getNum());
                    childNode.setRField2(ar.getName());
                    childNode.setEntity(ar);
                    pcNode.addChildren(childNode);
                    map2.put(ar.getId(), childNode);
                }
            }
            if(map2.size()>0){
                CommonGenericTree<Area> child2Node;
                for (Area ar : areaList) {
                    if (map2.containsKey(ar.getParentId())) {
                        pcNode = map2.get(ar.getParentId());
                        child2Node = new CommonGenericTree<>();
                        child2Node.setKey(ar.getId());
                        child2Node.setTitle(ar.getName());
                        child2Node.setParentId(ar.getParentId());
                        child2Node.setIcon("");
                        child2Node.setType(0);
                        child2Node.setValue(ar.getId());
                        child2Node.setDisabled(false);
                        child2Node.setRField1(ar.getNum());
                        child2Node.setRField2(ar.getName());
                        child2Node.setEntity(ar);
                        pcNode.addChildren(child2Node);
                        map3.put(ar.getId(), child2Node);
                    }
                }
                if(map3.size()>0){
                    CommonGenericTree<Area> child3Node;
                    for (Area ar : areaList) {
                        if (map3.containsKey(ar.getParentId())) {
                            pcNode = map3.get(ar.getParentId());
                            child3Node = new CommonGenericTree<>();
                            child3Node.setKey(ar.getId());
                            child3Node.setTitle(ar.getName());
                            child3Node.setParentId(ar.getParentId());
                            child3Node.setIcon("");
                            child3Node.setType(0);
                            child3Node.setValue(ar.getId());
                            child3Node.setDisabled(false);
                            child3Node.setRField1(ar.getNum());
                            child3Node.setRField2(ar.getName());
                            child3Node.setEntity(ar);
//                            pcNode.addChildren(child3Node);
//                            map4.put(cause.getId(), child3Node);
                        }
                    }
//                    if(map4.size()>0){
//                        CommonGenericTree<FaultCause> child4Node;
//                        for (FaultCause cause : faultCauseList) {
//                            if (map4.containsKey(cause.getParentId())) {
//                                pcNode = map4.get(cause.getParentId());
//                                child4Node = new CommonGenericTree<>();
//                                child4Node.setKey(cause.getId());
//                                child4Node.setTitle(cause.getNum() + "/" + cause.getName());
//                                child4Node.setParentId(cause.getParentId());
//                                child4Node.setIcon("");
//                                child4Node.setType(0);
//                                child4Node.setValue(cause.getId());
//                                child4Node.setDisabled(false);
//                                child4Node.setRField1(cause.getNum());
//                                child4Node.setRField2(cause.getName());
//                                child4Node.setEntity(cause);
//                                pcNode.addChildren(child4Node);
//                                map5.put(cause.getId(), child4Node);
//                            }
//                        }
//                    }
                }
            }
        }
        return list;
    }
}
lxzn-module-system/lxzn-system-start/src/main/java/org/jeecg/JeecgSystemApplication.java
@@ -27,7 +27,7 @@
    }
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(JeecgSystemApplication.class, args);
            ConfigurableApplicationContext application = SpringApplication.run(JeecgSystemApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");