Pārlūkot izejas kodu

5月2日系统修改完成 1.0

Zhangqy 1 mēnesi atpakaļ
vecāks
revīzija
f6573bd82c

+ 16
- 0
src/main/java/com/th/demo/controller/maint/CustomerController.java Parādīt failu

@@ -116,4 +116,20 @@ public class CustomerController {
116 116
         }
117 117
     }
118 118
 
119
+    @RequestMapping(value = "/queryByUserId.do")//查询方法 前两个参数是分页参数
120
+    public String queryByUserId(String fId,
121
+                                HttpServletRequest request) {
122
+
123
+        try {
124
+            String userId = (String) request.getAttribute("userId");
125
+            String belongId = (String) request.getAttribute("belongId");
126
+            result = customerService.queryByUserId(userId, belongId);
127
+        } catch (Exception ex) {
128
+            ex.printStackTrace();
129
+            result = JSONTools.toString(ResponseCodeMsg.CODE_EX, ex.getMessage());
130
+        } finally {
131
+            return result;
132
+        }
133
+    }
134
+
119 135
 }

+ 2
- 3
src/main/java/com/th/demo/controller/maint/PriceController.java Parādīt failu

@@ -22,14 +22,13 @@ public class PriceController {
22 22
     @RequestMapping(value = "/query.do")//查询方法 前两个参数是分页参数
23 23
     public String query(int page,
24 24
                         int rows,
25
-                        String materialName,
26
-                        String standard,
25
+                        String customerName,
27 26
                         HttpServletRequest request) {
28 27
 
29 28
         try {
30 29
             String userId = (String) request.getAttribute("userId");
31 30
             String belongId = (String) request.getAttribute("belongId");
32
-            result = priceService.query(page, rows,materialName,standard, userId,belongId);
31
+            result = priceService.query(page, rows,customerName, userId,belongId);
33 32
         } catch (Exception ex) {
34 33
             ex.printStackTrace();
35 34
             result = JSONTools.toString(ResponseCodeMsg.CODE_EX, ex.getMessage());

+ 2
- 0
src/main/java/com/th/demo/mapping/maint/CustomerMapper.java Parādīt failu

@@ -24,4 +24,6 @@ public interface CustomerMapper {
24 24
     Customer selectByName(String customerName, String belongId);
25 25
 
26 26
     List<Customer> selectByNameCode(String customerName, String customerCode, String belongId);
27
+
28
+    List<Customer> selectByUserId(String userId, String belongId);
27 29
 }

+ 3
- 1
src/main/java/com/th/demo/mapping/maint/PriceMapper.java Parādīt failu

@@ -21,7 +21,9 @@ public interface PriceMapper {
21 21
 
22 22
     Price selectByMaterialChangeTime(String materialId, int changeTime,String belongId);
23 23
 
24
-    List<Price> select(String materialName, String standard, String belongId);
24
+    List<Price> select(String materialName, String belongId);
25
+
26
+    List<Price> selectListByCustomer(String materialName, String belongId);
25 27
 
26 28
     int selectCntByMaterialChangeTime(String id, int i, String belongId);
27 29
 

+ 38
- 1
src/main/java/com/th/demo/model/maint/Price.java Parādīt failu

@@ -31,7 +31,12 @@ public class Price {
31 31
 
32 32
     private String belongId;
33 33
 
34
-    private String   storageType;
34
+    private String storageType;
35
+
36
+    private Customer customer;
37
+    private double keepDay;
38
+    private double ordPrice;
39
+    private double outOrdPrice;
35 40
 
36 41
     public String getId() {
37 42
         return id;
@@ -144,4 +149,36 @@ public class Price {
144 149
     public void setStorageType(String storageType) {
145 150
         this.storageType = storageType;
146 151
     }
152
+
153
+    public Customer getCustomer() {
154
+        return customer;
155
+    }
156
+
157
+    public void setCustomer(Customer customer) {
158
+        this.customer = customer;
159
+    }
160
+
161
+    public double getKeepDay() {
162
+        return keepDay;
163
+    }
164
+
165
+    public void setKeepDay(double keepDay) {
166
+        this.keepDay = keepDay;
167
+    }
168
+
169
+    public double getOrdPrice() {
170
+        return ordPrice;
171
+    }
172
+
173
+    public void setOrdPrice(double ordPrice) {
174
+        this.ordPrice = ordPrice;
175
+    }
176
+
177
+    public double getOutOrdPrice() {
178
+        return outOrdPrice;
179
+    }
180
+
181
+    public void setOutOrdPrice(double outOrdPrice) {
182
+        this.outOrdPrice = outOrdPrice;
183
+    }
147 184
 }

+ 8
- 0
src/main/java/com/th/demo/service/impl/maint/CustomerServiceImpl.java Parādīt failu

@@ -143,4 +143,12 @@ public class CustomerServiceImpl implements CustomerService {
143 143
         num += customerAddressMapper.updateByPrimaryKey(customerAddress);
144 144
         return Tools.moreThanZeroResultJSON(num);
145 145
     }
146
+
147
+    @Transactional
148
+    @Override
149
+    public String queryByUserId(String userId, String belongId) {
150
+
151
+        List<Customer> list = customerMapper.selectByUserId(userId, belongId);
152
+        return JSONTools.toString(list);
153
+    }
146 154
 }

+ 12
- 8
src/main/java/com/th/demo/service/impl/maint/PriceServiceImpl.java Parādīt failu

@@ -6,6 +6,7 @@ import com.github.pagehelper.PageHelper;
6 6
 import com.github.pagehelper.PageInfo;
7 7
 import com.th.demo.mapping.maint.PriceMapper;
8 8
 import com.th.demo.mapping.maint.ProdPriceMapper;
9
+import com.th.demo.model.maint.Customer;
9 10
 import com.th.demo.model.maint.Price;
10 11
 import com.th.demo.model.maint.ProdPrice;
11 12
 import com.th.demo.model.system.SysUser;
@@ -31,9 +32,9 @@ public class PriceServiceImpl implements PriceService {
31 32
     int num = 0;
32 33
 
33 34
     @Override
34
-    public String query(int page, int rows, String materialName,String standard, String userId, String belongId) {
35
+    public String query(int page, int rows, String customerName, String userId, String belongId) {
35 36
         PageHelper.startPage(page, rows);
36
-        List<Price> list = priceMapper.select(  materialName,standard, belongId);
37
+        List<Price> list = priceMapper.select(customerName, belongId);
37 38
         PageInfo<Price> pageInfo = new PageInfo<>(list);
38 39
         result = JSONTools.toStringyyyyMMddHHmmss(pageInfo);
39 40
         return result;
@@ -43,12 +44,9 @@ public class PriceServiceImpl implements PriceService {
43 44
     public String save(String json, String userId, String belongId) {
44 45
         Price price = JSON.parseObject(json,new TypeReference<Price>(){});
45 46
         if(price.getId()==null||price.getId().equals("")){
46
-            int priceCnt = priceMapper.selectCntByMaterialChangeTime(price.getMaterial().getId(),Integer.parseInt(price.getStorageType()) , belongId);
47
-            if(priceCnt > 0){
48
-                result = JSONTools.toStringyyyyMMddHHmmss(0);
49
-                result = "已存在该价格信息";
50
-
51
-                return result;
47
+            List<Price> priceList = priceMapper.selectListByCustomer(price.getCustomer().getId(),belongId);
48
+            if (priceList.size() >= 1){
49
+                return JSONTools.toString(1,"该客户的价格已维护,请勿重复维护");
52 50
             }
53 51
             price.setAddUser(new SysUser(userId));
54 52
             price.setAddTime(new Date());
@@ -58,6 +56,12 @@ public class PriceServiceImpl implements PriceService {
58 56
             price.setBelongId(belongId);
59 57
             num += priceMapper.insert(price);
60 58
         }else {
59
+            List<Price> priceList = priceMapper.selectListByCustomer(price.getCustomer().getName(),belongId);
60
+            if (priceList.size() == 1 && !price.getId().equals(priceList.get(0).getId())){
61
+                return JSONTools.toString(1,"该客户的价格已维护,请勿重复维护");
62
+            } else if (priceList.size() > 1) {
63
+                return JSONTools.toString(1,"该客户的价格已维护,请勿重复维护");
64
+            }
61 65
             price.setModifyUser(new SysUser(userId));
62 66
             price.setModifyTime(new Date());
63 67
             num += priceMapper.updateByPrimaryKey(price);

+ 2
- 0
src/main/java/com/th/demo/service/maint/CustomerService.java Parādīt failu

@@ -12,4 +12,6 @@ public interface CustomerService {
12 12
     String saveAddress(String json, String userId, String belongId);
13 13
 
14 14
     String defaultAddress(String json, String userId, String belongId);
15
+
16
+    String queryByUserId(String userId, String belongId);
15 17
 }

+ 1
- 1
src/main/java/com/th/demo/service/maint/PriceService.java Parādīt failu

@@ -1,7 +1,7 @@
1 1
 package com.th.demo.service.maint;
2 2
 
3 3
 public interface PriceService {
4
-    String query(int page, int rows, String materialName, String standard, String userId, String belongId);
4
+    String query(int page, int rows, String customerName, String userId, String belongId);
5 5
 
6 6
     String save(String json, String userId, String belongId);
7 7
 

+ 7
- 0
src/main/resource/mapper/maint/CustomerMapper.xml Parādīt failu

@@ -229,4 +229,11 @@
229 229
       and ifnull(cancel_flag,'0') = '0'
230 230
   </select>
231 231
 
232
+  <select id="selectByUserId" resultMap="BaseResultMap" >
233
+    select *
234
+    from t_maint_customer
235
+    where belong_id = #{param2,jdbcType=VARCHAR}
236
+      and ifnull(cancel_flag,'0') = '0'
237
+  </select>
238
+
232 239
 </mapper>

+ 26
- 8
src/main/resource/mapper/maint/PriceMapper.xml Parādīt failu

@@ -15,15 +15,20 @@
15 15
     <result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP" />
16 16
     <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR" />
17 17
     <result column="belong_id" property="belongId" jdbcType="VARCHAR" />
18
+    <result column="keep_day" property="keepDay" jdbcType="DOUBLE" />
19
+    <result column="ord_price" property="ordPrice" jdbcType="DOUBLE" />
20
+    <result column="out_ord_price" property="outOrdPrice" jdbcType="DOUBLE" />
18 21
 
19 22
       <association  column="material_id" property="material" select="com.th.demo.mapping.maint.MaterialMapper.selectByPrimaryKey" />
20 23
       <association  column="add_id" property="addUser" select="com.th.demo.mapping.system.SysUserMapper.selectByPrimaryKey" />
21 24
     <association  column="modify_id" property="modifyUser" select="com.th.demo.mapping.system.SysUserMapper.selectByPrimaryKey" />
25
+    <association  column="customer_id" property="customer" select="com.th.demo.mapping.maint.CustomerMapper.selectByPrimaryKey" />
22 26
 
23 27
   </resultMap>
24 28
   <sql id="Base_Column_List" >
25 29
     id, material_id, storage_price,transfer_price, weight_price, add_id, add_time,
26
-    modify_id, modify_time, cancel_id, cancel_time, cancel_flag, belong_id,storage_type
30
+    modify_id, modify_time, cancel_id, cancel_time, cancel_flag, belong_id,storage_type,
31
+      keep_day,ord_price,out_ord_price,customer_id
27 32
   </sql>
28 33
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
29 34
     select 
@@ -45,12 +50,14 @@
45 50
       transfer_price, weight_price, add_id,
46 51
       add_time, modify_id, modify_time, 
47 52
       cancel_id, cancel_time, cancel_flag, 
48
-      belong_id,storage_type)
53
+      belong_id,storage_type,
54
+    keep_day,ord_price,out_ord_price,customer_id)
49 55
     values (#{id,jdbcType=VARCHAR}, #{material.id,jdbcType=VARCHAR}, #{storagePrice,jdbcType=DOUBLE},
50 56
       #{transferPrice,jdbcType=DOUBLE}, #{weightPrice,jdbcType=DOUBLE}, #{addUser.id,jdbcType=VARCHAR},
51 57
       #{addTime,jdbcType=TIMESTAMP}, #{modifyUser.id,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP},
52 58
       #{cancelId,jdbcType=VARCHAR}, #{cancelTime,jdbcType=TIMESTAMP}, #{cancelFlag,jdbcType=VARCHAR}, 
53
-      #{belongId,jdbcType=VARCHAR},#{storageType,jdbcType=VARCHAR})
59
+      #{belongId,jdbcType=VARCHAR},#{storageType,jdbcType=VARCHAR}, #{keepDay,jdbcType=DOUBLE},
60
+      #{ordPrice,jdbcType=DOUBLE},#{outOrdPrice,jdbcType=DOUBLE},#{customer.id,jdbcType=VARCHAR})
54 61
   </insert>
55 62
   <insert id="insertSelective" parameterType="com.th.demo.model.maint.Price" >
56 63
     insert into t_maint_price
@@ -193,7 +200,11 @@ transfer_price,
193 200
       cancel_time = #{cancelTime,jdbcType=TIMESTAMP},
194 201
       cancel_flag = #{cancelFlag,jdbcType=VARCHAR},
195 202
       belong_id =  #{belongId,jdbcType=VARCHAR},
196
-     storage_type = #{storageType,jdbcType=VARCHAR}
203
+     storage_type = #{storageType,jdbcType=VARCHAR},
204
+        keep_day = #{keepDay,jdbcType=DOUBLE},
205
+      ord_price = #{ordPrice,jdbcType=DOUBLE},
206
+      out_ord_price = #{outOrdPrice,jdbcType=DOUBLE},
207
+      customer_id = #{customer.id,jdbcType=VARCHAR}
197 208
     where id = #{id,jdbcType=VARCHAR}
198 209
   </update>
199 210
 
@@ -207,11 +218,10 @@ transfer_price,
207 218
 
208 219
 
209 220
   <select id="select" resultMap="BaseResultMap" >
210
-    select  t.*   from t_maint_price t ,t_maint_material d
211
-    where t.material_id = d.id
221
+    select  t.*   from t_maint_price t ,t_maint_customer d
222
+    where t.customer_id = d.id
212 223
     and d.name like concat('%',#{param1,jdbcType=VARCHAR},'%')
213
-      and d.standard like concat('%',#{param2,jdbcType=VARCHAR},'%')
214
-     and t.belong_id=#{param3,jdbcType=VARCHAR}
224
+     and t.belong_id=#{param2,jdbcType=VARCHAR}
215 225
       and t.cancel_flag = '0'
216 226
   </select>
217 227
 
@@ -223,4 +233,12 @@ transfer_price,
223 233
      and belong_id = #{param3,jdbcType=VARCHAR}
224 234
      and cancel_flag = '0'
225 235
   </select>
236
+
237
+  <select id="selectListByCustomer" resultMap="BaseResultMap" >
238
+    select  t.*   from t_maint_price t
239
+    where 1=1
240
+      and t.customer_id = #{param1,jdbcType=VARCHAR}
241
+      and t.belong_id = #{param2,jdbcType=VARCHAR}
242
+      and t.cancel_flag = '0'
243
+  </select>
226 244
 </mapper>

Notiek ielāde…
Atcelt
Saglabāt