dxq 3 недель назад
Родитель
Сommit
3a8716b3f2

+ 94
- 0
sto/src/main/java/com/shinsoft/sto/controller/main/WareController.java Просмотреть файл

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

+ 9
- 0
sto/src/main/java/com/shinsoft/sto/mapper/main/WareMapper.java Просмотреть файл

@@ -0,0 +1,9 @@
1
+package com.shinsoft.sto.mapper.main;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.shinsoft.sto.model.main.Ware;
5
+
6
+public interface WareMapper extends BaseMapper<Ware> {
7
+
8
+}
9
+

+ 29
- 0
sto/src/main/java/com/shinsoft/sto/model/main/Ware.java Просмотреть файл

@@ -0,0 +1,29 @@
1
+package com.shinsoft.sto.model.main;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableId;
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_WARE")
16
+@ApiModel(value = "仓库", description = "仓库基本信息表")
17
+public class Ware extends BaseModel {
18
+
19
+    @ApiModelProperty("库房名称")
20
+    private String wareNm;
21
+    @ApiModelProperty("库房编码")
22
+    private String wareCode;
23
+    @ApiModelProperty("库房长度")
24
+    private String wareLength;
25
+    @ApiModelProperty("库房宽度")
26
+    private String wareWidth;
27
+
28
+}
29
+

+ 117
- 0
sto/src/main/java/com/shinsoft/sto/service/impl/main/WareServiceImp.java Просмотреть файл

@@ -0,0 +1,117 @@
1
+package com.shinsoft.sto.service.impl.main;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.alibaba.fastjson.JSONObject;
5
+import com.alibaba.fastjson.TypeReference;
6
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
7
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
8
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import com.shinsoft.sto.mapper.main.WareMapper;
10
+import com.shinsoft.sto.model.main.Ware;
11
+import com.shinsoft.sto.service.main.WareService;
12
+import com.shinsoft.tools.JSONTools;
13
+import com.shinsoft.tools.model.common.ResultJSON;
14
+import org.apache.commons.lang3.StringUtils;
15
+import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.stereotype.Service;
17
+import org.springframework.util.ObjectUtils;
18
+
19
+import java.util.Date;
20
+import java.util.List;
21
+import java.util.Map;
22
+
23
+/**
24
+ * <p>
25
+ * 仓库 服务实现类
26
+ * </p>
27
+ *
28
+ * @author system
29
+ * @since 2024-10-15
30
+ */
31
+@Service
32
+public class WareServiceImp extends ServiceImpl<WareMapper, Ware> implements WareService {
33
+
34
+    ResultJSON resultJSON;
35
+
36
+    @Autowired
37
+    WareMapper wareMapper;
38
+
39
+    @Override
40
+    public ResultJSON query(int page, int rows,  Map<String, Object> map) {
41
+        Page<Ware> warePage = new Page<>(page, rows);
42
+        QueryWrapper<Ware> queryWrapper = new QueryWrapper<>();
43
+        queryWrapper.eq("cancel_flag", "0");
44
+        queryWrapper.orderByDesc("add_time");
45
+        
46
+        // 解析查询参数
47
+        if (!ObjectUtils.isEmpty(map)) {
48
+            if (!ObjectUtils.isEmpty(map.get("wareNm"))) {
49
+                queryWrapper.like("ware_nm", map.get("wareNm"));
50
+            }
51
+            if (!ObjectUtils.isEmpty(map.get("wareCode"))) {
52
+                queryWrapper.like("ware_code", map.get("wareCode"));
53
+            }
54
+        }
55
+        
56
+        Page<Ware> list = wareMapper.selectPage(warePage, queryWrapper);
57
+        resultJSON = JSONTools.toResultJSON(list);
58
+        return resultJSON;
59
+    }
60
+
61
+    @Override
62
+    public ResultJSON queryByPK(String id) {
63
+        Ware ware = wareMapper.selectById(id);
64
+        resultJSON = JSONTools.toResultJSON(ware);
65
+        return resultJSON;
66
+    }
67
+
68
+    @Override
69
+    public ResultJSON save(String userId, String json) {
70
+        Date date = new Date();
71
+        Ware ware = JSON.parseObject(json, new TypeReference<Ware>() {
72
+        });
73
+        if (StringUtils.isEmpty(ware.getId())) {
74
+            ware.setCancelFlag("0");
75
+            ware.setAddId(userId);
76
+            ware.setAddTime(date);
77
+            wareMapper.insert(ware);
78
+        } else {
79
+            ware.setModifyId(userId);
80
+            ware.setModifyTime(date);
81
+            wareMapper.updateById(ware);
82
+        }
83
+
84
+        resultJSON = JSONTools.toResultJSON(ware);
85
+        return resultJSON;
86
+    }
87
+
88
+    @Override
89
+    public ResultJSON remove(String userId, String id) {
90
+        Date date = new Date();
91
+        Ware ware = wareMapper.selectById(id);
92
+        ware.setCancelFlag("1");
93
+        ware.setModifyId(userId);
94
+        ware.setModifyTime(date);
95
+        wareMapper.updateById(ware);
96
+        resultJSON = JSONTools.toResultJSON("");
97
+        return resultJSON;
98
+    }
99
+
100
+    @Override
101
+    public ResultJSON removeBatch(String userId, String ids) {
102
+        Date date = new Date();
103
+        List<String> list = JSON.parseObject(ids, new TypeReference<List<String>>() {
104
+        });
105
+        Ware ware;
106
+        for (String id : list) {
107
+            ware = wareMapper.selectById(id);
108
+            ware.setCancelFlag("1");
109
+            ware.setModifyId(userId);
110
+            ware.setModifyTime(date);
111
+            wareMapper.updateById(ware);
112
+        }
113
+        resultJSON = JSONTools.toResultJSON("");
114
+        return resultJSON;
115
+    }
116
+}
117
+

+ 29
- 0
sto/src/main/java/com/shinsoft/sto/service/main/WareService.java Просмотреть файл

@@ -0,0 +1,29 @@
1
+package com.shinsoft.sto.service.main;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.shinsoft.sto.model.main.Ware;
5
+import com.shinsoft.tools.model.common.ResultJSON;
6
+
7
+import java.util.Map;
8
+
9
+/**
10
+ * <p>
11
+ * 仓库 服务类
12
+ * </p>
13
+ *
14
+ * @author system
15
+ * @since 2024-10-15
16
+ */
17
+public interface WareService extends IService<Ware> {
18
+
19
+    ResultJSON query(int page, int rows, Map<String, Object> map);
20
+
21
+    ResultJSON queryByPK(String id);
22
+
23
+    ResultJSON save(String userId, String json);
24
+
25
+    ResultJSON remove(String userId, String id);
26
+
27
+    ResultJSON removeBatch(String userId, String ids);
28
+}
29
+

Загрузка…
Отмена
Сохранить