浏览代码

价格管理

FEI 7 个月前
父节点
当前提交
e26635635f

+ 116
- 0
sto/src/main/java/com/shinsoft/sto/controller/main/CargoChangeRecordController.java 查看文件

@@ -0,0 +1,116 @@
1
+package com.shinsoft.sto.controller.main;
2
+
3
+import com.shinsoft.tools.JSONTools;
4
+import com.shinsoft.tools.model.common.ResponseCodeMsg;
5
+import com.shinsoft.tools.model.common.ResultJSON;
6
+import com.shinsoft.sto.service.main.CargoChangeRecordService;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.web.bind.annotation.RequestMapping;
9
+import org.springframework.web.bind.annotation.RequestParam;
10
+import org.springframework.web.bind.annotation.RestController;
11
+
12
+import javax.servlet.http.HttpServletRequest;
13
+import java.util.HashMap;
14
+import java.util.Map;
15
+
16
+@RestController
17
+@RequestMapping("/CargoChangeRecord")
18
+public class CargoChangeRecordController {
19
+
20
+    @Autowired
21
+    private CargoChangeRecordService cargoChangeRecordService;
22
+
23
+    ResultJSON resultJSON;
24
+
25
+    @RequestMapping(value = "/query")
26
+    public ResultJSON query(@RequestParam(defaultValue = "1") Integer page,
27
+                            @RequestParam(defaultValue = "10") Integer rows,
28
+                            @RequestParam(required = false) String uperCustomerId,
29
+                            @RequestParam(required = false) String customerId,
30
+                            @RequestParam(required = false) String startDate,
31
+                            @RequestParam(required = false) String endDate,
32
+                            @RequestParam(required = false) String subStr,
33
+                            @RequestParam(required = false) String changeFrom,
34
+                            HttpServletRequest request) {
35
+        try {
36
+            String userId = (String) request.getHeader("userId");
37
+            Map<String, Object> params = new HashMap<>();
38
+            if (uperCustomerId != null) {
39
+                params.put("uperCustomerId", uperCustomerId);
40
+            }
41
+            if (customerId != null) {
42
+                params.put("customerId", customerId);
43
+            }
44
+            if (startDate != null) {
45
+                params.put("startDate", startDate);
46
+            }
47
+            if (endDate != null) {
48
+                params.put("endDate", endDate);
49
+            }
50
+            if (subStr != null) {
51
+                params.put("subStr", subStr);
52
+            }
53
+            if (changeFrom != null) {
54
+                params.put("changeFrom", changeFrom);
55
+            }
56
+            resultJSON = cargoChangeRecordService.query(page, rows, params);
57
+        } catch (Exception ex) {
58
+            ex.printStackTrace();
59
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
60
+        } finally {
61
+            return resultJSON;
62
+        }
63
+    }
64
+
65
+    @RequestMapping(value = "/queryByPK")
66
+    public ResultJSON queryByPK(@RequestParam String id, HttpServletRequest request) {
67
+        try {
68
+            String userId = (String) request.getHeader("userId");
69
+            resultJSON = cargoChangeRecordService.queryByPK(id);
70
+        } catch (Exception ex) {
71
+            ex.printStackTrace();
72
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
73
+        } finally {
74
+            return resultJSON;
75
+        }
76
+    }
77
+
78
+    @RequestMapping(value = "/save")
79
+    public ResultJSON save(@RequestParam String json, HttpServletRequest request) {
80
+        try {
81
+            String userId = (String) request.getHeader("userId");
82
+            resultJSON = cargoChangeRecordService.save(userId, json);
83
+        } catch (Exception ex) {
84
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
85
+            ex.printStackTrace();
86
+        } finally {
87
+            return resultJSON;
88
+        }
89
+    }
90
+
91
+    @RequestMapping(value = "/remove")
92
+    public ResultJSON remove(@RequestParam String id, HttpServletRequest request) {
93
+        try {
94
+            String userId = (String) request.getHeader("userId");
95
+            resultJSON = cargoChangeRecordService.remove(userId, id);
96
+        } catch (Exception ex) {
97
+            ex.printStackTrace();
98
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
99
+        } finally {
100
+            return resultJSON;
101
+        }
102
+    }
103
+
104
+    @RequestMapping(value = "/removeBatch")
105
+    public ResultJSON removeBatch(@RequestParam String ids, HttpServletRequest request) {
106
+        try {
107
+            String userId = (String) request.getHeader("userId");
108
+            resultJSON = cargoChangeRecordService.removeBatch(userId, ids);
109
+        } catch (Exception ex) {
110
+            ex.printStackTrace();
111
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
112
+        } finally {
113
+            return resultJSON;
114
+        }
115
+    }
116
+}

+ 113
- 0
sto/src/main/java/com/shinsoft/sto/controller/main/CargoController.java 查看文件

@@ -0,0 +1,113 @@
1
+package com.shinsoft.sto.controller.main;
2
+
3
+import com.shinsoft.tools.JSONTools;
4
+import com.shinsoft.tools.model.common.ResponseCodeMsg;
5
+import com.shinsoft.tools.model.common.ResultJSON;
6
+import com.shinsoft.sto.service.main.CargoService;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.web.bind.annotation.RequestMapping;
9
+import org.springframework.web.bind.annotation.RequestParam;
10
+import org.springframework.web.bind.annotation.RestController;
11
+
12
+import javax.servlet.http.HttpServletRequest;
13
+import java.util.HashMap;
14
+import java.util.Map;
15
+
16
+@RestController
17
+@RequestMapping("/Cargo")
18
+public class CargoController {
19
+
20
+    @Autowired
21
+    private CargoService cargoService;
22
+
23
+    ResultJSON resultJSON;
24
+
25
+    @RequestMapping(value = "/query")
26
+    public ResultJSON query(@RequestParam(defaultValue = "1") Integer page,
27
+                            @RequestParam(defaultValue = "10") Integer rows,
28
+                            @RequestParam(required = false) String uperCustomerId,
29
+                            @RequestParam(required = false) String customerId,
30
+                            HttpServletRequest request) {
31
+        try {
32
+            String userId = (String) request.getHeader("userId");
33
+            Map<String, Object> params = new HashMap<>();
34
+            if (uperCustomerId != null && !uperCustomerId.trim().isEmpty()) {
35
+                params.put("uperCustomerId", uperCustomerId);
36
+            }
37
+            if (customerId != null && !customerId.trim().isEmpty()) {
38
+                params.put("customerId", customerId);
39
+            }
40
+            resultJSON = cargoService.query(page, rows, params);
41
+        } catch (Exception ex) {
42
+            ex.printStackTrace();
43
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
44
+        } finally {
45
+            return resultJSON;
46
+        }
47
+    }
48
+
49
+    @RequestMapping(value = "/queryByPK")
50
+    public ResultJSON queryByPK(@RequestParam String id, HttpServletRequest request) {
51
+        try {
52
+            String userId = (String) request.getHeader("userId");
53
+            resultJSON = cargoService.queryByPK(id);
54
+        } catch (Exception ex) {
55
+            ex.printStackTrace();
56
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
57
+        } finally {
58
+            return resultJSON;
59
+        }
60
+    }
61
+
62
+    @RequestMapping(value = "/save")
63
+    public ResultJSON save(@RequestParam String json, HttpServletRequest request) {
64
+        try {
65
+            String userId = (String) request.getHeader("userId");
66
+            resultJSON = cargoService.save(userId, json);
67
+        } catch (Exception ex) {
68
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
69
+            ex.printStackTrace();
70
+        } finally {
71
+            return resultJSON;
72
+        }
73
+    }
74
+
75
+    @RequestMapping(value = "/transfer")
76
+    public ResultJSON transfer(@RequestParam String json, HttpServletRequest request) {
77
+        try {
78
+            String userId = (String) request.getHeader("userId");
79
+            resultJSON = cargoService.transfer(userId, json);
80
+        } catch (Exception ex) {
81
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
82
+            ex.printStackTrace();
83
+        } finally {
84
+            return resultJSON;
85
+        }
86
+    }
87
+
88
+    @RequestMapping(value = "/remove")
89
+    public ResultJSON remove(@RequestParam String id, HttpServletRequest request) {
90
+        try {
91
+            String userId = (String) request.getHeader("userId");
92
+            resultJSON = cargoService.remove(userId, id);
93
+        } catch (Exception ex) {
94
+            ex.printStackTrace();
95
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
96
+        } finally {
97
+            return resultJSON;
98
+        }
99
+    }
100
+
101
+    @RequestMapping(value = "/removeBatch")
102
+    public ResultJSON removeBatch(@RequestParam String ids, HttpServletRequest request) {
103
+        try {
104
+            String userId = (String) request.getHeader("userId");
105
+            resultJSON = cargoService.removeBatch(userId, ids);
106
+        } catch (Exception ex) {
107
+            ex.printStackTrace();
108
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
109
+        } finally {
110
+            return resultJSON;
111
+        }
112
+    }
113
+}

+ 16
- 0
sto/src/main/java/com/shinsoft/sto/mapper/main/CargoChangeRecordMapper.java 查看文件

@@ -0,0 +1,16 @@
1
+package com.shinsoft.sto.mapper.main;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
+import com.shinsoft.sto.model.main.CargoChangeRecord;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.Map;
9
+
10
+public interface CargoChangeRecordMapper extends BaseMapper<CargoChangeRecord> {
11
+
12
+    /**
13
+     * 分页查询货权变更记录
14
+     */
15
+    Page<CargoChangeRecord> selectCargoChangeRecordPage(Page<CargoChangeRecord> page, @Param("params") Map<String, Object> params);
16
+}

+ 86
- 0
sto/src/main/java/com/shinsoft/sto/mapper/main/CargoChangeRecordMapper.xml 查看文件

@@ -0,0 +1,86 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.shinsoft.sto.mapper.main.CargoChangeRecordMapper">
4
+
5
+    <resultMap id="BaseResultMap" type="com.shinsoft.sto.model.main.CargoChangeRecord">
6
+        <id column="id" property="id" jdbcType="VARCHAR"/>
7
+        <result column="process_instance_id" property="processInstanceId" jdbcType="VARCHAR"/>
8
+        <result column="process_instance_status" property="processInstanceStatus" jdbcType="VARCHAR"/>
9
+        <result column="add_id" property="addId" jdbcType="VARCHAR"/>
10
+        <result column="add_code" property="addCode" jdbcType="VARCHAR"/>
11
+        <result column="add_name" property="addName" jdbcType="VARCHAR"/>
12
+        <result column="add_dept_id" property="addDeptId" jdbcType="VARCHAR"/>
13
+        <result column="add_dept_code" property="addDeptCode" jdbcType="VARCHAR"/>
14
+        <result column="add_dept_name" property="addDeptName" jdbcType="VARCHAR"/>
15
+        <result column="add_time" property="addTime" jdbcType="TIMESTAMP"/>
16
+        <result column="modify_id" property="modifyId" jdbcType="VARCHAR"/>
17
+        <result column="modify_code" property="modifyCode" jdbcType="VARCHAR"/>
18
+        <result column="modify_name" property="modifyName" jdbcType="VARCHAR"/>
19
+        <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/>
20
+        <result column="cancel_id" property="cancelId" jdbcType="VARCHAR"/>
21
+        <result column="cancel_code" property="cancelCode" jdbcType="VARCHAR"/>
22
+        <result column="cancel_name" property="cancelName" jdbcType="VARCHAR"/>
23
+        <result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP"/>
24
+        <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR"/>
25
+        <result column="belong_id" property="belongId" jdbcType="VARCHAR"/>
26
+        <result column="weight" property="weight" jdbcType="NUMERIC"/>
27
+        <result column="change_from" property="changeFrom" jdbcType="VARCHAR"/>
28
+        <result column="sub_str" property="subStr" jdbcType="VARCHAR"/>
29
+        <result column="uper_customer_id" property="uperCustomerId" jdbcType="VARCHAR"/>
30
+        <result column="customer_id" property="customerId" jdbcType="VARCHAR"/>
31
+        <result column="ord_no" property="ordNo" jdbcType="VARCHAR"/>
32
+        <result column="remark" property="remark" jdbcType="VARCHAR"/>
33
+
34
+        <!-- 关联上游客户信息 -->
35
+        <association property="uperCustomer" javaType="com.shinsoft.sto.model.main.Customer">
36
+            <id column="uper_customer_id" property="id"/>
37
+            <result column="uper_customer_nm" property="customerNm"/>
38
+            <result column="uper_customer_short_nm" property="customerShortNm"/>
39
+        </association>
40
+
41
+        <!-- 关联客户信息 -->
42
+        <association property="customer" javaType="com.shinsoft.sto.model.main.Customer">
43
+            <id column="customer_id" property="id"/>
44
+            <result column="customer_nm" property="customerNm"/>
45
+            <result column="customer_short_nm" property="customerShortNm"/>
46
+        </association>
47
+    </resultMap>
48
+
49
+    <sql id="Base_Column_List">
50
+        r.id, r.process_instance_id, r.process_instance_status, r.add_id, r.add_code, r.add_name,
51
+        r.add_dept_id, r.add_dept_code, r.add_dept_name, r.add_time, r.modify_id, r.modify_code, r.modify_name,
52
+        r.modify_time, r.cancel_id, r.cancel_code, r.cancel_name, r.cancel_time, r.cancel_flag,
53
+        r.belong_id, r.weight, r.change_from, r.sub_str, r.uper_customer_id, r.customer_id, r.ord_no, r.remark,
54
+        uper.customer_nm as uper_customer_nm, uper.customer_short_nm as uper_customer_short_nm,
55
+        cust.customer_nm as customer_nm, cust.customer_short_nm as customer_short_nm
56
+    </sql>
57
+
58
+    <select id="selectCargoChangeRecordPage" resultMap="BaseResultMap">
59
+        select
60
+        <include refid="Base_Column_List"/>
61
+        from T_WARE_CARGOCHANGE_RECORD r
62
+        left join T_MAIN_CUSTOMER uper on r.uper_customer_id = uper.id and uper.cancel_flag = '0'
63
+        left join T_MAIN_CUSTOMER cust on r.customer_id = cust.id and cust.cancel_flag = '0'
64
+        where r.cancel_flag = '0'
65
+        <if test="params.uperCustomerId != null and params.uperCustomerId != ''">
66
+            and r.uper_customer_id = #{params.uperCustomerId}
67
+        </if>
68
+        <if test="params.customerId != null and params.customerId != ''">
69
+            and r.customer_id = #{params.customerId}
70
+        </if>
71
+        <if test="params.startDate != null and params.startDate != ''">
72
+            and r.modify_time >= to_date(#{params.startDate}, 'yyyy-MM-dd')
73
+        </if>
74
+        <if test="params.endDate != null and params.endDate != ''">
75
+            and r.modify_time &lt; to_date(#{params.endDate}, 'yyyy-MM-dd') + 1
76
+        </if>
77
+        <if test="params.subStr != null and params.subStr != ''">
78
+            and r.sub_str = #{params.subStr}
79
+        </if>
80
+        <if test="params.changeFrom != null and params.changeFrom != ''">
81
+            and r.change_from = #{params.changeFrom}
82
+        </if>
83
+        order by r.modify_time desc
84
+    </select>
85
+
86
+</mapper>

+ 24
- 0
sto/src/main/java/com/shinsoft/sto/mapper/main/CargoMapper.java 查看文件

@@ -0,0 +1,24 @@
1
+package com.shinsoft.sto.mapper.main;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
+import com.shinsoft.sto.model.main.Cargo;
6
+import org.apache.ibatis.annotations.Param;
7
+import org.apache.ibatis.annotations.Select;
8
+
9
+import java.util.List;
10
+import java.util.Map;
11
+
12
+public interface CargoMapper extends BaseMapper<Cargo> {
13
+
14
+    /**
15
+     * 分页查询货权信息
16
+     */
17
+    Page<Cargo> selectCargoPage(Page<Cargo> page, @Param("params") Map<String, Object> params);
18
+
19
+    /**
20
+     * 根据上游客户ID和客户ID查询货权信息
21
+     */
22
+    @Select("SELECT * FROM T_MAIN_CARGO WHERE cancel_flag = '0' AND uper_customer_id = #{uperCustomerId} AND customer_id = #{customerId}")
23
+    List<Cargo> selectByCustomerIds(@Param("uperCustomerId") String uperCustomerId, @Param("customerId") String customerId);
24
+}

+ 71
- 0
sto/src/main/java/com/shinsoft/sto/mapper/main/CargoMapper.xml 查看文件

@@ -0,0 +1,71 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.shinsoft.sto.mapper.main.CargoMapper">
4
+
5
+    <resultMap id="BaseResultMap" type="com.shinsoft.sto.model.main.Cargo">
6
+        <id column="id" property="id" jdbcType="VARCHAR"/>
7
+        <result column="process_instance_id" property="processInstanceId" jdbcType="VARCHAR"/>
8
+        <result column="process_instance_status" property="processInstanceStatus" jdbcType="VARCHAR"/>
9
+        <result column="add_id" property="addId" jdbcType="VARCHAR"/>
10
+        <result column="add_code" property="addCode" jdbcType="VARCHAR"/>
11
+        <result column="add_name" property="addName" jdbcType="VARCHAR"/>
12
+        <result column="add_dept_id" property="addDeptId" jdbcType="VARCHAR"/>
13
+        <result column="add_dept_code" property="addDeptCode" jdbcType="VARCHAR"/>
14
+        <result column="add_dept_name" property="addDeptName" jdbcType="VARCHAR"/>
15
+        <result column="add_time" property="addTime" jdbcType="TIMESTAMP"/>
16
+        <result column="modify_id" property="modifyId" jdbcType="VARCHAR"/>
17
+        <result column="modify_code" property="modifyCode" jdbcType="VARCHAR"/>
18
+        <result column="modify_name" property="modifyName" jdbcType="VARCHAR"/>
19
+        <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/>
20
+        <result column="cancel_id" property="cancelId" jdbcType="VARCHAR"/>
21
+        <result column="cancel_code" property="cancelCode" jdbcType="VARCHAR"/>
22
+        <result column="cancel_name" property="cancelName" jdbcType="VARCHAR"/>
23
+        <result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP"/>
24
+        <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR"/>
25
+        <result column="belong_id" property="belongId" jdbcType="VARCHAR"/>
26
+        <result column="uper_customer_id" property="uperCustomerId" jdbcType="VARCHAR"/>
27
+        <result column="customer_id" property="customerId" jdbcType="VARCHAR"/>
28
+        <result column="sum_weight" property="sumWeight" jdbcType="NUMERIC"/>
29
+        <result column="use_weight" property="useWeight" jdbcType="NUMERIC"/>
30
+
31
+        <!-- 关联上游客户信息 -->
32
+        <association property="uperCustomer" javaType="com.shinsoft.sto.model.main.Customer">
33
+            <id column="uper_customer_id" property="id"/>
34
+            <result column="uper_customer_nm" property="customerNm"/>
35
+            <result column="uper_customer_short_nm" property="customerShortNm"/>
36
+        </association>
37
+
38
+        <!-- 关联客户信息 -->
39
+        <association property="customer" javaType="com.shinsoft.sto.model.main.Customer">
40
+            <id column="customer_id" property="id"/>
41
+            <result column="customer_nm" property="customerNm"/>
42
+            <result column="customer_short_nm" property="customerShortNm"/>
43
+        </association>
44
+    </resultMap>
45
+
46
+    <sql id="Base_Column_List">
47
+        c.id, c.process_instance_id, c.process_instance_status, c.add_id, c.add_code, c.add_name,
48
+        c.add_dept_id, c.add_dept_code, c.add_dept_name, c.add_time, c.modify_id, c.modify_code, c.modify_name,
49
+        c.modify_time, c.cancel_id, c.cancel_code, c.cancel_name, c.cancel_time, c.cancel_flag,
50
+        c.belong_id, c.uper_customer_id, c.customer_id, c.sum_weight, c.use_weight,
51
+        uper.customer_nm as uper_customer_nm, uper.customer_short_nm as uper_customer_short_nm,
52
+        cust.customer_nm as customer_nm, cust.customer_short_nm as customer_short_nm
53
+    </sql>
54
+
55
+    <select id="selectCargoPage" resultMap="BaseResultMap">
56
+        select
57
+        <include refid="Base_Column_List"/>
58
+        from T_MAIN_CARGO c
59
+        left join T_MAIN_CUSTOMER uper on c.uper_customer_id = uper.id and uper.cancel_flag = '0'
60
+        left join T_MAIN_CUSTOMER cust on c.customer_id = cust.id and cust.cancel_flag = '0'
61
+        where c.cancel_flag = '0'
62
+        <if test="params.uperCustomerId != null and params.uperCustomerId != ''">
63
+            and c.uper_customer_id = #{params.uperCustomerId}
64
+        </if>
65
+        <if test="params.customerId != null and params.customerId != ''">
66
+            and c.customer_id = #{params.customerId}
67
+        </if>
68
+        order by c.add_time desc
69
+    </select>
70
+
71
+</mapper>

+ 51
- 0
sto/src/main/java/com/shinsoft/sto/model/main/Cargo.java 查看文件

@@ -0,0 +1,51 @@
1
+package com.shinsoft.sto.model.main;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableField;
4
+import com.baomidou.mybatisplus.annotation.TableName;
5
+import com.shinsoft.generator.model.BaseModel;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Getter;
9
+import lombok.Setter;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.math.BigDecimal;
13
+
14
+@Getter
15
+@Setter
16
+@Accessors(chain = true)
17
+@TableName("T_MAIN_CARGO")
18
+@ApiModel(value = "货权管理", description = "货权管理信息表")
19
+public class Cargo extends BaseModel {
20
+
21
+    @ApiModelProperty("上游客户ID")
22
+    private String uperCustomerId;
23
+
24
+    @ApiModelProperty("客户ID")
25
+    private String customerId;
26
+
27
+    @ApiModelProperty("可进行货权转移的重量")
28
+    private BigDecimal sumWeight = BigDecimal.ZERO;
29
+
30
+    @ApiModelProperty("使用重量")
31
+    private BigDecimal useWeight = BigDecimal.ZERO;
32
+
33
+    // 关联上游客户信息
34
+    @TableField(exist = false)
35
+    @ApiModelProperty("上游客户信息")
36
+    private Customer uperCustomer;
37
+
38
+    // 关联客户信息
39
+    @TableField(exist = false)
40
+    @ApiModelProperty("客户信息")
41
+    private Customer customer;
42
+
43
+    // 为了方便前端显示,添加客户名称字段
44
+    @TableField(exist = false)
45
+    @ApiModelProperty("上游客户名称")
46
+    private String uperCustomerName;
47
+
48
+    @TableField(exist = false)
49
+    @ApiModelProperty("客户名称")
50
+    private String customerName;
51
+}

+ 51
- 0
sto/src/main/java/com/shinsoft/sto/model/main/CargoChangeRecord.java 查看文件

@@ -0,0 +1,51 @@
1
+package com.shinsoft.sto.model.main;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableField;
4
+import com.baomidou.mybatisplus.annotation.TableName;
5
+import com.shinsoft.generator.model.BaseModel;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Getter;
9
+import lombok.Setter;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.math.BigDecimal;
13
+
14
+@Getter
15
+@Setter
16
+@Accessors(chain = true)
17
+@TableName("T_WARE_CARGOCHANGE_RECORD")
18
+@ApiModel(value = "货权变更记录", description = "货权重量变更履历表")
19
+public class CargoChangeRecord extends BaseModel {
20
+
21
+    @ApiModelProperty("重量")
22
+    private BigDecimal weight = BigDecimal.ZERO;
23
+
24
+    @ApiModelProperty("修改信息来源")
25
+    private String changeFrom;
26
+
27
+    @ApiModelProperty("增减情况")
28
+    private String subStr;
29
+
30
+    @ApiModelProperty("上游客户ID")
31
+    private String uperCustomerId;
32
+
33
+    @ApiModelProperty("下游客户ID")
34
+    private String customerId;
35
+
36
+    @ApiModelProperty("订单号")
37
+    private String ordNo;
38
+
39
+    @ApiModelProperty("备注")
40
+    private String remark;
41
+
42
+    // 关联上游客户信息
43
+    @TableField(exist = false)
44
+    @ApiModelProperty("上游客户信息")
45
+    private Customer uperCustomer;
46
+
47
+    // 关联客户信息
48
+    @TableField(exist = false)
49
+    @ApiModelProperty("客户信息")
50
+    private Customer customer;
51
+}

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

@@ -0,0 +1,116 @@
1
+package com.shinsoft.sto.service.impl.main;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.alibaba.fastjson.TypeReference;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import com.shinsoft.sto.mapper.main.CargoChangeRecordMapper;
8
+import com.shinsoft.sto.model.main.CargoChangeRecord;
9
+import com.shinsoft.sto.service.main.CargoChangeRecordService;
10
+import com.shinsoft.tools.JSONTools;
11
+import com.shinsoft.tools.model.common.ResponseCodeMsg;
12
+import com.shinsoft.tools.model.common.ResultJSON;
13
+import org.apache.commons.lang3.StringUtils;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.stereotype.Service;
16
+
17
+import java.util.Date;
18
+import java.util.List;
19
+import java.util.Map;
20
+
21
+@Service
22
+public class CargoChangeRecordServiceImp extends ServiceImpl<CargoChangeRecordMapper, CargoChangeRecord> implements CargoChangeRecordService {
23
+
24
+    ResultJSON resultJSON;
25
+
26
+    @Autowired
27
+    CargoChangeRecordMapper cargoChangeRecordMapper;
28
+
29
+    @Override
30
+    public ResultJSON query(Integer page, Integer rows, Map<String, Object> params) {
31
+        try {
32
+            Page<CargoChangeRecord> recordPage = new Page<>(page, rows);
33
+            Page<CargoChangeRecord> list = cargoChangeRecordMapper.selectCargoChangeRecordPage(recordPage, params);
34
+            resultJSON = JSONTools.toResultJSON(list);
35
+        } catch (Exception ex) {
36
+            ex.printStackTrace();
37
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
38
+        }
39
+        return resultJSON;
40
+    }
41
+
42
+    @Override
43
+    public ResultJSON queryByPK(String id) {
44
+        try {
45
+            CargoChangeRecord record = cargoChangeRecordMapper.selectById(id);
46
+            resultJSON = JSONTools.toResultJSON(record);
47
+        } catch (Exception ex) {
48
+            ex.printStackTrace();
49
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
50
+        }
51
+        return resultJSON;
52
+    }
53
+
54
+    @Override
55
+    public ResultJSON save(String userId, String json) {
56
+        try {
57
+            Date date = new Date();
58
+            CargoChangeRecord record = JSON.parseObject(json, new TypeReference<CargoChangeRecord>() {});
59
+
60
+            if (StringUtils.isEmpty(record.getId())) {
61
+                record.setCancelFlag("0");
62
+                record.setAddId(userId);
63
+                record.setAddTime(date);
64
+                cargoChangeRecordMapper.insert(record);
65
+            } else {
66
+                record.setModifyId(userId);
67
+                record.setModifyTime(date);
68
+                cargoChangeRecordMapper.updateById(record);
69
+            }
70
+
71
+            resultJSON = JSONTools.toResultJSON(record);
72
+        } catch (Exception ex) {
73
+            ex.printStackTrace();
74
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
75
+        }
76
+        return resultJSON;
77
+    }
78
+
79
+    @Override
80
+    public ResultJSON remove(String userId, String id) {
81
+        try {
82
+            Date date = new Date();
83
+            CargoChangeRecord record = cargoChangeRecordMapper.selectById(id);
84
+            record.setCancelFlag("1");
85
+            record.setModifyId(userId);
86
+            record.setModifyTime(date);
87
+            cargoChangeRecordMapper.updateById(record);
88
+            resultJSON = JSONTools.toResultJSON("");
89
+        } catch (Exception ex) {
90
+            ex.printStackTrace();
91
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
92
+        }
93
+        return resultJSON;
94
+    }
95
+
96
+    @Override
97
+    public ResultJSON removeBatch(String userId, String ids) {
98
+        try {
99
+            Date date = new Date();
100
+            List<String> list = JSON.parseObject(ids, new TypeReference<List<String>>() {});
101
+            CargoChangeRecord record;
102
+            for (String id : list) {
103
+                record = cargoChangeRecordMapper.selectById(id);
104
+                record.setCancelFlag("1");
105
+                record.setModifyId(userId);
106
+                record.setModifyTime(date);
107
+                cargoChangeRecordMapper.updateById(record);
108
+            }
109
+            resultJSON = JSONTools.toResultJSON("");
110
+        } catch (Exception ex) {
111
+            ex.printStackTrace();
112
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
113
+        }
114
+        return resultJSON;
115
+    }
116
+}

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

@@ -0,0 +1,271 @@
1
+package com.shinsoft.sto.service.impl.main;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.alibaba.fastjson.TypeReference;
5
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
+import com.shinsoft.sto.mapper.main.CargoMapper;
9
+import com.shinsoft.sto.mapper.main.CargoChangeRecordMapper;
10
+import com.shinsoft.sto.model.main.Cargo;
11
+import com.shinsoft.sto.model.main.CargoChangeRecord;
12
+import com.shinsoft.sto.service.main.CargoService;
13
+import com.shinsoft.tools.JSONTools;
14
+import com.shinsoft.tools.model.common.ResponseCodeMsg;
15
+import com.shinsoft.tools.model.common.ResultJSON;
16
+import org.apache.commons.lang3.StringUtils;
17
+import org.springframework.beans.factory.annotation.Autowired;
18
+import org.springframework.stereotype.Service;
19
+import org.springframework.transaction.annotation.Transactional;
20
+
21
+import java.math.BigDecimal;
22
+import java.util.Date;
23
+import java.util.List;
24
+import java.util.Map;
25
+import java.util.UUID;
26
+
27
+@Service
28
+public class CargoServiceImp extends ServiceImpl<CargoMapper, Cargo> implements CargoService {
29
+
30
+    ResultJSON resultJSON;
31
+
32
+    @Autowired
33
+    CargoMapper cargoMapper;
34
+    @Autowired
35
+    CargoChangeRecordMapper cargoChangeRecordMapper;
36
+
37
+    @Override
38
+    public ResultJSON query(Integer page, Integer rows, Map<String, Object> params) {
39
+        try {
40
+            Page<Cargo> cargoPage = new Page<>(page, rows);
41
+            Page<Cargo> list = cargoMapper.selectCargoPage(cargoPage, params);
42
+
43
+            // 设置客户名称,方便前端显示
44
+            if (list.getRecords() != null) {
45
+                for (Cargo cargo : list.getRecords()) {
46
+                    if (cargo.getUperCustomer() != null) {
47
+                        cargo.setUperCustomerName(cargo.getUperCustomer().getCustomerNm());
48
+                    }
49
+                    if (cargo.getCustomer() != null) {
50
+                        cargo.setCustomerName(cargo.getCustomer().getCustomerNm());
51
+                    }
52
+                }
53
+            }
54
+
55
+            resultJSON = JSONTools.toResultJSON(list);
56
+        } catch (Exception ex) {
57
+            ex.printStackTrace();
58
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
59
+        }
60
+        return resultJSON;
61
+    }
62
+    @Override
63
+    public ResultJSON queryByPK(String id) {
64
+        try {
65
+            Cargo cargo = cargoMapper.selectById(id);
66
+            resultJSON = JSONTools.toResultJSON(cargo);
67
+        } catch (Exception ex) {
68
+            ex.printStackTrace();
69
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
70
+        }
71
+        return resultJSON;
72
+    }
73
+    @Override
74
+    public ResultJSON save(String userId, String json) {
75
+        try {
76
+            Date date = new Date();
77
+            Cargo cargo = JSON.parseObject(json, new TypeReference<Cargo>() {});
78
+
79
+            if (StringUtils.isEmpty(cargo.getId())) {
80
+                cargo.setCancelFlag("0");
81
+                cargo.setAddId(userId);
82
+                cargo.setAddTime(date);
83
+                cargoMapper.insert(cargo);
84
+            } else {
85
+                cargo.setModifyId(userId);
86
+                cargo.setModifyTime(date);
87
+                cargoMapper.updateById(cargo);
88
+            }
89
+
90
+            resultJSON = JSONTools.toResultJSON(cargo);
91
+        } catch (Exception ex) {
92
+            ex.printStackTrace();
93
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
94
+        }
95
+        return resultJSON;
96
+    }
97
+
98
+    @Override
99
+    @Transactional(rollbackFor = Exception.class)
100
+    public ResultJSON transfer(String userId, String json) {
101
+        try {
102
+            Date date = new Date();
103
+            // 解析前端传递的数据
104
+            Map<String, Object> formData = JSON.parseObject(json, new TypeReference<Map<String, Object>>() {});
105
+
106
+            String uperCustomerId = (String) formData.get("uperCustomerId");
107
+            String customerId = (String) formData.get("customerId");
108
+            String subStr = (String) formData.get("subStr"); // 增加/减少
109
+            BigDecimal weight = new BigDecimal(formData.get("weight").toString());
110
+            String ordNo = (String) formData.get("ordNo");
111
+            String remark = (String) formData.get("remark");
112
+
113
+            // 根据上游客户ID和客户ID查询是否已存在货权记录
114
+            QueryWrapper<Cargo> queryWrapper = new QueryWrapper<>();
115
+            queryWrapper.eq("uper_customer_id", uperCustomerId)
116
+                    .eq("customer_id", customerId)
117
+                    .eq("cancel_flag", "0");
118
+            Cargo existingCargo = cargoMapper.selectOne(queryWrapper);
119
+
120
+            Cargo cargo;
121
+            if (existingCargo == null) {
122
+                // 新增记录
123
+                cargo = new Cargo();
124
+                cargo.setId(UUID.randomUUID().toString().replace("-", ""));
125
+                cargo.setUperCustomerId(uperCustomerId);
126
+                cargo.setCustomerId(customerId);
127
+
128
+                if ("增加".equals(subStr)) {
129
+                    // 新增+增加:可使用量=0+重量,已使用量=0
130
+                    cargo.setSumWeight(weight);
131
+                    cargo.setUseWeight(BigDecimal.ZERO);
132
+                } else if ("减少".equals(subStr)) {
133
+                    // 新增+减少:不允许,因为不能从0减少
134
+                    resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, "无法对不存在的记录进行减少操作");
135
+                    return resultJSON;
136
+                } else {
137
+                    // 默认新增:可使用量=0+重量,已使用量=0
138
+                    cargo.setSumWeight(weight);
139
+                    cargo.setUseWeight(BigDecimal.ZERO);
140
+                }
141
+
142
+                cargo.setCancelFlag("0");
143
+                cargo.setAddId(userId);
144
+                cargo.setAddTime(date);
145
+                cargoMapper.insert(cargo);
146
+            } else {
147
+                // 更新现有记录
148
+                cargo = existingCargo;
149
+                BigDecimal oldSumWeight = cargo.getSumWeight() != null ? cargo.getSumWeight() : BigDecimal.ZERO;
150
+                BigDecimal oldUseWeight = cargo.getUseWeight() != null ? cargo.getUseWeight() : BigDecimal.ZERO;
151
+
152
+                if ("增加".equals(subStr)) {
153
+                    // 增加:可使用量=原可使用量+重量,已使用量不变
154
+                    cargo.setSumWeight(oldSumWeight.add(weight));
155
+                } else if ("减少".equals(subStr)) {
156
+                    // 减少:可使用量=原可使用量-重量,已使用量=0+重量
157
+                    if (oldSumWeight.compareTo(weight) < 0) {
158
+                        resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, "减少的重量不能大于当前可使用量");
159
+                        return resultJSON;
160
+                    }
161
+                    cargo.setSumWeight(oldSumWeight.subtract(weight));
162
+                    cargo.setUseWeight(oldUseWeight.add(weight));
163
+                }
164
+
165
+                cargo.setModifyId(userId);
166
+                cargo.setModifyTime(date);
167
+                cargoMapper.updateById(cargo);
168
+            }
169
+
170
+            // 记录货权变更履历
171
+            CargoChangeRecord changeRecord = new CargoChangeRecord();
172
+            changeRecord.setId(UUID.randomUUID().toString().replace("-", ""));
173
+            changeRecord.setWeight(weight);
174
+            changeRecord.setChangeFrom("手动调整");
175
+            changeRecord.setSubStr(subStr);
176
+            changeRecord.setUperCustomerId(uperCustomerId);
177
+            changeRecord.setCustomerId(customerId);
178
+            changeRecord.setOrdNo(ordNo);
179
+            changeRecord.setRemark(remark);
180
+            changeRecord.setCancelFlag("0");
181
+            changeRecord.setAddId(userId);
182
+            changeRecord.setAddTime(date);
183
+            changeRecord.setModifyId(userId);
184
+            changeRecord.setModifyTime(date);
185
+            cargoChangeRecordMapper.insert(changeRecord);
186
+
187
+            resultJSON = JSONTools.toResultJSON(cargo);
188
+        } catch (Exception ex) {
189
+            ex.printStackTrace();
190
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
191
+        }
192
+        return resultJSON;
193
+    }
194
+   /* @Override
195
+    public ResultJSON save(String userId, String json) {
196
+        try {
197
+            Date date = new Date();
198
+            Cargo cargo = JSON.parseObject(json, new TypeReference<Cargo>() {});
199
+
200
+            if (StringUtils.isEmpty(cargo.getId())) {
201
+                cargo.setCancelFlag("0");
202
+                cargo.setAddId(userId);
203
+                cargo.setAddTime(date);
204
+                cargoMapper.insert(cargo);
205
+            } else {
206
+                cargo.setModifyId(userId);
207
+                cargo.setModifyTime(date);
208
+                cargoMapper.updateById(cargo);
209
+            }
210
+
211
+            resultJSON = JSONTools.toResultJSON(cargo);
212
+        } catch (Exception ex) {
213
+            ex.printStackTrace();
214
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
215
+        }
216
+        return resultJSON;
217
+    }
218
+
219
+    @Override
220
+    public ResultJSON transfer(String userId, String json) {
221
+        try {
222
+            Date date = new Date();
223
+            Cargo cargo = JSON.parseObject(json, new TypeReference<Cargo>() {});
224
+            // 这里实现货权转移逻辑,包括记录变更履历
225
+            // 具体实现根据业务需求来写
226
+            resultJSON = JSONTools.toResultJSON(cargo);
227
+        } catch (Exception ex) {
228
+            ex.printStackTrace();
229
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
230
+        }
231
+        return resultJSON;
232
+    }*/
233
+
234
+    @Override
235
+    public ResultJSON remove(String userId, String id) {
236
+        try {
237
+            Date date = new Date();
238
+            Cargo cargo = cargoMapper.selectById(id);
239
+            cargo.setCancelFlag("1");
240
+            cargo.setModifyId(userId);
241
+            cargo.setModifyTime(date);
242
+            cargoMapper.updateById(cargo);
243
+            resultJSON = JSONTools.toResultJSON("");
244
+        } catch (Exception ex) {
245
+            ex.printStackTrace();
246
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
247
+        }
248
+        return resultJSON;
249
+    }
250
+
251
+    @Override
252
+    public ResultJSON removeBatch(String userId, String ids) {
253
+        try {
254
+            Date date = new Date();
255
+            List<String> list = JSON.parseObject(ids, new TypeReference<List<String>>() {});
256
+            Cargo cargo;
257
+            for (String id : list) {
258
+                cargo = cargoMapper.selectById(id);
259
+                cargo.setCancelFlag("1");
260
+                cargo.setModifyId(userId);
261
+                cargo.setModifyTime(date);
262
+                cargoMapper.updateById(cargo);
263
+            }
264
+            resultJSON = JSONTools.toResultJSON("");
265
+        } catch (Exception ex) {
266
+            ex.printStackTrace();
267
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
268
+        }
269
+        return resultJSON;
270
+    }
271
+}

+ 20
- 0
sto/src/main/java/com/shinsoft/sto/service/main/CargoChangeRecordService.java 查看文件

@@ -0,0 +1,20 @@
1
+package com.shinsoft.sto.service.main;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.shinsoft.sto.model.main.CargoChangeRecord;
5
+import com.shinsoft.tools.model.common.ResultJSON;
6
+
7
+import java.util.Map;
8
+
9
+public interface CargoChangeRecordService extends IService<CargoChangeRecord> {
10
+
11
+    ResultJSON query(Integer page, Integer rows, Map<String, Object> params);
12
+
13
+    ResultJSON queryByPK(String id);
14
+
15
+    ResultJSON save(String userId, String json);
16
+
17
+    ResultJSON remove(String userId, String id);
18
+
19
+    ResultJSON removeBatch(String userId, String ids);
20
+}

+ 22
- 0
sto/src/main/java/com/shinsoft/sto/service/main/CargoService.java 查看文件

@@ -0,0 +1,22 @@
1
+package com.shinsoft.sto.service.main;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.shinsoft.sto.model.main.Cargo;
5
+import com.shinsoft.tools.model.common.ResultJSON;
6
+
7
+import java.util.Map;
8
+
9
+public interface CargoService extends IService<Cargo> {
10
+
11
+    ResultJSON query(Integer page, Integer rows, Map<String, Object> params);
12
+
13
+    ResultJSON queryByPK(String id);
14
+
15
+    ResultJSON save(String userId, String json);
16
+
17
+    ResultJSON transfer(String userId, String json);
18
+
19
+    ResultJSON remove(String userId, String id);
20
+
21
+    ResultJSON removeBatch(String userId, String ids);
22
+}

正在加载...
取消
保存