|
|
@@ -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
|
+
|