liyuanyuan 1 год назад
Родитель
Сommit
cf9d7bd8e7

+ 2 - 0
.gitignore

@@ -467,3 +467,5 @@ hjzx-api/target/classes/api/controller/system/CustomerController.class
467 467
 hjzx-api/target/classes/api/controller/system/ConfigController.class
468 468
 hjzx-util/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
469 469
 hjzx-entity/target/classes/api/entity/database/system/Application.class
470
+*.log
471
+/target

+ 175 - 0
hjzx-api/src/main/java/api/controller/system/MainProblemController.java

@@ -0,0 +1,175 @@
1
+package api.controller.system;
2
+
3
+import api.entity.database.system.WorkOrderType;
4
+import api.entity.view.system.WorkOrderTypeView;
5
+import api.util.annotation.Anonymous;
6
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
7
+import com.baomidou.mybatisplus.core.metadata.IPage;
8
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
9
+import api.controller.BaseController;
10
+import api.entity.database.system.MainProblem;
11
+import api.entity.input.PageInput;
12
+import api.model.AjaxResult;
13
+import api.service.system.IMainProblemService;
14
+import api.util.annotation.Log;
15
+import api.util.enums.BusinessType;
16
+import api.util.helper.StringHelper;
17
+import io.swagger.annotations.Api;
18
+import io.swagger.annotations.ApiOperation;
19
+import lombok.var;
20
+import org.springframework.beans.factory.annotation.Autowired;
21
+import org.springframework.web.bind.annotation.*;
22
+import java.util.Arrays;
23
+import java.util.Date;
24
+import java.util.List;
25
+
26
+@Api(value = "main_problem",tags = "main_problem")
27
+@RestController
28
+@RequestMapping("/system/mainproblem")
29
+public class MainProblemController extends BaseController {
30
+    @Autowired
31
+    private IMainProblemService mainproblemService;
32
+
33
+    @ApiOperation("列表")
34
+    @Log(title = "查询main_problem列表",businessType = BusinessType.QUERY)
35
+    @GetMapping
36
+    public AjaxResult getList(MainProblem input, PageInput pageInput) {
37
+        LambdaQueryWrapper<MainProblem> qw = new LambdaQueryWrapper();
38
+        qw.eq(input.getId() != null && input.getId() > 0, MainProblem::getId, input.getId());
39
+        qw.eq(input.getParentId() != null && input.getParentId() > 0, MainProblem::getParentId, input.getParentId());
40
+        qw.like(!StringHelper.isEmpty(input.getTypeCode()), MainProblem::getTypeCode, input.getTypeCode());
41
+        qw.like(!StringHelper.isEmpty(input.getAncestors()), MainProblem::getAncestors, input.getAncestors());
42
+        qw.like(!StringHelper.isEmpty(input.getTypeName()), MainProblem::getTypeName, input.getTypeName());
43
+        qw.eq(input.getTypeOrder() != null && input.getTypeOrder() > 0, MainProblem::getTypeOrder, input.getTypeOrder());
44
+        qw.eq(input.getCreateTime() != null , MainProblem::getCreateTime, input.getCreateTime());
45
+        qw.eq(input.getIsDelete() != null && input.getIsDelete() > 0, MainProblem::getIsDelete, input.getIsDelete());
46
+        qw.like(!StringHelper.isEmpty(input.getCreateBy()), MainProblem::getCreateBy, input.getCreateBy());
47
+        qw.eq(input.getCategory() != null && input.getCategory() > 0, MainProblem::getCategory, input.getCategory());
48
+        qw.like(!StringHelper.isEmpty(input.getSetButton()), MainProblem::getSetButton, input.getSetButton());
49
+        qw.like(!StringHelper.isEmpty(input.getAllTypeName()), MainProblem::getAllTypeName, input.getAllTypeName());
50
+        Page<MainProblem> page = GetPage(pageInput);
51
+        if (page != null) {
52
+            IPage<MainProblem> iPage = mainproblemService.getListPage(page, qw);
53
+            return Success("成功", iPage.getRecords(), iPage.getTotal());
54
+        } else {
55
+            return Success("成功", mainproblemService.getList(qw));
56
+        }
57
+    }
58
+
59
+    @ApiOperation("详情")
60
+    @Log(title = "查询main_problem详情",businessType = BusinessType.QUERY)
61
+    @GetMapping("/{id}")
62
+    public AjaxResult getInfo(@PathVariable long id) {
63
+        return Success("成功", mainproblemService.getEntity(id));
64
+    }
65
+
66
+    @ApiOperation("新增")
67
+    @Log(title = "新增main_problem",businessType = BusinessType.INSERT)
68
+    @PostMapping
69
+    public AjaxResult add(@RequestBody MainProblem input) {
70
+//        boolean result = mainproblemService.insert(input);
71
+//        if (result) {
72
+//            return Success("成功");
73
+//        } else {
74
+//            return Error("新增失败");
75
+//        }
76
+        Date currentDate = new Date(System.currentTimeMillis());
77
+        if (StringHelper.isEmpty(input.getTypeName()))
78
+            return Error("请输入名称");
79
+        if (StringHelper.isEmpty(input.getTypeCode()))
80
+            return Error("请输入类型编码");
81
+        if (input.getCategory() == null )
82
+        {
83
+            input.setCategory(0L);
84
+        }
85
+        if (input.getParentId()!=null&&input.getParentId()>0)
86
+        {
87
+            var model=mainproblemService.getEntity(input.getParentId());
88
+            if (model!=null)
89
+            {
90
+                input.setAncestors(model.getAncestors()+","+model.getId());
91
+
92
+                input.setAllTypeName(model.getAllTypeName()+"/"+input.getTypeName());
93
+            }
94
+            else
95
+            {
96
+                return Error("该父级分类不存在");
97
+            }
98
+        }
99
+        else
100
+        {
101
+            input.setAllTypeName(input.getTypeName());
102
+            input.setAncestors("0");
103
+            input.setParentId(0L);
104
+        }
105
+
106
+        input.setIsDelete(0L);
107
+        input.setCreateTime(currentDate);
108
+        input.setCreateBy(CurrentUser().getUserId().toString());
109
+        boolean result = mainproblemService.insert(input);
110
+        if (result) {
111
+            return Success("成功");
112
+        } else {
113
+            return Error("新增失败");
114
+        }
115
+    }
116
+
117
+    @ApiOperation("编辑")
118
+    @Log(title = "编辑main_problem",businessType = BusinessType.UPDATE)
119
+    @PutMapping
120
+    public AjaxResult edit(@RequestBody MainProblem input)  {
121
+        boolean result = mainproblemService.update(input);
122
+        if (result) {
123
+            return Success("成功");
124
+        } else {
125
+            return Error("修改失败");
126
+        }
127
+    }
128
+
129
+    @ApiOperation("删除")
130
+    @Log(title = "删除main_problem",businessType = BusinessType.DELETE)
131
+    @DeleteMapping("/{ids}")
132
+    public AjaxResult delete(@PathVariable Long[] ids)  {
133
+        boolean result = mainproblemService.delete(Arrays.asList(ids));
134
+        if (result) {
135
+            return Success("成功");
136
+        } else {
137
+            return Error("删除失败");
138
+        }
139
+    }
140
+    @GetMapping("/treeselect")
141
+    @Anonymous
142
+    public AjaxResult treeselect(MainProblem input) {
143
+        LambdaQueryWrapper<MainProblem> qw = new LambdaQueryWrapper<>();
144
+        qw.eq(MainProblem::getIsDelete, 0);
145
+        if (input.getCategory() != null )
146
+        {
147
+            qw.eq(MainProblem::getCategory, input.getCategory());
148
+        }
149
+        else
150
+        {
151
+            qw.eq(MainProblem::getCategory, 0);
152
+        }
153
+
154
+        qw.orderByDesc(MainProblem::getTypeOrder);
155
+        List<MainProblem> menus = mainproblemService.getList(qw);
156
+        return Success("获取菜单下拉树列表成功", mainproblemService.buildMenuTreeSelect(menus));
157
+    }
158
+    @GetMapping("/getTreeselectById")
159
+    public AjaxResult getTreeselectById(long id) {
160
+
161
+        LambdaQueryWrapper<MainProblem> qw = new LambdaQueryWrapper<>();
162
+        qw.eq(MainProblem::getIsDelete, 0);
163
+        qw.like(MainProblem::getAncestors,','+String.valueOf(id));
164
+        qw.orderByDesc(MainProblem::getTypeOrder);
165
+        List<MainProblem> menus = mainproblemService.getList(qw);
166
+        return Success("获取菜单下拉树列表成功", mainproblemService.buildMenuTreeSelect(menus));
167
+    }
168
+    @GetMapping("/GetWorkroderTypeView")
169
+    public AjaxResult GetWorkroderTypeView(long id) {
170
+
171
+        List<MainProblem> WorkroderType = mainproblemService.selectMainProblem(id);
172
+        return Success("获取菜单下拉树列表成功",WorkroderType);
173
+    }
174
+
175
+}

+ 59 - 0
hjzx-entity/src/main/java/api/entity/database/system/MainProblem.java

@@ -0,0 +1,59 @@
1
+package api.entity.database.system;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import com.baomidou.mybatisplus.annotation.TableName;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+
11
+import java.util.ArrayList;
12
+import java.util.Date;
13
+import java.util.List;
14
+
15
+/** main_problem */
16
+@ApiModel(value = "MainProblem", description = "main_problem实体")
17
+@Data
18
+@TableName("main_problem")
19
+public class MainProblem {
20
+    /** id */
21
+    @ApiModelProperty("id")
22
+    @TableId(type = IdType.AUTO)
23
+    private Long id;
24
+    /** parent_id */
25
+    @ApiModelProperty("parent_id")
26
+    private Long parentId;
27
+    /** type_code */
28
+    @ApiModelProperty("type_code")
29
+    private String typeCode;
30
+    /** ancestors */
31
+    @ApiModelProperty("ancestors")
32
+    private String ancestors;
33
+    /** type_name */
34
+    @ApiModelProperty("type_name")
35
+    private String typeName;
36
+    /** type_order */
37
+    @ApiModelProperty("type_order")
38
+    private Long typeOrder;
39
+    /** create_time */
40
+    @ApiModelProperty("create_time")
41
+    private Date createTime;
42
+    /** is_delete */
43
+    @ApiModelProperty("is_delete")
44
+    private Long isDelete;
45
+    /** create_by */
46
+    @ApiModelProperty("create_by")
47
+    private String createBy;
48
+    /** category */
49
+    @ApiModelProperty("category")
50
+    private Long category;
51
+    /** set_button */
52
+    @ApiModelProperty("set_button")
53
+    private String setButton;
54
+    /** all_type_name */
55
+    @ApiModelProperty("all_type_name")
56
+    private String allTypeName;
57
+    @TableField(exist = false)
58
+    private List<MainProblem> children = new ArrayList<MainProblem>();
59
+}

+ 8 - 0
hjzx-entity/src/main/java/api/entity/view/TreeSelect.java

@@ -2,6 +2,7 @@ package api.entity.view;
2 2
 
3 3
 
4 4
 import api.entity.database.system.Dept;
5
+import api.entity.database.system.MainProblem;
5 6
 import api.entity.database.system.Menu;
6 7
 import api.entity.database.system.WorkOrderType;
7 8
 import com.fasterxml.jackson.annotation.JsonInclude;
@@ -62,6 +63,13 @@ public class TreeSelect implements Serializable
62 63
         this.children=Type.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
63 64
 
64 65
     }
66
+    public TreeSelect(MainProblem Type) {
67
+        this.id=Type.getId();
68
+        this.label=Type.getTypeName();
69
+        this.code=Type.getTypeCode();
70
+        this.children=Type.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
71
+
72
+    }
65 73
 
66 74
 
67 75
 }

+ 15 - 0
hjzx-mapper/src/main/java/api/mapper/system/MainProblemMapper.java

@@ -0,0 +1,15 @@
1
+package api.mapper.system;
2
+
3
+import api.entity.view.system.WorkOrderTypeView;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import api.entity.database.system.MainProblem;
6
+import org.apache.ibatis.annotations.Mapper;
7
+
8
+import java.util.List;
9
+
10
+@Mapper
11
+public interface MainProblemMapper extends BaseMapper<MainProblem> {
12
+    public List<MainProblem> selectMainProblem(long id);
13
+
14
+    public   MainProblem selectMainProblemById(long id)  ;
15
+}

+ 32 - 0
hjzx-mapper/src/main/resources/mapper/system/MainProblemMapper.xml

@@ -0,0 +1,32 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper
3
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
+<mapper namespace="api.mapper.system.MainProblemMapper">
6
+
7
+
8
+
9
+
10
+    <select id="selectWorkroderType" resultType="Long" resultMap="api.entity.database.system.MainProblem">
11
+        select *
12
+--         (SELECT
13
+--         GROUP_CONCAT(b.`type_name` SEPARATOR '/')   from workorder_type  b  where FIND_IN_SET(b.id,CONCAT( a.ancestors,',',a.id))  )   ancestorsName
14
+       FROM  workorder_type a where a.is_delete=0
15
+        <if test="id >0 ">
16
+            and  a.id=#{id}
17
+        </if>
18
+        order by a.id
19
+    </select>
20
+
21
+    <select id="selectWorkroderTypeById" resultType="Long" resultMap="api.entity.database.system.MainProblem">
22
+        select *
23
+--                ,
24
+--         (SELECT
25
+--         GROUP_CONCAT(b.`type_name` SEPARATOR '/')   from workorder_type  b  where FIND_IN_SET(b.id,CONCAT( a.ancestors,',',a.id))  )   ancestorsName
26
+        FROM  workorder_type a where a.is_delete=0  and  a.id=#{id}
27
+        order by a.id
28
+    </select>
29
+
30
+
31
+
32
+</mapper> 

+ 20 - 0
hjzx-service/src/main/java/api/service/system/IMainProblemService.java

@@ -0,0 +1,20 @@
1
+package api.service.system;
2
+
3
+import api.entity.database.system.MainProblem;
4
+import api.entity.database.system.WorkOrderType;
5
+import api.entity.view.TreeSelect;
6
+import api.entity.view.system.WorkOrderTypeView;
7
+import api.service.IBaseService;
8
+
9
+import java.util.List;
10
+
11
+public interface IMainProblemService extends IBaseService<MainProblem> {
12
+    public List<TreeSelect> buildMenuTreeSelect(List<MainProblem> menus);
13
+
14
+    public List<MainProblem> buildMenuTree(List<MainProblem> menus);
15
+
16
+
17
+    public List<MainProblem> selectMainProblem(long id);
18
+
19
+    public MainProblem selectMainProblemById(long id);
20
+}

+ 98 - 0
hjzx-service/src/main/java/api/service/system/impl/MainProblemServiceImpl.java

@@ -0,0 +1,98 @@
1
+package api.service.system.impl;
2
+
3
+import api.entity.database.system.MainProblem;
4
+import api.entity.database.system.WorkOrderType;
5
+import api.entity.view.TreeSelect;
6
+import api.entity.view.system.WorkOrderTypeView;
7
+import api.mapper.system.MainProblemMapper;
8
+import api.mapper.system.WorkOrderTypeMapper;
9
+import api.service.system.IMainProblemService;
10
+import api.service.BaseServiceImpl;
11
+import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.stereotype.Service;
13
+import org.springframework.transaction.annotation.Transactional;
14
+
15
+import java.util.ArrayList;
16
+import java.util.Iterator;
17
+import java.util.List;
18
+import java.util.stream.Collectors;
19
+
20
+@Transactional
21
+@Service
22
+public class MainProblemServiceImpl extends BaseServiceImpl<MainProblemMapper, MainProblem> implements IMainProblemService{
23
+    public MainProblemServiceImpl(){ super(false); }
24
+    @Autowired
25
+    private MainProblemMapper mainProblemMapper;
26
+
27
+    @Override
28
+    public List<MainProblem> selectMainProblem(long id)
29
+    {
30
+        return mainProblemMapper.selectMainProblem(id);
31
+    }
32
+
33
+    @Override
34
+    public MainProblem selectMainProblemById(long id)
35
+    {
36
+        return mainProblemMapper.selectMainProblemById(id);
37
+    }
38
+    @Override
39
+    public List<TreeSelect> buildMenuTreeSelect(List<MainProblem> Type) {
40
+        List<MainProblem> menuTrees = buildMenuTree(Type);
41
+        return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
42
+    }
43
+
44
+    @Override
45
+    public List<MainProblem> buildMenuTree(List<MainProblem> Type) {
46
+        List<MainProblem> returnList = new ArrayList<MainProblem>();
47
+        List<Long> tempList = Type.stream().map(MainProblem::getId).collect(Collectors.toList());
48
+        for (Iterator<MainProblem> iterator = Type.iterator(); iterator.hasNext(); ) {
49
+            MainProblem menu = (MainProblem) iterator.next();
50
+            // 如果是顶级节点, 遍历该父节点的所有子节点
51
+            if (!tempList.contains(menu.getParentId())) {
52
+                recursionFn(Type, menu);
53
+                returnList.add(menu);
54
+            }
55
+        }
56
+        if (returnList.isEmpty()) {
57
+            returnList = Type;
58
+        }
59
+        return returnList;
60
+    }
61
+    /**
62
+     * 递归列表
63
+     *
64
+     * @param list 分类表
65
+     * @param t    子节点
66
+     */
67
+    private void recursionFn(List<MainProblem> list, MainProblem t) {
68
+        // 得到子节点列表
69
+        List<MainProblem> childList = getChildList(list, t);
70
+        t.setChildren(childList);
71
+        for (MainProblem tChild : childList) {
72
+            if (hasChild(list, tChild)) {
73
+                recursionFn(list, tChild);
74
+            }
75
+        }
76
+    }
77
+    /**
78
+     * 判断是否有子节点
79
+     */
80
+    private boolean hasChild(List<MainProblem> list, MainProblem t) {
81
+        return getChildList(list, t).size() > 0;
82
+    }
83
+
84
+    /**
85
+     * 得到子节点列表
86
+     */
87
+    private List<MainProblem> getChildList(List<MainProblem> list, MainProblem t) {
88
+        List<MainProblem> tlist = new ArrayList<MainProblem>();
89
+        Iterator<MainProblem> it = list.iterator();
90
+        while (it.hasNext()) {
91
+            MainProblem n = (MainProblem) it.next();
92
+            if (n.getParentId().longValue() == t.getId().longValue()) {
93
+                tlist.add(n);
94
+            }
95
+        }
96
+        return tlist;
97
+    }
98
+}