张庆宇 пре 3 месеци
родитељ
комит
b6c4d886f6

+ 9
- 8
sto/src/main/java/com/shinsoft/sto/controller/main/CustomerController.java Прегледај датотеку

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

+ 2
- 0
sto/src/main/java/com/shinsoft/sto/mapper/main/CustomerMapper.java Прегледај датотеку

14
      * 查询客户下拉框数据
14
      * 查询客户下拉框数据
15
      */
15
      */
16
     List<selectModel> selectCustomerOptions(@Param("belongId") String belongId);
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 Прегледај датотеку

22
         <result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP"/>
22
         <result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP"/>
23
         <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR"/>
23
         <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR"/>
24
         <result column="belong_id" property="belongId" jdbcType="VARCHAR"/>
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
     </resultMap>
25
     </resultMap>
35
 
26
 
36
     <sql id="Base_Column_List">
27
     <sql id="Base_Column_List">
43
     <select id="selectCustomerPage" resultMap="BaseResultMap">
34
     <select id="selectCustomerPage" resultMap="BaseResultMap">
44
         select
35
         select
45
         <include refid="Base_Column_List"/>
36
         <include refid="Base_Column_List"/>
46
-        from STO_MAIN_CUSTOMER
37
+        from T_MAIN_CUSTOMER
47
         where nvl(cancel_flag,'0') = '0'
38
         where nvl(cancel_flag,'0') = '0'
48
         and belong_id = #{belongId}
39
         and belong_id = #{belongId}
49
         <if test="query != null and query != ''">
40
         <if test="query != null and query != ''">
58
     <select id="selectByCustomerName" resultMap="BaseResultMap">
49
     <select id="selectByCustomerName" resultMap="BaseResultMap">
59
         select
50
         select
60
         <include refid="Base_Column_List"/>
51
         <include refid="Base_Column_List"/>
61
-        from STO_MAIN_CUSTOMER
52
+        from T_MAIN_CUSTOMER
62
         where nvl(cancel_flag,'0') = '0'
53
         where nvl(cancel_flag,'0') = '0'
63
         and belong_id = #{belongId}
54
         and belong_id = #{belongId}
64
         and customer_name = #{customerName}
55
         and customer_name = #{customerName}
73
 
64
 
74
         ORDER BY add_time DESC
65
         ORDER BY add_time DESC
75
     </select>
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
 </mapper>
77
 </mapper>

+ 19
- 13
sto/src/main/java/com/shinsoft/sto/service/impl/main/CustomerServiceImp.java Прегледај датотеку

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

+ 2
- 2
sto/src/main/java/com/shinsoft/sto/service/main/CustomerService.java Прегледај датотеку

2
 
2
 
3
 import com.baomidou.mybatisplus.extension.service.IService;
3
 import com.baomidou.mybatisplus.extension.service.IService;
4
 import com.shinsoft.sto.model.main.Customer;
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
 import java.util.List;
7
 import java.util.List;
8
 import java.util.Map;
8
 import java.util.Map;
21
 
21
 
22
     ResultJSON queryByPK(String id);
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
     ResultJSON remove(String userId, String id);
26
     ResultJSON remove(String userId, String id);
27
 
27
 

Loading…
Откажи
Сачувај