浏览代码

客户管理

dxq 1 个月前
父节点
当前提交
27afc73b37

+ 4
- 0
sto-api/src/main/java/com/shinsoft/stoapi/service/StoService.java 查看文件

@@ -38,4 +38,8 @@ public interface StoService {
38 38
 
39 39
     @RequestMapping(value = "sto/Onhand/queryDelvOut", method = RequestMethod.GET)
40 40
     ResultJSON queryDelvOut(@RequestParam(value = "params" , required = false) String params);
41
+
42
+
43
+    @RequestMapping(value = "/sto/Customer/query", method = RequestMethod.GET)
44
+    ResultJSON ConfigQuery(@RequestParam(value = "params" , required = false) String params);
41 45
 }

+ 61
- 8
sto/src/main/java/com/shinsoft/sto/controller/main/CustomerController.java 查看文件

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

+ 17
- 24
sto/src/main/java/com/shinsoft/sto/model/main/Customer.java 查看文件

@@ -1,5 +1,6 @@
1 1
 package com.shinsoft.sto.model.main;
2 2
 
3
+import com.baomidou.mybatisplus.annotation.TableId;
3 4
 import com.baomidou.mybatisplus.annotation.TableName;
4 5
 import io.swagger.annotations.ApiModel;
5 6
 import io.swagger.annotations.ApiModelProperty;
@@ -14,40 +15,32 @@ import lombok.experimental.Accessors;
14 15
 @ApiModel(value = "仓库客户", description = "仓库客户基本信息表")
15 16
 public class Customer {
16 17
 
18
+    @TableId("ID")
19
+    @ApiModelProperty("主键ID")
20
+    private String id;
21
+
17 22
     @ApiModelProperty("客户名称")
18 23
     private String customerNm;
19
-
20 24
     @ApiModelProperty("客户简称")
21 25
     private String customerShortNm;
22
-
23 26
     @ApiModelProperty("联系人")
24 27
     private String contactPerson;
25
-
26 28
     @ApiModelProperty("联系方式")
27 29
     private String contactInfo;
28
-
29 30
     @ApiModelProperty("默认地址")
30 31
     private String defaultAddress;
31
-
32
-    private String attr1;
33
-
34
-    private String attr2;
35
-
36
-    private String attr3;
37
-
38
-    private String attr4;
39
-
40
-    private String attr5;
41
-
42
-    private String attr6;
43
-
44
-    private String attr7;
45
-
46
-    private String attr8;
47
-
48
-    private String attr9;
49
-
50
-    private String attr10;
32
+    @ApiModelProperty("新增人id")
33
+    private String addId;
34
+    @ApiModelProperty("新增时间")
35
+    private String addTime;
36
+    @ApiModelProperty("编辑人id")
37
+    private String modifyId;
38
+    @ApiModelProperty("修改时间")
39
+    private String modifyTime;
40
+    @ApiModelProperty("作废标识0作废1正常")
41
+    private String cancelFlag;
42
+    @ApiModelProperty("添加部门id")
43
+    private String addDeptId;
51 44
 
52 45
 
53 46
 }

+ 24
- 1
sto/src/main/java/com/shinsoft/sto/service/main/CustomerService.java 查看文件

@@ -1,5 +1,28 @@
1 1
 package com.shinsoft.sto.service.main;
2 2
 
3
-public interface CustomerService {
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.shinsoft.sto.model.main.Customer;
5
+import com.shinsoft.tools.model.common.ResultJSON;
4 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 CustomerService extends IService<Customer> {
18
+
19
+    ResultJSON query(int page, int rows, String params, 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);
5 28
 }

+ 110
- 0
sto/src/main/java/com/shinsoft/sto/service/main/impl/CustomerServiceImp.java 查看文件

@@ -1,10 +1,120 @@
1 1
 package com.shinsoft.sto.service.main.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
3 5
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 6
 import com.shinsoft.sto.mapper.main.CustomerMapper;
5 7
 import com.shinsoft.sto.model.main.Customer;
6 8
 import com.shinsoft.sto.service.main.CustomerService;
9
+import com.shinsoft.tools.JSONTools;
10
+import com.shinsoft.tools.model.common.ResultJSON;
11
+import com.alibaba.fastjson.JSON;
12
+import com.alibaba.fastjson.JSONObject;
13
+import com.alibaba.fastjson.TypeReference;
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;
7 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
8 32
 public class CustomerServiceImp extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
9 33
 
34
+    ResultJSON resultJSON;
35
+
36
+    @Autowired
37
+    CustomerMapper customerMapper;
38
+
39
+    @Override
40
+    public ResultJSON query(int page, int rows, String params, Map<String, Object> map) {
41
+        Page<Customer> customerPage = new Page<>(page, rows);
42
+        QueryWrapper<Customer> queryWrapper = new QueryWrapper<>();
43
+        queryWrapper.eq("cancel_flag", "0");
44
+        queryWrapper.orderByDesc("add_time");
45
+        
46
+        // 解析查询参数
47
+        if (!ObjectUtils.isEmpty(params)) {
48
+            JSONObject jsonObject = JSON.parseObject(params);
49
+            if (!ObjectUtils.isEmpty(jsonObject.get("customerNm"))) {
50
+                queryWrapper.like("customer_nm", jsonObject.getString("customerNm"));
51
+            }
52
+            if (!ObjectUtils.isEmpty(jsonObject.get("customerShortNm"))) {
53
+                queryWrapper.like("customer_short_nm", jsonObject.getString("customerShortNm"));
54
+            }
55
+            if (!ObjectUtils.isEmpty(jsonObject.get("contactPerson"))) {
56
+                queryWrapper.like("contact_person", jsonObject.getString("contactPerson"));
57
+            }
58
+        }
59
+        
60
+        Page<Customer> list = customerMapper.selectPage(customerPage, queryWrapper);
61
+        resultJSON = JSONTools.toResultJSON(list);
62
+        return resultJSON;
63
+    }
64
+
65
+    @Override
66
+    public ResultJSON queryByPK(String id) {
67
+        Customer customer = customerMapper.selectById(id);
68
+        resultJSON = JSONTools.toResultJSON(customer);
69
+        return resultJSON;
70
+    }
71
+
72
+    @Override
73
+    public ResultJSON save(String userId, String json) {
74
+        Date date = new Date();
75
+        Customer customer = JSON.parseObject(json, new TypeReference<Customer>() {
76
+        });
77
+        if (StringUtils.isEmpty(customer.getId())) {
78
+            customer.setCancelFlag("0");
79
+            customer.setAddId(userId);
80
+            customer.setAddTime(date.toString());
81
+            customerMapper.insert(customer);
82
+        } else {
83
+            customer.setModifyId(userId);
84
+            customer.setModifyTime(date.toString());
85
+            customerMapper.updateById(customer);
86
+        }
87
+
88
+        resultJSON = JSONTools.toResultJSON(customer);
89
+        return resultJSON;
90
+    }
91
+
92
+    @Override
93
+    public ResultJSON remove(String userId, String id) {
94
+        Date date = new Date();
95
+        Customer customer = customerMapper.selectById(id);
96
+        customer.setCancelFlag("1");
97
+        customer.setModifyId(userId);
98
+        customer.setModifyTime(date.toString());
99
+        customerMapper.updateById(customer);
100
+        resultJSON = JSONTools.toResultJSON("");
101
+        return resultJSON;
102
+    }
103
+
104
+    @Override
105
+    public ResultJSON removeBatch(String userId, String ids) {
106
+        Date date = new Date();
107
+        List<String> list = JSON.parseObject(ids, new TypeReference<List<String>>() {
108
+        });
109
+        Customer customer;
110
+        for (String id : list) {
111
+            customer = customerMapper.selectById(id);
112
+            customer.setCancelFlag("1");
113
+            customer.setModifyId(userId);
114
+            customer.setModifyTime(date.toString());
115
+            customerMapper.updateById(customer);
116
+        }
117
+        resultJSON = JSONTools.toResultJSON("");
118
+        return resultJSON;
119
+    }
10 120
 }

正在加载...
取消
保存