正在显示
8 个修改的文件
包含
231 行增加
和
11 行删除
1 | package com.sunyo.energy.location.controller; | 1 | package com.sunyo.energy.location.controller; |
2 | 2 | ||
3 | import com.github.pagehelper.PageInfo; | 3 | import com.github.pagehelper.PageInfo; |
4 | -import com.google.gson.internal.$Gson$Preconditions; | ||
5 | import com.sunyo.energy.location.controller.response.ResultJson; | 4 | import com.sunyo.energy.location.controller.response.ResultJson; |
6 | import com.sunyo.energy.location.dao.LocationMapper; | 5 | import com.sunyo.energy.location.dao.LocationMapper; |
7 | import com.sunyo.energy.location.dao.PayRecordsMapper; | 6 | import com.sunyo.energy.location.dao.PayRecordsMapper; |
7 | +import com.sunyo.energy.location.dao.WaterEleCountMoneyMapper; | ||
8 | import com.sunyo.energy.location.model.Location; | 8 | import com.sunyo.energy.location.model.Location; |
9 | import com.sunyo.energy.location.model.PayRecords; | 9 | import com.sunyo.energy.location.model.PayRecords; |
10 | +import com.sunyo.energy.location.model.WaterEleCountMoney; | ||
10 | import com.sunyo.energy.location.service.ElectricityMeterService; | 11 | import com.sunyo.energy.location.service.ElectricityMeterService; |
11 | import com.sunyo.energy.location.service.PayOrderService; | 12 | import com.sunyo.energy.location.service.PayOrderService; |
12 | import com.sunyo.energy.location.service.WaterMeterService; | 13 | import com.sunyo.energy.location.service.WaterMeterService; |
13 | import io.swagger.annotations.Api; | 14 | import io.swagger.annotations.Api; |
14 | import io.swagger.annotations.ApiOperation; | 15 | import io.swagger.annotations.ApiOperation; |
15 | -import io.swagger.models.auth.In; | ||
16 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
17 | -import org.springframework.util.StringUtils; | ||
18 | import org.springframework.web.bind.annotation.*; | 17 | import org.springframework.web.bind.annotation.*; |
19 | 18 | ||
19 | +import java.util.List; | ||
20 | +import java.util.Map; | ||
21 | + | ||
20 | /** | 22 | /** |
21 | * Created by XYH on 2019/12/16. | 23 | * Created by XYH on 2019/12/16. |
22 | * 订单查询,新增,更新,删除 | 24 | * 订单查询,新增,更新,删除 |
@@ -41,10 +43,13 @@ public class PayOrderController { | @@ -41,10 +43,13 @@ public class PayOrderController { | ||
41 | @Autowired | 43 | @Autowired |
42 | private LocationMapper locationMapper; | 44 | private LocationMapper locationMapper; |
43 | 45 | ||
46 | + @Autowired | ||
47 | + WaterEleCountMoneyMapper waterEleCountMoneyMapperl; | ||
48 | + | ||
44 | @ApiOperation(value = "查询缴费订单") | 49 | @ApiOperation(value = "查询缴费订单") |
45 | @RequestMapping("/list") | 50 | @RequestMapping("/list") |
46 | - public PageInfo<PayRecords> getOrder(@RequestParam(value = "pageSize", required = false, defaultValue = "1") int pageSize, | ||
47 | - @RequestParam(value = "pageNum", required = false, defaultValue = "5") int pageNum, | 51 | + public PageInfo<PayRecords> getOrder(@RequestParam(value = "pageSize", required = false, defaultValue = "100000") int pageSize, |
52 | + @RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum, | ||
48 | @RequestParam(value = "orderNumber", required = false) String orderNumber, | 53 | @RequestParam(value = "orderNumber", required = false) String orderNumber, |
49 | @RequestParam(value = "payTime", required = false) String payTime, | 54 | @RequestParam(value = "payTime", required = false) String payTime, |
50 | @RequestParam(value = "username", required = false) String username, | 55 | @RequestParam(value = "username", required = false) String username, |
@@ -133,4 +138,13 @@ public class PayOrderController { | @@ -133,4 +138,13 @@ public class PayOrderController { | ||
133 | } | 138 | } |
134 | } | 139 | } |
135 | 140 | ||
141 | + @ApiOperation(value = "水电剩余余额统计") | ||
142 | + @GetMapping("/waterEleCount") | ||
143 | + public ResultJson waterEleCount() throws Exception { | ||
144 | + | ||
145 | + List<WaterEleCountMoney> waterEleCountMonies = waterEleCountMoneyMapperl.selectByPrimaryKey(); | ||
146 | + | ||
147 | + return new ResultJson("200", "success", waterEleCountMonies); | ||
148 | + } | ||
149 | + | ||
136 | } | 150 | } |
@@ -14,7 +14,7 @@ public interface LocationMapper { | @@ -14,7 +14,7 @@ public interface LocationMapper { | ||
14 | 14 | ||
15 | int insertSelective(Location record); | 15 | int insertSelective(Location record); |
16 | 16 | ||
17 | - List<Location> selectByPrimaryKey(Integer id); | 17 | + List<Location> selectByPrimaryKey(); |
18 | 18 | ||
19 | List<Location> selectAll(Integer id); | 19 | List<Location> selectAll(Integer id); |
20 | 20 |
1 | +package com.sunyo.energy.location.dao; | ||
2 | + | ||
3 | +import com.sunyo.energy.location.model.WaterEleCountMoney; | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +public interface WaterEleCountMoneyMapper { | ||
8 | + int deleteByPrimaryKey(Integer id); | ||
9 | + | ||
10 | + int insert(WaterEleCountMoney record); | ||
11 | + | ||
12 | + int insertSelective(WaterEleCountMoney record); | ||
13 | + | ||
14 | + List<WaterEleCountMoney> selectByPrimaryKey(); | ||
15 | + | ||
16 | + int updateByPrimaryKeySelective(WaterEleCountMoney record); | ||
17 | + | ||
18 | + int updateByPrimaryKey(WaterEleCountMoney record); | ||
19 | +} |
1 | +package com.sunyo.energy.location.model; | ||
2 | + | ||
3 | +import java.math.BigDecimal; | ||
4 | +import java.util.Date; | ||
5 | + | ||
6 | +public class WaterEleCountMoney { | ||
7 | + private Integer id; | ||
8 | + | ||
9 | + private BigDecimal wmMoney; | ||
10 | + | ||
11 | + private BigDecimal emMoney; | ||
12 | + | ||
13 | + private Date createDate; | ||
14 | + | ||
15 | + public Integer getId() { | ||
16 | + return id; | ||
17 | + } | ||
18 | + | ||
19 | + public void setId(Integer id) { | ||
20 | + this.id = id; | ||
21 | + } | ||
22 | + | ||
23 | + public BigDecimal getWmMoney() { | ||
24 | + return wmMoney; | ||
25 | + } | ||
26 | + | ||
27 | + public void setWmMoney(BigDecimal wmMoney) { | ||
28 | + this.wmMoney = wmMoney; | ||
29 | + } | ||
30 | + | ||
31 | + public BigDecimal getEmMoney() { | ||
32 | + return emMoney; | ||
33 | + } | ||
34 | + | ||
35 | + public void setEmMoney(BigDecimal emMoney) { | ||
36 | + this.emMoney = emMoney; | ||
37 | + } | ||
38 | + | ||
39 | + public Date getCreateDate() { | ||
40 | + return createDate; | ||
41 | + } | ||
42 | + | ||
43 | + public void setCreateDate(Date createDate) { | ||
44 | + this.createDate = createDate; | ||
45 | + } | ||
46 | +} |
@@ -3,6 +3,8 @@ package com.sunyo.energy.location.service; | @@ -3,6 +3,8 @@ package com.sunyo.energy.location.service; | ||
3 | import com.github.pagehelper.PageInfo; | 3 | import com.github.pagehelper.PageInfo; |
4 | import com.sunyo.energy.location.model.PayRecords; | 4 | import com.sunyo.energy.location.model.PayRecords; |
5 | 5 | ||
6 | +import java.util.Map; | ||
7 | + | ||
6 | /** | 8 | /** |
7 | * Created by XYH on 2019/12/16. | 9 | * Created by XYH on 2019/12/16. |
8 | */ | 10 | */ |
@@ -15,4 +17,6 @@ public interface PayOrderService { | @@ -15,4 +17,6 @@ public interface PayOrderService { | ||
15 | int ediOrder(PayRecords payRecords); | 17 | int ediOrder(PayRecords payRecords); |
16 | 18 | ||
17 | int delOrder(PayRecords payRecords); | 19 | int delOrder(PayRecords payRecords); |
20 | + | ||
21 | + void waterEleCount() throws Exception; | ||
18 | } | 22 | } |
@@ -3,15 +3,21 @@ package com.sunyo.energy.location.service.imp; | @@ -3,15 +3,21 @@ package com.sunyo.energy.location.service.imp; | ||
3 | import com.github.pagehelper.Page; | 3 | import com.github.pagehelper.Page; |
4 | import com.github.pagehelper.PageHelper; | 4 | import com.github.pagehelper.PageHelper; |
5 | import com.github.pagehelper.PageInfo; | 5 | import com.github.pagehelper.PageInfo; |
6 | +import com.sunyo.energy.location.dao.LocationMapper; | ||
6 | import com.sunyo.energy.location.dao.PayRecordsMapper; | 7 | import com.sunyo.energy.location.dao.PayRecordsMapper; |
7 | -import com.sunyo.energy.location.model.PayRecords; | 8 | +import com.sunyo.energy.location.dao.WaterEleCountMoneyMapper; |
9 | +import com.sunyo.energy.location.model.*; | ||
10 | +import com.sunyo.energy.location.service.ElectricityMeterService; | ||
8 | import com.sunyo.energy.location.service.PayOrderService; | 11 | import com.sunyo.energy.location.service.PayOrderService; |
12 | +import com.sunyo.energy.location.service.WaterMeterService; | ||
13 | +import com.sunyo.energy.location.utils.AllUtils; | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
15 | +import org.springframework.scheduling.annotation.Scheduled; | ||
10 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
11 | import org.springframework.util.StringUtils; | 17 | import org.springframework.util.StringUtils; |
12 | 18 | ||
13 | -import java.util.ArrayList; | ||
14 | -import java.util.List; | 19 | +import java.math.BigDecimal; |
20 | +import java.util.*; | ||
15 | 21 | ||
16 | /** | 22 | /** |
17 | * Created by XYH on 2019/12/16. | 23 | * Created by XYH on 2019/12/16. |
@@ -21,6 +27,18 @@ public class PayOrderImpl implements PayOrderService { | @@ -21,6 +27,18 @@ public class PayOrderImpl implements PayOrderService { | ||
21 | @Autowired | 27 | @Autowired |
22 | PayRecordsMapper recordsMapper; | 28 | PayRecordsMapper recordsMapper; |
23 | 29 | ||
30 | + @Autowired | ||
31 | + LocationMapper locationMapper; | ||
32 | + | ||
33 | + @Autowired | ||
34 | + WaterMeterService waterMeterService; | ||
35 | + | ||
36 | + @Autowired | ||
37 | + ElectricityMeterService electricityMeterService; | ||
38 | + | ||
39 | + @Autowired | ||
40 | + WaterEleCountMoneyMapper waterEleCountMoneyMapper; | ||
41 | + | ||
24 | 42 | ||
25 | @Override | 43 | @Override |
26 | public PageInfo<PayRecords> getOrder(int pageSize, int pageNum, String orderNumber, String payTime, | 44 | public PageInfo<PayRecords> getOrder(int pageSize, int pageNum, String orderNumber, String payTime, |
@@ -65,4 +83,42 @@ public class PayOrderImpl implements PayOrderService { | @@ -65,4 +83,42 @@ public class PayOrderImpl implements PayOrderService { | ||
65 | public int delOrder(PayRecords payRecords) { | 83 | public int delOrder(PayRecords payRecords) { |
66 | return recordsMapper.deleteByPrimaryKey(payRecords.getId()); | 84 | return recordsMapper.deleteByPrimaryKey(payRecords.getId()); |
67 | } | 85 | } |
86 | + | ||
87 | + /** | ||
88 | + * 剩余水电费统计 | ||
89 | + * @throws Exception | ||
90 | + */ | ||
91 | + @Override | ||
92 | + @Scheduled(cron = "0 0 * * * ?") | ||
93 | + public void waterEleCount() throws Exception { | ||
94 | + Map<String, Object> map = new HashMap<>(); | ||
95 | + // 水量 | ||
96 | + Double wmMoney = 0.00; | ||
97 | + // 电费 | ||
98 | + Double eeMoney = 0.00; | ||
99 | + // 查询 公寓所有水电编号 | ||
100 | + List<Location> locations = locationMapper.selectByPrimaryKey(); | ||
101 | + for (Location location: locations){ | ||
102 | + // 剩余水量 查询累加 | ||
103 | + WaterMeter realTime = waterMeterService.findRealTime(location.getWmid()); | ||
104 | + String subtraction = AllUtils.nubmerSubtraction(realTime.getWmSacc(), realTime.getWmLacc()); | ||
105 | + BigDecimal wmBigDecimal = new BigDecimal(subtraction); | ||
106 | + wmMoney += wmBigDecimal.doubleValue(); | ||
107 | + // 剩余电费 累加 | ||
108 | + ElectricityMeter energyInfoForRealTime = electricityMeterService.getEnergyInfoForRealTime(location.getEeid()); | ||
109 | + if (energyInfoForRealTime != null) { | ||
110 | + // 电费累加 | ||
111 | + eeMoney+=energyInfoForRealTime.getBalance().doubleValue(); | ||
112 | + } | ||
113 | + } | ||
114 | + BigDecimal moneyWm = new BigDecimal(wmMoney); | ||
115 | + BigDecimal bigDecimal = new BigDecimal(4.5); | ||
116 | + | ||
117 | + WaterEleCountMoney waterEleCountMoney = new WaterEleCountMoney(); | ||
118 | + waterEleCountMoney.setCreateDate(new Date()); | ||
119 | + waterEleCountMoney.setEmMoney(new BigDecimal(eeMoney).setScale(2,BigDecimal.ROUND_HALF_UP)); | ||
120 | + waterEleCountMoney.setWmMoney(moneyWm.multiply(bigDecimal).setScale(2,BigDecimal.ROUND_HALF_UP)); | ||
121 | + waterEleCountMoney.setId(2); | ||
122 | + waterEleCountMoneyMapper.updateByPrimaryKeySelective(waterEleCountMoney); | ||
123 | + } | ||
68 | } | 124 | } |
@@ -13,11 +13,11 @@ | @@ -13,11 +13,11 @@ | ||
13 | <sql id="Base_Column_List"> | 13 | <sql id="Base_Column_List"> |
14 | id, adrName, parent, type, wm_id, ee_id | 14 | id, adrName, parent, type, wm_id, ee_id |
15 | </sql> | 15 | </sql> |
16 | - <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer"> | 16 | + <select id="selectByPrimaryKey" resultMap="BaseResultMap"> |
17 | select | 17 | select |
18 | <include refid="Base_Column_List"/> | 18 | <include refid="Base_Column_List"/> |
19 | from location | 19 | from location |
20 | - where id = #{id,jdbcType=INTEGER} | 20 | + where wm_id != '' and wm_id is not null and ee_id is not null and ee_id != '' |
21 | </select> | 21 | </select> |
22 | <select id="selectAll" resultMap="BaseResultMap" parameterType="java.lang.Integer"> | 22 | <select id="selectAll" resultMap="BaseResultMap" parameterType="java.lang.Integer"> |
23 | select | 23 | select |
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.sunyo.energy.location.dao.WaterEleCountMoneyMapper" > | ||
4 | + <resultMap id="BaseResultMap" type="com.sunyo.energy.location.model.WaterEleCountMoney" > | ||
5 | + <id column="id" property="id" jdbcType="INTEGER" /> | ||
6 | + <result column="wm_money" property="wmMoney" jdbcType="DECIMAL" /> | ||
7 | + <result column="em_money" property="emMoney" jdbcType="DECIMAL" /> | ||
8 | + <result column="create_date" property="createDate" jdbcType="TIMESTAMP" /> | ||
9 | + </resultMap> | ||
10 | + <sql id="Base_Column_List" > | ||
11 | + id, wm_money, em_money, create_date | ||
12 | + </sql> | ||
13 | + <select id="selectByPrimaryKey" resultMap="BaseResultMap" > | ||
14 | + select | ||
15 | + <include refid="Base_Column_List" /> | ||
16 | + from water_ele_count_money | ||
17 | + </select> | ||
18 | + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > | ||
19 | + delete from water_ele_count_money | ||
20 | + where id = #{id,jdbcType=INTEGER} | ||
21 | + </delete> | ||
22 | + <insert id="insert" parameterType="com.sunyo.energy.location.model.WaterEleCountMoney" > | ||
23 | + insert into water_ele_count_money (id, wm_money, em_money, | ||
24 | + create_date) | ||
25 | + values (#{id,jdbcType=INTEGER}, #{wmMoney,jdbcType=DECIMAL}, #{emMoney,jdbcType=DECIMAL}, | ||
26 | + #{createDate,jdbcType=TIMESTAMP}) | ||
27 | + </insert> | ||
28 | + <insert id="insertSelective" parameterType="com.sunyo.energy.location.model.WaterEleCountMoney" > | ||
29 | + insert into water_ele_count_money | ||
30 | + <trim prefix="(" suffix=")" suffixOverrides="," > | ||
31 | + <if test="id != null" > | ||
32 | + id, | ||
33 | + </if> | ||
34 | + <if test="wmMoney != null" > | ||
35 | + wm_money, | ||
36 | + </if> | ||
37 | + <if test="emMoney != null" > | ||
38 | + em_money, | ||
39 | + </if> | ||
40 | + <if test="createDate != null" > | ||
41 | + create_date, | ||
42 | + </if> | ||
43 | + </trim> | ||
44 | + <trim prefix="values (" suffix=")" suffixOverrides="," > | ||
45 | + <if test="id != null" > | ||
46 | + #{id,jdbcType=INTEGER}, | ||
47 | + </if> | ||
48 | + <if test="wmMoney != null" > | ||
49 | + #{wmMoney,jdbcType=DECIMAL}, | ||
50 | + </if> | ||
51 | + <if test="emMoney != null" > | ||
52 | + #{emMoney,jdbcType=DECIMAL}, | ||
53 | + </if> | ||
54 | + <if test="createDate != null" > | ||
55 | + #{createDate,jdbcType=TIMESTAMP}, | ||
56 | + </if> | ||
57 | + </trim> | ||
58 | + </insert> | ||
59 | + <update id="updateByPrimaryKeySelective" parameterType="com.sunyo.energy.location.model.WaterEleCountMoney" > | ||
60 | + update water_ele_count_money | ||
61 | + <set > | ||
62 | + <if test="wmMoney != null" > | ||
63 | + wm_money = #{wmMoney,jdbcType=DECIMAL}, | ||
64 | + </if> | ||
65 | + <if test="emMoney != null" > | ||
66 | + em_money = #{emMoney,jdbcType=DECIMAL}, | ||
67 | + </if> | ||
68 | + <if test="createDate != null" > | ||
69 | + create_date = #{createDate,jdbcType=TIMESTAMP}, | ||
70 | + </if> | ||
71 | + </set> | ||
72 | + where id = #{id,jdbcType=INTEGER} | ||
73 | + </update> | ||
74 | + <update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.WaterEleCountMoney" > | ||
75 | + update water_ele_count_money | ||
76 | + set wm_money = #{wmMoney,jdbcType=DECIMAL}, | ||
77 | + em_money = #{emMoney,jdbcType=DECIMAL}, | ||
78 | + create_date = #{createDate,jdbcType=TIMESTAMP} | ||
79 | + where id = #{id,jdbcType=INTEGER} | ||
80 | + </update> | ||
81 | +</mapper> |
-
请 注册 或 登录 后发表评论