Parcourir la source

添加分区管理

dxq il y a 4 mois
Parent
révision
e438a501fa

+ 105
- 0
sto/src/main/java/com/shinsoft/sto/controller/main/AreaController.java Voir le fichier

@@ -0,0 +1,105 @@
1
+package com.shinsoft.sto.controller.main;
2
+
3
+import com.shinsoft.sto.service.main.AreaService;
4
+import com.shinsoft.sto.service.main.WareService;
5
+import com.shinsoft.tools.JSONTools;
6
+import com.shinsoft.tools.model.common.ResponseCodeMsg;
7
+import com.shinsoft.tools.model.common.ResultJSON;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.web.bind.annotation.GetMapping;
10
+import org.springframework.web.bind.annotation.RequestMapping;
11
+import org.springframework.web.bind.annotation.RequestParam;
12
+import org.springframework.web.bind.annotation.RestController;
13
+
14
+import javax.servlet.http.HttpServletRequest;
15
+@RestController
16
+@RequestMapping("/Area")
17
+public class AreaController {
18
+
19
+    @Autowired
20
+    private AreaService areaService;
21
+
22
+    @Autowired
23
+    private WareService wareService;
24
+
25
+    ResultJSON resultJSON;
26
+
27
+    @GetMapping("/query")
28
+    public ResultJSON query(@RequestParam(defaultValue = "1") int page,
29
+                            @RequestParam(defaultValue = "50") int rows,
30
+                            @RequestParam(required = false) String wareId,
31
+                            HttpServletRequest request) {
32
+        try {
33
+            return areaService.query(page, rows, wareId);
34
+        } catch (Exception ex) {
35
+            ex.printStackTrace();
36
+            return JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
37
+        }
38
+    }
39
+
40
+    @RequestMapping(value = "/queryByPK")
41
+    public ResultJSON queryByPK(String id, HttpServletRequest request) {
42
+        try {
43
+            String userId = (String) request.getHeader("userId");
44
+            resultJSON = areaService.queryByPK(id);
45
+        } catch (Exception ex) {
46
+            ex.printStackTrace();
47
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
48
+        } finally {
49
+            return resultJSON;
50
+        }
51
+    }
52
+
53
+    @RequestMapping(value = "/save")
54
+    public ResultJSON save(String json, HttpServletRequest request) {
55
+        try {
56
+            String userId = (String) request.getHeader("userId");
57
+            resultJSON = areaService.save(userId, json);
58
+        } catch (Exception ex) {
59
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
60
+            ex.printStackTrace();
61
+        } finally {
62
+            return resultJSON;
63
+        }
64
+    }
65
+
66
+    @RequestMapping(value = "/remove")
67
+    public ResultJSON remove(String id, HttpServletRequest request) {
68
+        try {
69
+            String userId = (String) request.getHeader("userId");
70
+            resultJSON = areaService.remove(userId, id);
71
+        } catch (Exception ex) {
72
+            ex.printStackTrace();
73
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
74
+        } finally {
75
+            return resultJSON;
76
+        }
77
+    }
78
+
79
+    @RequestMapping(value = "/removeBatch")
80
+    public ResultJSON removeBatch(String ids, HttpServletRequest request) {
81
+        try {
82
+            String userId = (String) request.getHeader("userId");
83
+            resultJSON = areaService.removeBatch(userId, ids);
84
+        } catch (Exception ex) {
85
+            ex.printStackTrace();
86
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
87
+        } finally {
88
+            return resultJSON;
89
+        }
90
+    }
91
+
92
+    @RequestMapping(value = "/wareOptions")
93
+    public ResultJSON wareOptions(HttpServletRequest request) {
94
+        try {
95
+            String userId = (String) request.getHeader("userId");
96
+            resultJSON = wareService.getWareOptions();
97
+        } catch (Exception ex) {
98
+            ex.printStackTrace();
99
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
100
+        } finally {
101
+            return resultJSON;
102
+        }
103
+    }
104
+}
105
+

+ 12
- 0
sto/src/main/java/com/shinsoft/sto/controller/main/WareController.java Voir le fichier

@@ -90,5 +90,17 @@ public class WareController {
90 90
             return resultJSON;
91 91
         }
92 92
     }
93
+    @RequestMapping(value = "/options")
94
+    public ResultJSON options(HttpServletRequest request) {
95
+        try {
96
+            String userId = (String) request.getHeader("userId");
97
+            resultJSON = wareService.getWareOptions();
98
+        } catch (Exception ex) {
99
+            ex.printStackTrace();
100
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
101
+        } finally {
102
+            return resultJSON;
103
+        }
104
+    }
93 105
 }
94 106
 

+ 14
- 0
sto/src/main/java/com/shinsoft/sto/mapper/main/AreaMapper.java Voir le fichier

@@ -0,0 +1,14 @@
1
+package com.shinsoft.sto.mapper.main;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
+import com.shinsoft.sto.model.main.Area;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+public interface AreaMapper extends BaseMapper<Area> {
9
+
10
+
11
+    Page<Area> selectAreaPage(Page<Area> page,
12
+                              @Param("wareId") String wareId);
13
+}
14
+

+ 53
- 0
sto/src/main/java/com/shinsoft/sto/mapper/main/AreaMapper.xml Voir le fichier

@@ -0,0 +1,53 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.shinsoft.sto.mapper.main.AreaMapper">
4
+
5
+    <resultMap id="BaseResultMap" type="com.shinsoft.sto.model.main.Area">
6
+        <id column="id" property="id" jdbcType="VARCHAR"/>
7
+        <result column="process_instance_id" property="processInstanceId" jdbcType="VARCHAR"/>
8
+        <result column="process_instance_status" property="processInstanceStatus" jdbcType="VARCHAR"/>
9
+        <result column="add_id" property="addId" jdbcType="VARCHAR"/>
10
+        <result column="add_code" property="addCode" jdbcType="VARCHAR"/>
11
+        <result column="add_name" property="addName" jdbcType="VARCHAR"/>
12
+        <result column="add_dept_id" property="addDeptId" jdbcType="VARCHAR"/>
13
+        <result column="add_dept_code" property="addDeptCode" jdbcType="VARCHAR"/>
14
+        <result column="add_dept_name" property="addDeptName" jdbcType="VARCHAR"/>
15
+        <result column="add_time" property="addTime" jdbcType="TIMESTAMP"/>
16
+        <result column="modify_id" property="modifyId" jdbcType="VARCHAR"/>
17
+        <result column="modify_code" property="modifyCode" jdbcType="VARCHAR"/>
18
+        <result column="modify_name" property="modifyName" jdbcType="VARCHAR"/>
19
+        <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/>
20
+        <result column="cancel_id" property="cancelId" jdbcType="VARCHAR"/>
21
+        <result column="cancel_code" property="cancelCode" jdbcType="VARCHAR"/>
22
+        <result column="cancel_name" property="cancelName" jdbcType="VARCHAR"/>
23
+        <result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP"/>
24
+        <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR"/>
25
+        <result column="belong_id" property="belongId" jdbcType="VARCHAR"/>
26
+        <result column="ware_id" property="wareId" jdbcType="VARCHAR"/>
27
+        <result column="area_name" property="areaName" jdbcType="VARCHAR"/>
28
+        <result column="area_code" property="areaCode" jdbcType="VARCHAR"/>
29
+    </resultMap>
30
+
31
+    <sql id="Base_Column_List">
32
+        a.id, a.process_instance_id, a.process_instance_status, a.add_id, a.add_code, a.add_name, a.add_dept_id,
33
+        a.add_dept_code, a.add_dept_name, a.add_time, a.modify_id, a.modify_code, a.modify_name, a.modify_time,
34
+        a.cancel_id, a.cancel_code, a.cancel_name, a.cancel_time, a.cancel_flag, a.belong_id, a.ware_id,
35
+        a.area_name, a.area_code
36
+    </sql>
37
+
38
+    <select id="selectAreaPage" resultMap="BaseResultMap">
39
+        select
40
+        <include refid="Base_Column_List"/>,
41
+        w.ware_nm as ware_name
42
+        from T_MAIN_AREA a
43
+                 left join T_MAIN_WARE w on w.id = a.ware_id
44
+        where nvl(a.cancel_flag,'0') = '0'
45
+        <if test="wareId != null and wareId != ''">
46
+            and a.ware_id = #{wareId}
47
+        </if>
48
+        order by a.add_time desc
49
+    </select>
50
+
51
+</mapper>
52
+
53
+

+ 6
- 1
sto/src/main/java/com/shinsoft/sto/mapper/main/WareMapper.java Voir le fichier

@@ -1,9 +1,14 @@
1 1
 package com.shinsoft.sto.mapper.main;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.shinsoft.sto.model.common.selectModel;
4 5
 import com.shinsoft.sto.model.main.Ware;
6
+import org.apache.ibatis.annotations.Select;
7
+
8
+import java.util.List;
5 9
 
6 10
 public interface WareMapper extends BaseMapper<Ware> {
7 11
 
12
+    @Select("SELECT id AS value, ware_nm AS label FROM T_MAIN_WARE WHERE NVL(cancel_flag,'0') = '0' ORDER BY add_time DESC")
13
+    List<selectModel> selectWareOptions();
8 14
 }
9
-

+ 31
- 0
sto/src/main/java/com/shinsoft/sto/model/main/Area.java Voir le fichier

@@ -0,0 +1,31 @@
1
+package com.shinsoft.sto.model.main;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableField;
4
+import com.baomidou.mybatisplus.annotation.TableName;
5
+import com.shinsoft.generator.model.BaseModel;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Getter;
9
+import lombok.Setter;
10
+import lombok.experimental.Accessors;
11
+
12
+@Getter
13
+@Setter
14
+@Accessors(chain = true)
15
+@TableName("T_MAIN_AREA")
16
+@ApiModel(value = "库房分区", description = "库房分区信息表")
17
+public class Area extends BaseModel {
18
+
19
+    @ApiModelProperty("所属库房ID")
20
+    private String wareId;
21
+    @TableField(exist = false)
22
+    @ApiModelProperty("所属库房")
23
+    private String wareName;
24
+
25
+    @ApiModelProperty("分区名称")
26
+    private String areaName;
27
+
28
+    @ApiModelProperty("分区编码")
29
+    private String areaCode;
30
+}
31
+

+ 96
- 0
sto/src/main/java/com/shinsoft/sto/service/impl/main/AreaServiceImp.java Voir le fichier

@@ -0,0 +1,96 @@
1
+package com.shinsoft.sto.service.impl.main;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.alibaba.fastjson.TypeReference;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import com.shinsoft.sto.mapper.main.AreaMapper;
8
+import com.shinsoft.sto.model.main.Area;
9
+import com.shinsoft.sto.service.main.AreaService;
10
+import com.shinsoft.tools.JSONTools;
11
+import com.shinsoft.tools.model.common.ResultJSON;
12
+import org.apache.commons.lang3.StringUtils;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.stereotype.Service;
15
+
16
+import java.util.Date;
17
+import java.util.List;
18
+
19
+/**
20
+ * <p>
21
+ * 库房分区 服务实现类
22
+ * </p>
23
+ */
24
+@Service
25
+public class AreaServiceImp extends ServiceImpl<AreaMapper, Area> implements AreaService {
26
+
27
+    @Autowired
28
+    private AreaMapper areaMapper;
29
+
30
+    ResultJSON resultJSON;
31
+
32
+    @Override
33
+    public ResultJSON query(int page, int rows, String wareId) {
34
+        Page<Area> areaPage = new Page<>(page, rows);
35
+        Page<Area> list = areaMapper.selectAreaPage(areaPage, wareId);
36
+        resultJSON = JSONTools.toResultJSON(list);
37
+        return resultJSON;
38
+    }
39
+
40
+    @Override
41
+    public ResultJSON queryByPK(String id) {
42
+        Area area = areaMapper.selectById(id);
43
+        resultJSON = JSONTools.toResultJSON(area);
44
+        return resultJSON;
45
+    }
46
+
47
+    @Override
48
+    public ResultJSON save(String userId, String json) {
49
+        Date date = new Date();
50
+        Area area = JSON.parseObject(json, new TypeReference<Area>() {
51
+        });
52
+        if (StringUtils.isEmpty(area.getId())) {
53
+            area.setCancelFlag("0");
54
+            area.setAddId(userId);
55
+            area.setAddTime(date);
56
+            areaMapper.insert(area);
57
+        } else {
58
+            area.setModifyId(userId);
59
+            area.setModifyTime(date);
60
+            areaMapper.updateById(area);
61
+        }
62
+
63
+        resultJSON = JSONTools.toResultJSON(area);
64
+        return resultJSON;
65
+    }
66
+
67
+    @Override
68
+    public ResultJSON remove(String userId, String id) {
69
+        Date date = new Date();
70
+        Area area = areaMapper.selectById(id);
71
+        area.setCancelFlag("1");
72
+        area.setModifyId(userId);
73
+        area.setModifyTime(date);
74
+        areaMapper.updateById(area);
75
+        resultJSON = JSONTools.toResultJSON("");
76
+        return resultJSON;
77
+    }
78
+
79
+    @Override
80
+    public ResultJSON removeBatch(String userId, String ids) {
81
+        Date date = new Date();
82
+        List<String> list = JSON.parseObject(ids, new TypeReference<List<String>>() {
83
+        });
84
+        Area area;
85
+        for (String id : list) {
86
+            area = areaMapper.selectById(id);
87
+            area.setCancelFlag("1");
88
+            area.setModifyId(userId);
89
+            area.setModifyTime(date);
90
+            areaMapper.updateById(area);
91
+        }
92
+        resultJSON = JSONTools.toResultJSON("");
93
+        return resultJSON;
94
+    }
95
+}
96
+

+ 8
- 0
sto/src/main/java/com/shinsoft/sto/service/impl/main/WareServiceImp.java Voir le fichier

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
7 7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
8 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9 9
 import com.shinsoft.sto.mapper.main.WareMapper;
10
+import com.shinsoft.sto.model.common.selectModel;
10 11
 import com.shinsoft.sto.model.main.Ware;
11 12
 import com.shinsoft.sto.service.main.WareService;
12 13
 import com.shinsoft.tools.JSONTools;
@@ -113,5 +114,12 @@ public class WareServiceImp extends ServiceImpl<WareMapper, Ware> implements War
113 114
         resultJSON = JSONTools.toResultJSON("");
114 115
         return resultJSON;
115 116
     }
117
+
118
+    @Override
119
+    public ResultJSON getWareOptions() {
120
+        List<selectModel> options = wareMapper.selectWareOptions();
121
+        resultJSON = JSONTools.toResultJSON(options);
122
+        return resultJSON;
123
+    }
116 124
 }
117 125
 

+ 25
- 0
sto/src/main/java/com/shinsoft/sto/service/main/AreaService.java Voir le fichier

@@ -0,0 +1,25 @@
1
+package com.shinsoft.sto.service.main;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.shinsoft.sto.model.main.Area;
5
+import com.shinsoft.tools.model.common.ResultJSON;
6
+
7
+/**
8
+ * <p>
9
+ * 库房分区 服务类
10
+ * </p>
11
+ */
12
+public interface AreaService extends IService<Area> {
13
+
14
+    ResultJSON query(int page, int rows, String wareId);
15
+
16
+    ResultJSON queryByPK(String id);
17
+
18
+    ResultJSON save(String userId, String json);
19
+
20
+    ResultJSON remove(String userId, String id);
21
+
22
+    ResultJSON removeBatch(String userId, String ids);
23
+}
24
+
25
+

+ 2
- 0
sto/src/main/java/com/shinsoft/sto/service/main/WareService.java Voir le fichier

@@ -25,5 +25,7 @@ public interface WareService extends IService<Ware> {
25 25
     ResultJSON remove(String userId, String id);
26 26
 
27 27
     ResultJSON removeBatch(String userId, String ids);
28
+
29
+    ResultJSON getWareOptions();
28 30
 }
29 31
 

Loading…
Annuler
Enregistrer