浏览代码

价格管理

FEI 4 个月前
父节点
当前提交
82e9ba3c83

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

@@ -0,0 +1,100 @@
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.PriceService;
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("/Price")
18
+public class PriceController {
19
+
20
+    @Autowired
21
+    private PriceService priceService;
22
+
23
+    ResultJSON resultJSON;
24
+
25
+    @RequestMapping(value = "/query")
26
+    public ResultJSON query(@RequestParam int page,
27
+                            @RequestParam int rows,
28
+                            @RequestParam(required = false) String customerName,
29
+                            @RequestParam(required = false) String materialName,
30
+                            HttpServletRequest request) {
31
+        try {
32
+            String userId = (String) request.getHeader("userId");
33
+            Map<String, Object> params = new HashMap<>();
34
+            if (customerName != null) {
35
+                params.put("customerName", customerName);
36
+            }
37
+            if (materialName != null) {
38
+                params.put("materialName", materialName);
39
+            }
40
+            resultJSON = priceService.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 = priceService.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 = priceService.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 = "/remove")
76
+    public ResultJSON remove(@RequestParam String id, HttpServletRequest request) {
77
+        try {
78
+            String userId = (String) request.getHeader("userId");
79
+            resultJSON = priceService.remove(userId, id);
80
+        } catch (Exception ex) {
81
+            ex.printStackTrace();
82
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
83
+        } finally {
84
+            return resultJSON;
85
+        }
86
+    }
87
+
88
+    @RequestMapping(value = "/removeBatch")
89
+    public ResultJSON removeBatch(@RequestParam String ids, HttpServletRequest request) {
90
+        try {
91
+            String userId = (String) request.getHeader("userId");
92
+            resultJSON = priceService.removeBatch(userId, ids);
93
+        } catch (Exception ex) {
94
+            ex.printStackTrace();
95
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
96
+        } finally {
97
+            return resultJSON;
98
+        }
99
+    }
100
+}

+ 24
- 0
sto/src/main/java/com/shinsoft/sto/mapper/main/PriceMapper.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.Price;
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 PriceMapper extends BaseMapper<Price> {
13
+
14
+    /**
15
+     * 分页查询价格信息
16
+     */
17
+    Page<Price> selectPricePage(Page<Price> page, @Param("params") Map<String, Object> params);
18
+
19
+    /**
20
+     * 根据客户ID查询价格信息
21
+     */
22
+    @Select("SELECT * FROM T_MAIN_PRICE WHERE cancel_flag = '0' AND customer_id = #{customerId}")
23
+    List<Price> selectByCustomerId(String customerId);
24
+}

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

@@ -0,0 +1,72 @@
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.PriceMapper">
4
+
5
+    <resultMap id="BaseResultMap" type="com.shinsoft.sto.model.main.Price">
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_code" property="addDeptCode" jdbcType="VARCHAR"/>
13
+        <result column="add_dept_name" property="addDeptName" jdbcType="VARCHAR"/>
14
+        <result column="add_time" property="addTime" jdbcType="TIMESTAMP"/>
15
+        <result column="modify_id" property="modifyId" jdbcType="VARCHAR"/>
16
+        <result column="modify_code" property="modifyCode" jdbcType="VARCHAR"/>
17
+        <result column="modify_name" property="modifyName" jdbcType="VARCHAR"/>
18
+        <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/>
19
+        <result column="cancel_id" property="cancelId" jdbcType="VARCHAR"/>
20
+        <result column="cancel_code" property="cancelCode" jdbcType="VARCHAR"/>
21
+        <result column="cancel_name" property="cancelName" jdbcType="VARCHAR"/>
22
+        <result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP"/>
23
+        <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR"/>
24
+        <result column="belong_id" property="belongId" jdbcType="VARCHAR"/>
25
+        <result column="customer_id" property="customerId" jdbcType="VARCHAR"/>
26
+        <result column="material_id" property="materialId" jdbcType="VARCHAR"/>
27
+        <result column="storage_price" property="storagePrice" jdbcType="NUMERIC"/>
28
+        <result column="transfer_price" property="transferPrice" jdbcType="NUMERIC"/>
29
+        <result column="weight_price" property="weightPrice" jdbcType="NUMERIC"/>
30
+        <result column="storage_type" property="storageType" jdbcType="VARCHAR"/>
31
+        <result column="material_name" property="materialName" jdbcType="VARCHAR"/>
32
+        <result column="keep_day" property="keepDay" jdbcType="NUMERIC"/>
33
+        <result column="ord_price" property="ordPrice" jdbcType="NUMERIC"/>
34
+        <result column="out_ord_price" property="outOrdPrice" jdbcType="NUMERIC"/>
35
+        <result column="pay_way" property="payWay" jdbcType="VARCHAR"/>
36
+
37
+        <!-- 关联客户信息 -->
38
+        <association property="customer" javaType="com.shinsoft.sto.model.main.Customer">
39
+            <id column="customer_id" property="id"/>
40
+            <result column="customer_nm" property="customerNm"/>
41
+            <result column="customer_short_nm" property="customerShortNm"/>
42
+            <result column="contact_person" property="contactPerson"/>
43
+            <result column="contact_info" property="contactInfo"/>
44
+            <result column="default_address" property="defaultAddress"/>
45
+        </association>
46
+    </resultMap>
47
+
48
+    <sql id="Base_Column_List">
49
+        p.id, p.process_instance_id, p.process_instance_status, p.add_id, p.add_code, p.add_name,
50
+        p.add_dept_code, p.add_dept_name, p.add_time, p.modify_id, p.modify_code, p.modify_name,
51
+        p.modify_time, p.cancel_id, p.cancel_code, p.cancel_name, p.cancel_time, p.cancel_flag,
52
+        p.belong_id, p.customer_id, p.material_id, p.storage_price, p.transfer_price, p.weight_price,
53
+        p.storage_type, p.material_name, p.keep_day, p.ord_price, p.out_ord_price, p.pay_way,
54
+        c.customer_nm, c.customer_short_nm, c.contact_person, c.contact_info, c.default_address
55
+    </sql>
56
+
57
+    <select id="selectPricePage" resultMap="BaseResultMap">
58
+        select
59
+        <include refid="Base_Column_List"/>
60
+        from T_MAIN_PRICE p
61
+        left join T_MAIN_CUSTOMER c on p.customer_id = c.id and c.cancel_flag = '0'
62
+        where p.cancel_flag = '0'
63
+        <if test="params.customerName != null and params.customerName != ''">
64
+            and c.customer_nm like '%' || #{params.customerName} || '%'
65
+        </if>
66
+        <if test="params.materialName != null and params.materialName != ''">
67
+            and p.material_name like '%' || #{params.materialName} || '%'
68
+        </if>
69
+        order by p.add_time desc
70
+    </select>
71
+
72
+</mapper>

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

@@ -0,0 +1,62 @@
1
+package com.shinsoft.sto.model.main;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableField;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import com.shinsoft.generator.model.BaseModel;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Getter;
10
+import lombok.Setter;
11
+import lombok.experimental.Accessors;
12
+
13
+import java.math.BigDecimal;
14
+
15
+@Getter
16
+@Setter
17
+@Accessors(chain = true)
18
+@TableName("T_MAIN_PRICE")
19
+@ApiModel(value = "价格管理", description = "价格管理信息表")
20
+public class Price extends BaseModel {
21
+
22
+    @ApiModelProperty("所属ID")
23
+    private String belongId;
24
+
25
+    @ApiModelProperty("客户ID")
26
+    private String customerId;
27
+
28
+    @ApiModelProperty("物料ID")
29
+    private String materialId;
30
+
31
+    @ApiModelProperty("仓储出库单价(元/吨)")
32
+    private BigDecimal storagePrice;
33
+
34
+    @ApiModelProperty("货权转移单价(元/吨)")
35
+    private BigDecimal transferPrice;
36
+
37
+    @ApiModelProperty("过磅称重单价(元/吨)")
38
+    private BigDecimal weightPrice;
39
+
40
+    @ApiModelProperty("仓储类型")
41
+    private String storageType;
42
+
43
+    @ApiModelProperty("物料名称")
44
+    private String materialName;
45
+
46
+    @ApiModelProperty("保存天数")
47
+    private Integer keepDay;
48
+
49
+    @ApiModelProperty("小于保存天数的价格")
50
+    private BigDecimal ordPrice;
51
+
52
+    @ApiModelProperty("大于保存天数的价格")
53
+    private BigDecimal outOrdPrice;
54
+
55
+    @ApiModelProperty("支付方式")
56
+    private String payWay;
57
+
58
+    // 关联客户信息
59
+    @TableField(exist = false)
60
+    @ApiModelProperty("客户信息")
61
+    private Customer customer;
62
+}

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

@@ -0,0 +1,126 @@
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.PriceMapper;
8
+import com.shinsoft.sto.model.main.Price;
9
+import com.shinsoft.sto.service.main.PriceService;
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
+import org.springframework.util.ObjectUtils;
17
+
18
+import java.util.Date;
19
+import java.util.HashMap;
20
+import java.util.List;
21
+import java.util.Map;
22
+
23
+/**
24
+ * <p>
25
+ * 价格管理 服务实现类
26
+ * </p>
27
+ *
28
+ * @author system
29
+ * @since 2024-10-15
30
+ */
31
+@Service
32
+public class PriceServiceImp extends ServiceImpl<PriceMapper, Price> implements PriceService {
33
+
34
+    ResultJSON resultJSON;
35
+
36
+    @Autowired
37
+    PriceMapper priceMapper;
38
+
39
+    @Override
40
+    public ResultJSON query(int page, int rows, Map<String, Object> params) {
41
+        try {
42
+            Page<Price> pricePage = new Page<>(page, rows);
43
+            Page<Price> list = priceMapper.selectPricePage(pricePage, params);
44
+            resultJSON = JSONTools.toResultJSON(list);
45
+        } catch (Exception ex) {
46
+            ex.printStackTrace();
47
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
48
+        }
49
+        return resultJSON;
50
+    }
51
+
52
+    @Override
53
+    public ResultJSON queryByPK(String id) {
54
+        try {
55
+            Price price = priceMapper.selectById(id);
56
+            resultJSON = JSONTools.toResultJSON(price);
57
+        } catch (Exception ex) {
58
+            ex.printStackTrace();
59
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
60
+        }
61
+        return resultJSON;
62
+    }
63
+
64
+    @Override
65
+    public ResultJSON save(String userId, String json) {
66
+        try {
67
+            Date date = new Date();
68
+            Price price = JSON.parseObject(json, new TypeReference<Price>() {});
69
+
70
+            if (StringUtils.isEmpty(price.getId())) {
71
+                price.setCancelFlag("0");
72
+                price.setAddId(userId);
73
+                price.setAddTime(date);
74
+                priceMapper.insert(price);
75
+            } else {
76
+                price.setModifyId(userId);
77
+                price.setModifyTime(date);
78
+                priceMapper.updateById(price);
79
+            }
80
+
81
+            resultJSON = JSONTools.toResultJSON(price);
82
+        } catch (Exception ex) {
83
+            ex.printStackTrace();
84
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
85
+        }
86
+        return resultJSON;
87
+    }
88
+
89
+    @Override
90
+    public ResultJSON remove(String userId, String id) {
91
+        try {
92
+            Date date = new Date();
93
+            Price price = priceMapper.selectById(id);
94
+            price.setCancelFlag("1");
95
+            price.setModifyId(userId);
96
+            price.setModifyTime(date);
97
+            priceMapper.updateById(price);
98
+            resultJSON = JSONTools.toResultJSON("");
99
+        } catch (Exception ex) {
100
+            ex.printStackTrace();
101
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
102
+        }
103
+        return resultJSON;
104
+    }
105
+
106
+    @Override
107
+    public ResultJSON removeBatch(String userId, String ids) {
108
+        try {
109
+            Date date = new Date();
110
+            List<String> list = JSON.parseObject(ids, new TypeReference<List<String>>() {});
111
+            Price price;
112
+            for (String id : list) {
113
+                price = priceMapper.selectById(id);
114
+                price.setCancelFlag("1");
115
+                price.setModifyId(userId);
116
+                price.setModifyTime(date);
117
+                priceMapper.updateById(price);
118
+            }
119
+            resultJSON = JSONTools.toResultJSON("");
120
+        } catch (Exception ex) {
121
+            ex.printStackTrace();
122
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
123
+        }
124
+        return resultJSON;
125
+    }
126
+}

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

@@ -0,0 +1,28 @@
1
+package com.shinsoft.sto.service.main;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.shinsoft.sto.model.main.Price;
5
+import com.shinsoft.tools.model.common.ResultJSON;
6
+
7
+import java.util.Map;
8
+
9
+/**
10
+ * <p>
11
+ * 价格管理 服务类
12
+ * </p>
13
+ *
14
+ * @author system
15
+ * @since 2024-10-15
16
+ */
17
+public interface PriceService extends IService<Price> {
18
+
19
+    ResultJSON query(int page, int rows, Map<String, Object> params);
20
+
21
+    ResultJSON queryByPK(String id);
22
+
23
+    ResultJSON save(String userId, String json);
24
+
25
+    ResultJSON remove(String userId, String id);
26
+
27
+    ResultJSON removeBatch(String userId, String ids);
28
+}

正在加载...
取消
保存