Przeglądaj źródła

顾客信息进行调整

张庆宇 3 miesięcy temu
rodzic
commit
b6c4d886f6

+ 9
- 8
sto/src/main/java/com/shinsoft/sto/controller/main/CustomerController.java Wyświetl plik

@@ -2,7 +2,7 @@ package com.shinsoft.sto.controller.main;
2 2
 
3 3
 import com.shinsoft.tools.JSONTools;
4 4
 import com.shinsoft.tools.model.common.ResponseCodeMsg;
5
-import com.shinsoft.tools.model.common.ResultJSON;
5
+import com.shinsoft.sto.model.system.ResultJSON;
6 6
 import com.shinsoft.sto.service.main.CustomerService;
7 7
 import org.springframework.beans.factory.annotation.Autowired;
8 8
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -32,7 +32,7 @@ public class CustomerController {
32 32
             resultJSON = customerService.query(page, rows, customerNm, map);
33 33
         } catch (Exception ex) {
34 34
             ex.printStackTrace();
35
-            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
35
+            //resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
36 36
         } finally {
37 37
             return resultJSON;
38 38
         }
@@ -45,7 +45,7 @@ public class CustomerController {
45 45
             resultJSON = customerService.queryByPK(id);
46 46
         } catch (Exception ex) {
47 47
             ex.printStackTrace();
48
-            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
48
+            //resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
49 49
         } finally {
50 50
             return resultJSON;
51 51
         }
@@ -55,9 +55,10 @@ public class CustomerController {
55 55
     public ResultJSON save(String json, HttpServletRequest request) {
56 56
         try {
57 57
             String userId = (String) request.getHeader("userId");
58
-            resultJSON = customerService.save(userId, json);
58
+            String belongId = (String) request.getHeader("beongId");
59
+            resultJSON = customerService.save(userId,belongId, json);
59 60
         } catch (Exception ex) {
60
-            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
61
+            //resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
61 62
             ex.printStackTrace();
62 63
         } finally {
63 64
             return resultJSON;
@@ -71,7 +72,7 @@ public class CustomerController {
71 72
             resultJSON = customerService.remove(userId, id);
72 73
         } catch (Exception ex) {
73 74
             ex.printStackTrace();
74
-            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
75
+            //resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
75 76
         } finally {
76 77
             return resultJSON;
77 78
         }
@@ -84,7 +85,7 @@ public class CustomerController {
84 85
             resultJSON = customerService.removeBatch(userId, ids);
85 86
         } catch (Exception ex) {
86 87
             ex.printStackTrace();
87
-            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
88
+            //resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
88 89
         } finally {
89 90
             return resultJSON;
90 91
         }
@@ -98,7 +99,7 @@ public class CustomerController {
98 99
             resultJSON = customerService.querySelect(belongId);
99 100
         } catch (Exception ex) {
100 101
             ex.printStackTrace();
101
-            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
102
+            //resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
102 103
         } finally {
103 104
             return resultJSON;
104 105
         }

+ 2
- 0
sto/src/main/java/com/shinsoft/sto/mapper/main/CustomerMapper.java Wyświetl plik

@@ -14,4 +14,6 @@ public interface CustomerMapper extends BaseMapper<Customer> {
14 14
      * 查询客户下拉框数据
15 15
      */
16 16
     List<selectModel> selectCustomerOptions(@Param("belongId") String belongId);
17
+
18
+    List<Customer> selectByName(@Param("customerNm") String customerNm,@Param("customerShortNm") String customerShortNm,@Param("belongId") String belongId);
17 19
 }

+ 11
- 11
sto/src/main/java/com/shinsoft/sto/mapper/main/CustomerMapper.xml Wyświetl plik

@@ -22,15 +22,6 @@
22 22
         <result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP"/>
23 23
         <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR"/>
24 24
         <result column="belong_id" property="belongId" jdbcType="VARCHAR"/>
25
-        <result column="customer_name" property="customerName" jdbcType="VARCHAR"/>
26
-        <result column="customer_abbreviation" property="customerAbbreviation" jdbcType="VARCHAR"/>
27
-        <result column="customer_contact" property="customerContact" jdbcType="VARCHAR"/>
28
-        <result column="contact_information" property="contactInformation" jdbcType="VARCHAR"/>
29
-        <result column="default_address" property="defaultAddress" jdbcType="VARCHAR"/>
30
-        <result column="remarks" property="remarks" jdbcType="VARCHAR"/>
31
-        <result column="active_status" property="activeStatus" jdbcType="VARCHAR"/>
32
-        <result column="operation" property="operation" jdbcType="VARCHAR"/>
33
-        <result column="test" property="test" jdbcType="VARCHAR"/>
34 25
     </resultMap>
35 26
 
36 27
     <sql id="Base_Column_List">
@@ -43,7 +34,7 @@
43 34
     <select id="selectCustomerPage" resultMap="BaseResultMap">
44 35
         select
45 36
         <include refid="Base_Column_List"/>
46
-        from STO_MAIN_CUSTOMER
37
+        from T_MAIN_CUSTOMER
47 38
         where nvl(cancel_flag,'0') = '0'
48 39
         and belong_id = #{belongId}
49 40
         <if test="query != null and query != ''">
@@ -58,7 +49,7 @@
58 49
     <select id="selectByCustomerName" resultMap="BaseResultMap">
59 50
         select
60 51
         <include refid="Base_Column_List"/>
61
-        from STO_MAIN_CUSTOMER
52
+        from T_MAIN_CUSTOMER
62 53
         where nvl(cancel_flag,'0') = '0'
63 54
         and belong_id = #{belongId}
64 55
         and customer_name = #{customerName}
@@ -73,5 +64,14 @@
73 64
 
74 65
         ORDER BY add_time DESC
75 66
     </select>
67
+    <select id="selectByName" resultType="com.shinsoft.sto.model.main.Customer">
68
+        select * from T_MAIN_CUSTOMER WHERE nvl(cancel_flag,'0') = '0'
69
+        <if test="belongId!=null and belongId !=''">
70
+            AND belong_id = #{belongId}
71
+        </if>
72
+        and (customer_nm = #{customerNm}
73
+                or customer_short_nm = #{customerShortNm})
74
+
75
+    </select>
76 76
 
77 77
 </mapper>

+ 19
- 13
sto/src/main/java/com/shinsoft/sto/service/impl/main/CustomerServiceImp.java Wyświetl plik

@@ -12,7 +12,7 @@ import com.shinsoft.sto.model.main.Customer;
12 12
 import com.shinsoft.sto.service.main.CustomerService;
13 13
 import com.shinsoft.tools.JSONTools;
14 14
 import com.shinsoft.tools.model.common.ResponseCodeMsg;
15
-import com.shinsoft.tools.model.common.ResultJSON;
15
+import com.shinsoft.sto.model.system.ResultJSON;
16 16
 import org.apache.commons.lang3.StringUtils;
17 17
 import org.springframework.beans.factory.annotation.Autowired;
18 18
 import org.springframework.stereotype.Service;
@@ -61,35 +61,41 @@ public class CustomerServiceImp extends ServiceImpl<CustomerMapper, Customer> im
61 61
         }
62 62
         
63 63
         Page<Customer> list = customerMapper.selectPage(customerPage, queryWrapper);
64
-        resultJSON = JSONTools.toResultJSON(list);
64
+        resultJSON = ResultJSON.success(list);
65 65
         return resultJSON;
66 66
     }
67 67
 
68 68
     @Override
69 69
     public ResultJSON queryByPK(String id) {
70 70
         Customer customer = customerMapper.selectById(id);
71
-        resultJSON = JSONTools.toResultJSON(customer);
71
+        resultJSON = ResultJSON.success(customer);
72 72
         return resultJSON;
73 73
     }
74 74
 
75 75
     @Override
76
-    public ResultJSON save(String userId, String json) {
76
+    public ResultJSON save(String userId,String belongId, String json) {
77 77
         Date date = new Date();
78
+        boolean success;
78 79
         Customer customer = JSON.parseObject(json, new TypeReference<Customer>() {
79 80
         });
80 81
         if (StringUtils.isEmpty(customer.getId())) {
82
+            //增加插入校验,相同客户名称的信息只能保存一条
83
+            //增加限制的原因为:入库批量导入的时候使用到的客户名称进行查询赋值,如果出现两条一样的会出现错误
81 84
             customer.setCancelFlag("0");
82 85
             customer.setAddId(userId);
83 86
             customer.setAddTime(date);
84
-            customerMapper.insert(customer);
87
+
88
+            List<Customer> customers = customerMapper.selectByName(customer.getCustomerNm(), customer.getCustomerShortNm(), belongId);
89
+            if (customers != null && !customers.isEmpty()) {
90
+                return ResultJSON.error("客户名称或简称已存在,请勿重复添加");
91
+            }
92
+            success = customerMapper.insert(customer)> 0;
85 93
         } else {
86 94
             customer.setModifyId(userId);
87 95
             customer.setModifyTime(date);
88
-            customerMapper.updateById(customer);
96
+            success = customerMapper.updateById(customer)> 0;
89 97
         }
90
-
91
-        resultJSON = JSONTools.toResultJSON(customer);
92
-        return resultJSON;
98
+        return success ? ResultJSON.success("新增成功") : ResultJSON.error("新增失败");
93 99
     }
94 100
 
95 101
     @Override
@@ -100,7 +106,7 @@ public class CustomerServiceImp extends ServiceImpl<CustomerMapper, Customer> im
100 106
         customer.setModifyId(userId);
101 107
         customer.setModifyTime(date);
102 108
         customerMapper.updateById(customer);
103
-        resultJSON = JSONTools.toResultJSON("");
109
+        resultJSON = ResultJSON.success("");
104 110
         return resultJSON;
105 111
     }
106 112
 
@@ -117,7 +123,7 @@ public class CustomerServiceImp extends ServiceImpl<CustomerMapper, Customer> im
117 123
             customer.setModifyTime(date);
118 124
             customerMapper.updateById(customer);
119 125
         }
120
-        resultJSON = JSONTools.toResultJSON("");
126
+        resultJSON = ResultJSON.success("");
121 127
         return resultJSON;
122 128
     }
123 129
 
@@ -125,11 +131,11 @@ public class CustomerServiceImp extends ServiceImpl<CustomerMapper, Customer> im
125 131
     public ResultJSON querySelect(String belongId) {
126 132
         try {
127 133
             List<selectModel> list = customerMapper.selectCustomerOptions(belongId);
128
-            resultJSON = JSONTools.toResultJSON(list);
134
+            resultJSON = ResultJSON.success(list);
129 135
             return resultJSON;
130 136
         } catch (Exception ex) {
131 137
             ex.printStackTrace();
132
-            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
138
+            resultJSON = ResultJSON.error("查询失败");
133 139
             return resultJSON;
134 140
         }
135 141
     }

+ 2
- 2
sto/src/main/java/com/shinsoft/sto/service/main/CustomerService.java Wyświetl plik

@@ -2,7 +2,7 @@ package com.shinsoft.sto.service.main;
2 2
 
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.shinsoft.sto.model.main.Customer;
5
-import com.shinsoft.tools.model.common.ResultJSON;
5
+import com.shinsoft.sto.model.system.ResultJSON;
6 6
 
7 7
 import java.util.List;
8 8
 import java.util.Map;
@@ -21,7 +21,7 @@ public interface CustomerService extends IService<Customer> {
21 21
 
22 22
     ResultJSON queryByPK(String id);
23 23
 
24
-    ResultJSON save(String userId, String json);
24
+    ResultJSON save(String userId,String belongId, String json);
25 25
 
26 26
     ResultJSON remove(String userId, String id);
27 27
 

Ładowanie…
Anuluj
Zapisz