Zhangqy 2 months ago
parent
commit
8b67304cf9

+ 64
- 0
src/main/java/com/th/demo/controller/maint/CargoController.java View File

@@ -0,0 +1,64 @@
1
+package com.th.demo.controller.maint;
2
+
3
+import com.th.demo.model.system.ResponseCodeMsg;
4
+import com.th.demo.model.system.Type;
5
+import com.th.demo.service.maint.AreaService;
6
+import com.th.demo.service.maint.CargoService;
7
+import com.th.demo.tools.JSONTools;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.web.bind.annotation.RequestMapping;
10
+import org.springframework.web.bind.annotation.RestController;
11
+
12
+import javax.servlet.http.HttpServletRequest;
13
+
14
+@RestController
15
+@RequestMapping(value = "/MaintCargo")
16
+public class CargoController {
17
+    @Autowired
18
+    public CargoService cargoService;
19
+    String result = Type.FAIL;
20
+
21
+    @RequestMapping(value = "/queryAll.do")
22
+    public String queryAll(int page, int rows,String uperCustomer, String Customer , HttpServletRequest request) {
23
+
24
+        try {
25
+            String userId = (String) request.getAttribute("userId");
26
+            String belongId = (String) request.getAttribute("belongId");
27
+            result = cargoService.query(page,rows,uperCustomer,Customer,userId,belongId);
28
+        } catch (Exception ex) {
29
+            ex.printStackTrace();
30
+            result = JSONTools.toString(ResponseCodeMsg.CODE_EX, ex.getMessage());
31
+        } finally {
32
+            return result;
33
+        }
34
+    }
35
+
36
+    @RequestMapping(value = "/save.do")
37
+    public String save(String json ,HttpServletRequest request) {
38
+
39
+        try {
40
+            String userId = (String) request.getAttribute("userId");
41
+            String belongId = (String) request.getAttribute("belongId");
42
+            result = cargoService.save(json,userId,belongId);
43
+        } catch (Exception ex) {
44
+            ex.printStackTrace();
45
+            result = JSONTools.toString(ResponseCodeMsg.CODE_EX, ex.getMessage());
46
+        } finally {
47
+            return result;
48
+        }
49
+    }
50
+    @RequestMapping(value = "/remove.do")
51
+    public String remove(String id ,HttpServletRequest request) {
52
+
53
+        try {
54
+            String userId = (String) request.getAttribute("userId");
55
+            String belongId = (String) request.getAttribute("belongId");
56
+            result = cargoService.remove(id,userId,belongId);
57
+        } catch (Exception ex) {
58
+            ex.printStackTrace();
59
+            result = JSONTools.toString(ResponseCodeMsg.CODE_EX, ex.getMessage());
60
+        } finally {
61
+            return result;
62
+        }
63
+    }
64
+}

+ 4
- 2
src/main/java/com/th/demo/mapping/maint/CargoMapper.java View File

@@ -5,13 +5,15 @@ import com.th.demo.model.maint.Cargo;
5 5
 import java.util.List;
6 6
 
7 7
 public interface CargoMapper {
8
-    Cargo selectByPrimaryKey(String id);
9 8
 
10
-    List<Cargo> selectByWareId(String wareId, String belongId);
9
+    List<Cargo> selectAll (String uperCustomer, String Customer ,String belongId);
10
+    Cargo selectByPrimaryKey(String id);
11 11
 
12 12
     int updateByPrimaryKey(Cargo cargo);
13 13
 
14 14
     int deleteByPrimaryKey(String id);
15 15
 
16 16
     int insert(Cargo cargo);
17
+
18
+    Cargo selectByByFkAndCustomer(String uperCustomer, String Customer,String belongId);
17 19
 }

+ 1
- 0
src/main/java/com/th/demo/mapping/maint/CustomerMapper.java View File

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

+ 9
- 0
src/main/java/com/th/demo/model/maint/Cargo.java View File

@@ -6,6 +6,7 @@ public class Cargo {
6 6
     private Customer uperCustomer;
7 7
     private Customer Customer;
8 8
     private double sumWeight;
9
+    private String belongId;
9 10
 
10 11
     public String getId() {
11 12
         return id;
@@ -38,4 +39,12 @@ public class Cargo {
38 39
     public void setSumWeight(double sumWeight) {
39 40
         this.sumWeight = sumWeight;
40 41
     }
42
+
43
+    public String getBelongId() {
44
+        return belongId;
45
+    }
46
+
47
+    public void setBelongId(String belongId) {
48
+        this.belongId = belongId;
49
+    }
41 50
 }

+ 101
- 0
src/main/java/com/th/demo/service/impl/maint/CargoServiceImpl.java View File

@@ -0,0 +1,101 @@
1
+package com.th.demo.service.impl.maint;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.alibaba.fastjson.JSONObject;
5
+import com.github.pagehelper.PageHelper;
6
+import com.github.pagehelper.PageInfo;
7
+import com.th.demo.mapping.maint.AreaMapper;
8
+import com.th.demo.mapping.maint.CargoMapper;
9
+import com.th.demo.mapping.maint.CustomerMapper;
10
+import com.th.demo.model.maint.Customer;
11
+import com.th.demo.model.maint.Area;
12
+import com.th.demo.model.maint.Cargo;
13
+import com.th.demo.model.maint.Ware;
14
+import com.th.demo.model.system.Type;
15
+import com.th.demo.service.maint.CargoService;
16
+import com.th.demo.tools.JSONTools;
17
+import com.th.demo.tools.Tools;
18
+import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.stereotype.Service;
20
+
21
+import java.util.Date;
22
+import java.util.List;
23
+
24
+@Service("CargoService")
25
+public class CargoServiceImpl implements CargoService {
26
+    @Autowired
27
+    public CargoMapper cargoMapper;
28
+    @Autowired
29
+    public CustomerMapper customerMapper;
30
+
31
+    String result = Type.FAIL;
32
+    int num = 0;
33
+
34
+
35
+    @Override
36
+    public String query(int page, int rows, String uperCustomer, String Customer ,String userId, String belongId) {
37
+        PageHelper.startPage(page, rows);
38
+        List<Cargo> list   = cargoMapper.selectAll(uperCustomer, Customer, belongId);
39
+        PageInfo<Cargo> pageInfo = new PageInfo<>(list);
40
+        result = JSONTools.toString(pageInfo);
41
+        return result;
42
+    }
43
+
44
+    @Override
45
+    public String save(String json, String userId, String belongId) {
46
+        result = Type.FAIL;
47
+        JSONObject object = JSON.parseObject(json);
48
+        String uperCustomer = object.get("uperCustomer").toString();
49
+        String downCustomer = object.get("Customer").toString();
50
+        Cargo cargo = cargoMapper.selectByByFkAndCustomer(uperCustomer, downCustomer, belongId);
51
+        Customer uperCust = customerMapper.selectByPrimaryKey(uperCustomer);
52
+        Customer downCust = customerMapper.selectByPrimaryKey(downCustomer);
53
+        String subChange = object.get("sub").toString();
54
+        if (object.get("weight").toString().equals("")){
55
+            return JSONTools.toString(1,"请确认重量信息");
56
+        }
57
+        Double weight = Double.parseDouble(object.get("weight").toString());
58
+        if (cargo == null){
59
+            if (subChange.equals("down")){
60
+                return JSONTools.toString(1,"新建信息请选择增加重量");
61
+            } else if (subChange.equals("")) {
62
+                return JSONTools.toString(1,"请选择修改类型");
63
+            }
64
+
65
+            cargo = new Cargo();
66
+            cargo.setUperCustomer(uperCust);
67
+            cargo.setCustomer(downCust);
68
+            cargo.setSumWeight(weight);
69
+            cargo.setBelongId(belongId);
70
+
71
+            num= cargoMapper.insert(cargo);
72
+
73
+            result = Tools.moreThanZeroResultJSON(num);
74
+
75
+        }
76
+        else{
77
+            if (subChange.equals("down")){
78
+                if (weight > cargo.getSumWeight()){
79
+                    return JSONTools.toString(1,"需要减少的重量不足,请确认后再进行操作");
80
+                }
81
+                cargo.setSumWeight(cargo.getSumWeight() - weight);
82
+            }else if (subChange.equals("up")){
83
+                cargo.setSumWeight(cargo.getSumWeight() + weight);
84
+            }else if (subChange.equals("")) {
85
+                return JSONTools.toString(1,"请选择修改类型");
86
+            }
87
+
88
+            // cargo.setBelongId(belongId);
89
+            num = cargoMapper.updateByPrimaryKey(cargo);
90
+            result = Tools.moreThanZeroResultJSON(num);
91
+        }
92
+        return result;
93
+    }
94
+
95
+    @Override
96
+    public String remove(String id, String userId, String belongId) {
97
+        num = cargoMapper.deleteByPrimaryKey(id);
98
+        result = Tools.moreThanZeroResultJSON(num);
99
+        return result;
100
+    }
101
+}

+ 2
- 2
src/main/java/com/th/demo/service/impl/ware/InServiceImpl.java View File

@@ -366,7 +366,7 @@ public class InServiceImpl implements InService {
366 366
                 customerName = listJO.get(i).get("货主").toString();
367 367
                 customer = customerMapper.selectByName(customerName, belongId);
368 368
                 if (customer == null) {
369
-                    err += "未找到名为\"" + customerName + "\"的订单客户名称;";
369
+                    err += "未找到名或简称为\"" + customerName + "\"的订单客户名称;";
370 370
                     throw new Exception(err);
371 371
                 }
372 372
                 store.setCustomer(customer);
@@ -377,7 +377,7 @@ public class InServiceImpl implements InService {
377 377
                 fk_compony_name = listJO.get(i).get("货主").toString();
378 378
                 fk_compony = customerMapper.selectByName(fk_compony_name, belongId);
379 379
                 if (customer == null) {
380
-                    err += "未找到名为\"" + customerName + "\"的客户名称;";
380
+                    err += "未找到名或简称为\"" + customerName + "\"的客户名称;";
381 381
                     throw new Exception(err);
382 382
                 }
383 383
                 store.setFkComponyId(fk_compony.getId());

+ 9
- 0
src/main/java/com/th/demo/service/maint/CargoService.java View File

@@ -0,0 +1,9 @@
1
+package com.th.demo.service.maint;
2
+
3
+public interface CargoService {
4
+    String query(int page, int rows, String uperCustomer, String Customer ,String userId, String belongId);
5
+
6
+    String save(String json, String userId, String belongId);
7
+
8
+    String remove(String id, String userId, String belongId);
9
+}

+ 7
- 7
src/main/resource/localhost/db.properties View File

@@ -1,14 +1,14 @@
1
-#jdbc.driverClass=com.mysql.jdbc.Driver
2
-#jdbc.jdbcUrl=jdbc:mysql://172.18.200.32:3306/ware_mj?useUnicode=true&characterEncoding=utf8
3
-#jdbc.user=root
4
-#jdbc.password=root
5
-
6
-#???????????????????????????????
7 1
 jdbc.driverClass=com.mysql.jdbc.Driver
8
-jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ware_mj?characterEncoding=utf8
2
+jdbc.jdbcUrl=jdbc:mysql://172.18.200.32:3306/ware_mj?useUnicode=true&characterEncoding=utf8
9 3
 jdbc.user=root
10 4
 jdbc.password=root
11 5
 
6
+#???????????????????????????????
7
+#jdbc.driverClass=com.mysql.jdbc.Driver
8
+#jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ware_mj?characterEncoding=utf8
9
+#jdbc.user=root
10
+#jdbc.password=root
11
+
12 12
 #jdbc.driverClass=com.mysql.jdbc.Driver
13 13
 #jdbc.jdbcUrl=jdbc:mysql://60.205.9.174:3309/thware?useUnicode=true&characterEncoding=utf8
14 14
 #jdbc.user=root

+ 31
- 85
src/main/resource/mapper/maint/CargoMapper.xml View File

@@ -4,50 +4,34 @@
4 4
     <resultMap id="BaseResultMap" type="com.th.demo.model.maint.Cargo" >
5 5
         <id column="id" property="id" jdbcType="VARCHAR" />
6 6
         <result column="sum_weight" property="sumWeight" jdbcType="DOUBLE" />
7
+        <result column="belong_id" property="belongId" jdbcType="DOUBLE" />
7 8
 
8 9
         <association  column="uper_customer_id" property="uperCustomer" select="com.th.demo.mapping.maint.CustomerMapper.selectByPrimaryKey" />
9 10
         <association  column="customer_id" property="Customer" select="com.th.demo.mapping.maint.CustomerMapper.selectByPrimaryKey" />
10 11
     </resultMap>
11 12
 
12 13
     <sql id="Base_Column_List" >
13
-        id, ware_id, name, code, add_id, add_time, modify_id, modify_time, cancel_id, cancel_time,
14
-    cancel_flag, belong_id
14
+        id, uper_customer_id, customer_id, sum_weight, belong_id
15 15
     </sql>
16 16
 
17 17
     <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
18 18
         select
19 19
         <include refid="Base_Column_List" />
20
-        from t_maint_area
20
+        from t_maint_cargo
21 21
         where id = #{param1,jdbcType=VARCHAR}
22 22
     </select>
23 23
 
24
-    <select id="selectByWareId" resultMap="BaseResultMap" >
25
-        select t.*
26
-        from t_maint_area t
27
-        where t.ware_id =  #{param1,jdbcType=VARCHAR}
28
-          and   t.belong_id =  #{param2,jdbcType=VARCHAR}
29
-          and ifnull(t.cancel_flag,'0') = '0'
30
-        order by t.code
31
-    </select>
32
-
33 24
     <update id="updateByPrimaryKey" parameterType="com.th.demo.model.maint.Cargo" >
34
-        update t_maint_area
35
-        set ware_id = #{ware.id,jdbcType=VARCHAR},
36
-            name = #{name,jdbcType=VARCHAR},
37
-            code = #{code,jdbcType=VARCHAR},
38
-            add_id = #{addId,jdbcType=VARCHAR},
39
-            add_time = #{addTime,jdbcType=TIMESTAMP},
40
-            modify_id = #{modifyId,jdbcType=VARCHAR},
41
-            modify_time = #{modifyTime,jdbcType=TIMESTAMP},
42
-            cancel_id = #{cancelId,jdbcType=VARCHAR},
43
-            cancel_time = #{cancelTime,jdbcType=TIMESTAMP},
44
-            cancel_flag = #{cancelFlag,jdbcType=VARCHAR},
25
+        update t_maint_cargo
26
+        set uper_customer_id = #{uperCustomer.id ,jdbcType=VARCHAR},
27
+            customer_id = #{Customer.id ,jdbcType=VARCHAR},
28
+            sum_weight = #{sumWeight,jdbcType=DOUBLE},
45 29
             belong_id = #{belongId,jdbcType=VARCHAR}
46 30
         where id = #{id,jdbcType=VARCHAR}
47 31
     </update>
48 32
 
49 33
     <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
50
-        delete from t_maint_area
34
+        delete from t_maint_cargo
51 35
         where id = #{param1,jdbcType=VARCHAR}
52 36
     </delete>
53 37
 
@@ -57,70 +41,32 @@
57 41
         </selectKey>
58 42
 
59 43
 
60
-        insert into t_maint_area (id, ware_id, name,
61
-        code, add_id, add_time,
62
-        modify_id, modify_time, cancel_id,
63
-        cancel_time, cancel_flag, belong_id)
64
-        values (#{id,jdbcType=VARCHAR}, #{ware.id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
65
-        #{code,jdbcType=VARCHAR}, #{addId,jdbcType=VARCHAR}, #{addTime,jdbcType=TIMESTAMP},
66
-        #{modifyId,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP}, #{cancelId,jdbcType=VARCHAR},
67
-        #{cancelTime,jdbcType=TIMESTAMP}, #{cancelFlag,jdbcType=VARCHAR}, #{belongId,jdbcType=VARCHAR})
44
+        insert into t_maint_cargo (id, uper_customer_id, customer_id,
45
+        sum_weight, belong_id)
46
+        values (#{id,jdbcType=VARCHAR}, #{uperCustomer.id,jdbcType=VARCHAR}, #{Customer.id,jdbcType=VARCHAR},
47
+        #{sumWeight,jdbcType=DOUBLE}, #{belongId,jdbcType=VARCHAR})
68 48
     </insert>
69 49
 
50
+    <select id="selectAll" resultMap="BaseResultMap" >
51
+        select *
52
+        from t_maint_cargo
53
+        where 1=1
54
+        <if test="param1 != null and param1 != ''" >
55
+            and uper_customer_id = #{param1,jdbcType=VARCHAR}
56
+        </if>
57
+        <if test="param2 != null and param2 != ''" >
58
+            and customer_id = #{param2,jdbcType=VARCHAR}
59
+        </if>
60
+          and belong_id = #{param3,jdbcType=VARCHAR}
61
+    </select>
70 62
 
71
-    <update id="updateByPrimaryKeySelective" parameterType="com.th.demo.model.maint.Cargo" >
72
-        update t_maint_stack
73
-        <set >
74
-            <if test="wareId != null" >
75
-                ware_id = #{wareId,jdbcType=VARCHAR},
76
-            </if>
77
-            <if test="name != null" >
78
-                name = #{name,jdbcType=VARCHAR},
79
-            </if>
80
-            <if test="code != null" >
81
-                code = #{code,jdbcType=VARCHAR},
82
-            </if>
83
-            <if test="addId != null" >
84
-                add_id = #{addId,jdbcType=VARCHAR},
85
-            </if>
86
-            <if test="addTime != null" >
87
-                add_time = #{addTime,jdbcType=TIMESTAMP},
88
-            </if>
89
-            <if test="modifyId != null" >
90
-                modify_id = #{modifyId,jdbcType=VARCHAR},
91
-            </if>
92
-            <if test="modifyTime != null" >
93
-                modify_time = #{modifyTime,jdbcType=TIMESTAMP},
94
-            </if>
95
-            <if test="cancelId != null" >
96
-                cancel_id = #{cancelId,jdbcType=VARCHAR},
97
-            </if>
98
-            <if test="cancelTime != null" >
99
-                cancel_time = #{cancelTime,jdbcType=TIMESTAMP},
100
-            </if>
101
-            <if test="cancelFlag != null" >
102
-                cancel_flag = #{cancelFlag,jdbcType=VARCHAR},
103
-            </if>
104
-            <if test="belongId != null" >
105
-                belong_id = #{belongId,jdbcType=VARCHAR},
106
-            </if>
107
-        </set>
108
-        where id = #{id,jdbcType=VARCHAR}
109
-    </update>
110
-
111
-
112
-
113
-    <select id="selectByWareNameStackName" resultMap="BaseResultMap" >
114
-        select t.*
115
-        from t_maint_stack t ,t_maint_ware d
116
-        where t.ware_id = d.id
117
-          and d.id in  (
118
-            select  a.ware_id from t_maint_userware a where  a.user_id = #{param3,jdbcType=VARCHAR}
119
-        )  and d.name = #{param1,jdbcType=VARCHAR}
120
-          and t.name = #{param2,jdbcType=VARCHAR}
121
-          and   t.belong_id = #{param4,jdbcType=VARCHAR}
122
-          and ifnull(t.cancel_flag,'0') = '0'
123
-        order by t.code
63
+    <select id="selectByByFkAndCustomer" resultMap="BaseResultMap" >
64
+        select *
65
+        from t_maint_cargo
66
+        where 1=1
67
+          and uper_customer_id = #{param1,jdbcType=VARCHAR}
68
+          and customer_id = #{param2,jdbcType=VARCHAR}
69
+          and belong_id = #{param3,jdbcType=VARCHAR}
124 70
     </select>
125 71
 
126 72
 </mapper>

+ 2
- 1
src/main/resource/mapper/maint/CustomerMapper.xml View File

@@ -215,7 +215,7 @@
215 215
   <select id="selectByName" resultMap="BaseResultMap" >
216 216
     select *
217 217
     from t_maint_customer
218
-    where name = #{param1,jdbcType=VARCHAR}
218
+    where (name = #{param1,jdbcType=VARCHAR} or code = #{param1,jdbcType=VARCHAR})
219 219
     and   belong_id = #{param2,jdbcType=VARCHAR}
220 220
     and ifnull(cancel_flag,'0') = '0'
221 221
   </select>
@@ -227,4 +227,5 @@
227 227
       and ifnull(cancel_flag,'0') = '0'
228 228
   </select>
229 229
 
230
+
230 231
 </mapper>

Loading…
Cancel
Save